Skip to content

Instantly share code, notes, and snippets.

@tarchan
Created July 12, 2011 13:11
Show Gist options
  • Save tarchan/1077947 to your computer and use it in GitHub Desktop.
Save tarchan/1077947 to your computer and use it in GitHub Desktop.
10分ごとに時報を流すスクリプトです。
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