From 26bce2e8a0973d83390a84d17cce9ab1a2c2e817 Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 29 Aug 2013 20:07:30 +0000 Subject: [PATCH] fix for currentnick --- modules/report/report.js | 14 ++++++++++++++ modules/users/users.js | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/report/report.js b/modules/report/report.js index 3b60720..5b18099 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -207,6 +207,20 @@ var report = function(dbot) { this.db.save('notifies', notify.id, notify, function() {}); }.bind(this), function() {}); }.bind(this)); + + dbot.api.event.addHook('new_current_nick', function(user) { + if(_.has(this.pending, user.id) && this.pNotify[user.id] === true + && !_.include(user.mobile, user.currentNick)) { + dbot.say(user.server, user.currentNick, dbot.t('missed_notifies', { + 'user': user.primaryNick, + 'link': dbot.api.web.getUrl('notify/' + user.server + '/missing') + })); + this.pNotify[user.id] = false; + } + + }.bind(this)); + + }.bind(this); }; diff --git a/modules/users/users.js b/modules/users/users.js index 78ee8ac..1346f60 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -22,7 +22,8 @@ var users = function(dbot) { 'currentNick': nick, 'server': server, 'channels': [], - 'aliases': [] + 'aliases': [], + 'mobile': [] }, function(err, result) { if(!err) { dbot.api.event.emit('new_user', [ result ]); @@ -96,6 +97,7 @@ var users = function(dbot) { this.listener = function(event) { this.api.isKnownUser(event.server, event.newNick, function(isKnown) { event.rUser.currentNick = event.newNick; + dbot.api.event.emit('new_current_nick', [ event.rUser ]); if(!isKnown) { event.rUser.aliases.push(event.newNick); @@ -133,7 +135,10 @@ var users = function(dbot) { } else { if(event.user != user.currentNick) { user.currentNick = event.user; - this.db.save('users', user.id, user, function() { done(user); }); + this.db.save('users', user.id, user, function() { + dbot.api.event.emit('new_current_nick', [ user ]); + done(user); + }); } else { done(user); }