mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
whoops
This commit is contained in:
commit
f8bc0be366
@ -35,12 +35,21 @@ var api = function(dbot) {
|
||||
return k;
|
||||
}
|
||||
}.bind(this));
|
||||
this.db.read('nunsubs', cName + '.' + server, function(err, nunsubs) {
|
||||
if(nunsubs) {
|
||||
_.each(nunsubs.users, function(user) {
|
||||
var uPart = user.split('.')[0];
|
||||
if(_.include(ops, uPart)) {
|
||||
ops = _.without(ops, uPart);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var offlineOps = {};
|
||||
async.each(ops, function(op, done) {
|
||||
dbot.api.users.isOnline(server, cName, op, function(err, user, online) {
|
||||
if(!err && !online) offlineOps[op] = user;
|
||||
if(user && user.currentNick !== op) {
|
||||
if(user.currentNick !== op) {
|
||||
ops = _.without(ops, op);
|
||||
ops.push(user.currentNick);
|
||||
}
|
||||
@ -69,6 +78,7 @@ var api = function(dbot) {
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
} else {
|
||||
var channel = dbot.instance.connections[server].channels[cName];
|
||||
var ops = _.filter(channel.nicks, function(user) {
|
||||
@ -85,7 +95,7 @@ var api = function(dbot) {
|
||||
var perOps = channel.op;
|
||||
if(this.config.notifyVoice) perOps = _.union(perOps, channel.voice);
|
||||
|
||||
this.db.read('nunsubs', channel.id, function(err, nunsubs) {
|
||||
this.db.read('nunsubs', cName + '.' + server, function(err, nunsubs) {
|
||||
async.eachSeries(ops, function(nick, next) {
|
||||
dbot.api.users.resolveUser(server, nick, function(user) {
|
||||
if(nunsubs && _.include(nunsubs.users, user.id)) {
|
||||
|
@ -139,21 +139,21 @@ var commands = function(dbot) {
|
||||
},
|
||||
|
||||
'~nunsub': function(event) {
|
||||
var cName = event.input[1];
|
||||
var cName = event.input[1],
|
||||
cId = event.input[1] + '.' + event.server;
|
||||
|
||||
dbot.api.users.resolveChannel(event.server, cName, function(channel) {
|
||||
if(channel) {
|
||||
this.db.read('nunsubs', channel.id, function(err, nunsubs) {
|
||||
if(_.has(dbot.instance.connections[event.server].channels, cName)) {
|
||||
this.db.read('nunsubs', cId, function(err, nunsubs) {
|
||||
if(!nunsubs) {
|
||||
var nunsubs = {
|
||||
'id': channel.id,
|
||||
'id': cId,
|
||||
'users': []
|
||||
}
|
||||
}
|
||||
|
||||
if(!_.include(nunsubs, event.rUser.id)) {
|
||||
nunsubs.users.push(event.rUser.id);
|
||||
this.db.save('nunsubs', channel.id, nunsubs, function() {
|
||||
this.db.save('nunsubs', cId, nunsubs, function() {
|
||||
var reply = dbot.t('nunsubbed', { 'cName': cName })
|
||||
if(_.has(this.config.chan_redirs, cName)) {
|
||||
reply += dbot.t('n_also_found', { 'afaName' : this.config.chan_redirs[cName] });
|
||||
@ -167,18 +167,17 @@ var commands = function(dbot) {
|
||||
} else {
|
||||
event.reply('Channel not known.');
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
'~ununsub': function(event) {
|
||||
var cName = event.input[1];
|
||||
var cName = event.input[1],
|
||||
cId = event.input[1] + '.' + event.server;
|
||||
|
||||
dbot.api.users.resolveChannel(event.server, cName, function(channel) {
|
||||
if(channel) {
|
||||
this.db.read('nunsubs', channel.id, function(err, nunsubs) {
|
||||
if(_.has(dbot.instance.connections[event.server].channels, cName)) {
|
||||
this.db.read('nunsubs', cId, function(err, nunsubs) {
|
||||
if(!_.isUndefined(nunsubs) && _.include(nunsubs.users, event.rUser.id)) {
|
||||
nunsubs.users = _.without(nunsubs.users, event.rUser.id);
|
||||
this.db.save('nunsubs', channel.id, nunsubs, function() {
|
||||
this.db.save('nunsubs', cId, nunsubs, function() {
|
||||
event.reply(dbot.t('ununsubbed', { 'cName': cName }));
|
||||
});
|
||||
} else {
|
||||
@ -188,7 +187,6 @@ var commands = function(dbot) {
|
||||
} else {
|
||||
event.reply('Channel not known.');
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
commands['~report'].regex = /^report (#[^ ]+ )?([^ ]+) (.*)$/;
|
||||
|
Loading…
Reference in New Issue
Block a user