fix for currentnick

This commit is contained in:
reality 2013-08-29 20:07:30 +00:00
parent 2f2c702c8f
commit 26bce2e8a0
2 changed files with 21 additions and 2 deletions

View File

@ -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);
};

View File

@ -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);
}