From 450ffce0e238227f62bc5fe849cc0539c3cd5eb3 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 3 Aug 2013 01:53:36 +0000 Subject: [PATCH] stagger pend notifies --- modules/report/report.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/report/report.js b/modules/report/report.js index b196147..6a91c20 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -50,10 +50,21 @@ var report = function(dbot) { this.listener = function(event) { if(_.has(this.pending, event.rUser.id)) { - _.each(this.pending[event.rUser.id], function(message) { - dbot.say(event.server, event.rUser.currentNick, message); - }); - delete this.pending[event.rUser.id]; + var i=0, + pending = this.pending[event.rUser.id]; + + var notifyUser = function(pending) { + if(i >= msg.length) { + delete this.pending[event.rUser.id]; + return; + } + dbot.say(event.server, pending[i], message); + setTimeout(function() { + i++; notifyUser(pending); + }, 1000); + }.bind(this); + + notifyUser(pending); } }.bind(this); this.on = 'JOIN';