3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-03 17:39:28 +01:00

addTimeout for timers module [#494]

This commit is contained in:
reality 2013-06-09 15:25:06 +00:00
parent 32b89794cb
commit 8a7333cef3

View File

@ -34,6 +34,18 @@ var timers = function(dbot) {
}
}.bind(this), timeout));
}
},
'addTimeout': function(date, callback, params) {
var now = new Date().getTime()
timeout = date.getTime() - now;
this.runningTimeouts.push(setTimeout(function() {
try {
callback.apply(callback, params);
} catch(err) {
console.log('Callback failed: ' + err);
}
}, timeout));
}
};