forked from GitHub/dbot
fix ~setaliasparents, implement mobile aliases [#573]
This commit is contained in:
parent
c5a3d75d29
commit
2f2c702c8f
@ -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')
|
||||
|
@ -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));
|
||||
},
|
||||
|
@ -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, ",
|
||||
|
Loading…
Reference in New Issue
Block a user