diff --git a/modules/timers/timers.js b/modules/timers/timers.js index b1e968d..2acb505 100644 --- a/modules/timers/timers.js +++ b/modules/timers/timers.js @@ -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)); } };