Created
July 12, 2011 13:11
-
-
Save tarchan/1077947 to your computer and use it in GitHub Desktop.
10分ごとに時報を流すスクリプトです。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var interval = 10 * 60 * 1000; // 10分 | |
var where = '#limechat'; | |
function setTimeout(func, time) | |
{ | |
println("タイマーを開始します。: " + time); | |
java.lang.Thread.sleep(time); | |
func(); | |
} | |
function send(channel, text) | |
{ | |
println(channel + ": " + text); | |
} | |
function showTime() | |
{ | |
send(where, new Date().toString() + ' になりました'); | |
setNextTimer(); | |
} | |
function setNextTimer() | |
{ | |
var now = new Date().getTime(); | |
var next = (Math.floor(now / interval) +1) * interval; | |
setTimeout(showTime, next - now) | |
} | |
setNextTimer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment