diff --git a/modules/report/report.js b/modules/report/report.js index 4249357..3b60720 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -74,14 +74,21 @@ var report = function(dbot) { dbot.api.users.resolveChannel(server, cName, function(channel) { if(channel) { var perOps = channel.op; - if(this.config.notifyVoice) pOps = _.union(perOps, channel.voice); + if(this.config.notifyVoice) perOps = _.union(perOps, channel.voice); async.eachSeries(ops, function(nick, next) { dbot.api.users.resolveUser(server, nick, function(user) { - perOps = _.without(perOps, user.id); next(); + console.log(user.mobile); + console.log(user.currentNick); + console.log(_.include(user.mobile, user.currentNick)); + if(!_.include(user.mobile, user.currentNick)) { + perOps = _.without(perOps, user.id); + } + next(); }); }, function() { offlineUsers = perOps; + console.log(offlineUsers); _.each(offlineUsers, function(id) { if(!this.pending[id]) this.pending[id] = []; this.pending[id].push({ @@ -105,7 +112,7 @@ var report = function(dbot) { }; this.listener = function(event) { - if(_.has(this.pending, event.rUser.id) && this.pNotify[event.rUser.id] === true) { + if(_.has(this.pending, event.rUser.id) && this.pNotify[event.rUser.id] === true && !_.include(event.rUser.mobile, event.rUser.currentNick)) { dbot.say(event.server, event.user, dbot.t('missed_notifies', { 'user': event.rUser.primaryNick, 'link': dbot.api.web.getUrl('notify/' + event.server + '/missing') diff --git a/modules/users/commands.js b/modules/users/commands.js index 6c27f39..a347064 100644 --- a/modules/users/commands.js +++ b/modules/users/commands.js @@ -35,6 +35,22 @@ var commands = function(dbot) { }); }, + '~setmobilealias': function(event) { + if(_.include(event.rUser.aliases, event.params[1])) { + if(!_.has(event.rUser, 'mobile')) event.rUser.mobile = []; + if(!_.include(event.rUser.mobile, event.params[1])) { + event.rUser.mobile.push(event.params[1]); + this.db.save('users', event.rUser.id, event.rUser, function(err) { + event.reply(dbot.t('added_mobile_alias', { 'alias': event.params[1] })); + }); + } else { + event.reply(dbot.t('already_mobile', { 'alias': event.params[1] })); + } + } else { + event.reply(dbot.t('unknown_alias', { 'alias': event.params[1] })); + } + }, + '~addalias': function(event) { var nick = event.input[1], alias = event.input[2]; @@ -66,6 +82,7 @@ var commands = function(dbot) { this.api.resolveUser(event.server, alias, function(user) { if(user) { user.aliases = _.without(user.aliases, alias); + user.mobile = _.without(user.mobile, alias); this.db.save('users', user.id, user, function(err) { event.reply(dbot.t('alias_removed', { 'primary': user.primaryNick, @@ -86,7 +103,6 @@ var commands = function(dbot) { user.primaryNick = newPrimary; user.aliases = _.without(user.aliases, newPrimary); user.aliases.push(newAlias); - this.internalAPI.updateChannelPrimaryUser(event.server, newAlias, newPrimary); this.db.save('users', user.id, user, function(err) { if(!err) { @@ -101,7 +117,7 @@ var commands = function(dbot) { } }); } else { - event.reply(dbot.t('unknown_alias', { 'alias': newPrimarj })); + event.reply(dbot.t('unknown_alias', { 'alias': newPrimary })); } }.bind(this)); }, diff --git a/modules/users/strings.json b/modules/users/strings.json index fc2facd..e812416 100644 --- a/modules/users/strings.json +++ b/modules/users/strings.json @@ -8,6 +8,12 @@ "fr": "{alias} est un alias de {user}", "it": "{alias} รจ un alias di {user}" }, + "added_mobile_alias": { + "en": "{alias} added as a mobile alias." + }, + "already_mobile": { + "en": "{alias} is already a mobile alias." + }, "primary": { "en": "{user} (currently {currentNick}) is a primary user with {count} aliases, ", "na'vi": "{user} ({currentNick}) lu txin ulte {count}a stxo lu poru, ",