mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
parent
3021601c52
commit
68b0977bae
@ -21,8 +21,8 @@ var command = function(dbot) {
|
||||
}
|
||||
|
||||
this.api.hasAccess(event.server, event.user, commandName, function(hasAccess) {
|
||||
dbot.api.ignore.isUserIgnoring(event.server, event.user, commandName, function(isIgnoring) {
|
||||
dbot.api.ignore.isUserBanned(event.server, event.user, commandName, function(isBanned) {
|
||||
dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) {
|
||||
dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) {
|
||||
if(isBanned) {
|
||||
if(this.config.banOutput && commandName != '~') {
|
||||
event.reply(dbot.t('command_ban', {'user': event.user}));
|
||||
|
@ -3,18 +3,18 @@ var _ = require('underscore')._;
|
||||
var api = function(dbot) {
|
||||
return {
|
||||
// Is user ignoring command/module?
|
||||
'isUserIgnoring': function(server, user, item, callback) {
|
||||
this.internalAPI.isUserImpeded(server, user, item, 'ignores', callback);
|
||||
'isUserIgnoring': function(user, item, callback) {
|
||||
this.internalAPI.isUserImpeded(user, item, 'ignores', callback);
|
||||
},
|
||||
|
||||
// Is user banned from command/module?
|
||||
'isUserBanned': function(server, user, item, callback) {
|
||||
this.internalAPI.isUserImpeded(server, user, item, 'bans', callback);
|
||||
'isUserBanned': function(user, item, callback) {
|
||||
this.internalAPI.isUserImpeded(user, item, 'bans', callback);
|
||||
},
|
||||
|
||||
// Is channel ignoring module?
|
||||
// TODO: Command support
|
||||
'isChannelIgnoring': function(server, channelName, item, callback) {
|
||||
'isChannelIgnoring': function(channelName, item, callback) {
|
||||
var isIgnoring = false,
|
||||
channel = false;
|
||||
|
||||
@ -32,16 +32,14 @@ var api = function(dbot) {
|
||||
},
|
||||
|
||||
// Resolve a nick and return their user and ignores object
|
||||
'getUserIgnores': function(server, user, callback) {
|
||||
dbot.api.users.resolveUser(server, user, function(user) {
|
||||
if(user) {
|
||||
'getUserIgnores': function(user, callback) {
|
||||
this.db.read('ignores', user.id, function(err, ignores) {
|
||||
callback(false, user, ignores);
|
||||
});
|
||||
if(!err && ignores) {
|
||||
callback(false, ignores);
|
||||
} else {
|
||||
callback(true, null, null);
|
||||
callback(true, null);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ var _ = require('underscore')._,
|
||||
|
||||
var ignore = function(dbot) {
|
||||
this.internalAPI = {
|
||||
'isUserImpeded': function(server, user, item, by, callback) {
|
||||
this.api.getUserIgnores(server, user, function(err, user, ignores) {
|
||||
'isUserImpeded': function(user, item, by, callback) {
|
||||
this.api.getUserIgnores(user, function(err, ignores) {
|
||||
var isImpeded = false;
|
||||
if(!err && ignores) {
|
||||
if(_.has(dbot.commands, item)) {
|
||||
@ -33,7 +33,7 @@ var ignore = function(dbot) {
|
||||
var module = event.params[1];
|
||||
var ignorableModules = _.chain(dbot.modules)
|
||||
.filter(function(module, name) {
|
||||
return dbot.config[module].ignorable === true;
|
||||
return dbot.config.modules[module].ignorable === true;
|
||||
})
|
||||
.pluck('name')
|
||||
.value();
|
||||
@ -45,11 +45,10 @@ var ignore = function(dbot) {
|
||||
}));
|
||||
} else {
|
||||
if(module == '*' || _.include(ignorableModules, module)) {
|
||||
this.api.getUserIgnores(event.server, event.user, function(err, user, ignores) {
|
||||
if(!err) {
|
||||
this.api.getUserIgnores(event.rUser, function(err, ignores) {
|
||||
if(!ignores) {
|
||||
ignores = {
|
||||
'id': user.id,
|
||||
'id': event.rUser.id,
|
||||
'ignores': [],
|
||||
'bans': []
|
||||
};
|
||||
@ -57,7 +56,7 @@ var ignore = function(dbot) {
|
||||
|
||||
if(!_.include(ignores.ignores, module)) {
|
||||
ignores.ignores.push(module);
|
||||
this.db.save('ignores', user.id, ignores, function(err) {
|
||||
this.db.save('ignores', event.rUser.id, ignores, function(err) {
|
||||
if(!err) {
|
||||
dbot.instance.ignoreTag(event.user, module);
|
||||
event.reply(dbot.t('ignored', {
|
||||
@ -69,9 +68,6 @@ var ignore = function(dbot) {
|
||||
} else {
|
||||
event.reply(dbot.t('already_ignoring', { 'user': event.user }));
|
||||
}
|
||||
} else {
|
||||
// User doesn't exist
|
||||
}
|
||||
}.bind(this));
|
||||
} else {
|
||||
event.reply(dbot.t('invalid_ignore', { 'user': event.user }));
|
||||
@ -82,16 +78,22 @@ var ignore = function(dbot) {
|
||||
'~unignore': function(event) {
|
||||
var module = event.params[1];
|
||||
|
||||
this.api.getUserIgnores(event.server, event.user, function(err, user, ignores) {
|
||||
this.api.getUserIgnores(event.rUser, function(err, ignores) {
|
||||
if(err || !ignores || _.isUndefined(module)) {
|
||||
if(ignores) {
|
||||
event.reply(dbot.t('unignore_usage', {
|
||||
'user': event.user,
|
||||
'modules': ignores.ignores.join(', ')
|
||||
}));
|
||||
} else {
|
||||
event.reply(dbot.t('empty_unignore_usage', {
|
||||
'user': event.user
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
if(_.include(ignores.ignores, module)) {
|
||||
ignores.ignores = _.without(ignores.ignores, module);
|
||||
this.db.save('ignores', user.id, ignores, function(err) {
|
||||
this.db.save('ignores', event.rUser.id, ignores, function(err) {
|
||||
if(!err) {
|
||||
dbot.instance.removeIgnore(event.user, module)
|
||||
event.reply(dbot.t('unignored', {
|
||||
@ -112,7 +114,8 @@ var ignore = function(dbot) {
|
||||
item = event.input[2];
|
||||
|
||||
if(module == '*' || _.include(dbot.config.moduleNames, item) || _.include(dbot.commands, item)) {
|
||||
this.api.getUserIgnores(event.server, nick, function(err, user, ignores) {
|
||||
dbot.api.users.resolveUser(event.server, nick, function(user) {
|
||||
this.api.getUserIgnores(user, function(err, ignores) {
|
||||
if(!err) {
|
||||
if(!ignores) {
|
||||
ignores = {
|
||||
@ -141,6 +144,7 @@ var ignore = function(dbot) {
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
} else {
|
||||
event.reply(dbot.t('invalid_ban', { 'user': event.user }));
|
||||
}
|
||||
@ -150,7 +154,8 @@ var ignore = function(dbot) {
|
||||
var nick = event.input[1],
|
||||
item = event.input[2];
|
||||
|
||||
this.api.getUserIgnores(event.server, nick, function(err, user, ignores) {
|
||||
dbot.api.users.resolveUser(event.server, nick, function(user) {
|
||||
this.api.getUserIgnores(user, function(err, ignores) {
|
||||
if(err || !ignores) {
|
||||
event.reply(dbot.t('invalid_unban', {
|
||||
'user': event.user,
|
||||
@ -174,6 +179,7 @@ var ignore = function(dbot) {
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
'~ignorechannel': function(event) {
|
||||
|
@ -39,6 +39,14 @@
|
||||
"nl": "{user}: Gebruik: ~unignore [module]. Modules die momenteel worden genegeerd: {modules}.",
|
||||
"de": "{user}: Benutzung: ~unignore [module]. Module, die im Moment ignoriert werden: {modules}."
|
||||
},
|
||||
"empty_unignore_usage": {
|
||||
"en": "{user}: Usage: ~unignore [module].",
|
||||
"es": "{user}: Modo de empleo: ~unignore [módulo].",
|
||||
"na'vi": "{user}: Sar: ~unignore ['u].",
|
||||
"cy": "{user}: Defnydd: ~unignore [modiwl].",
|
||||
"nl": "{user}: Gebruik: ~unignore [module].",
|
||||
"de": "{user}: Benutzung: ~unignore [module]."
|
||||
},
|
||||
"invalid_unignore": {
|
||||
"en": "{user}: You're not ignoring that module or it doesn't exist.",
|
||||
"es": "{user}: No ignoras este módulo o no existe.",
|
||||
@ -57,7 +65,7 @@
|
||||
},
|
||||
"ban_usage": {
|
||||
"en": "{user}: Usage: ~ban [user] [module/command]. Use * for all modules and commands.",
|
||||
"cy": "{user}: Defnydd: ~ban [defnyddiwr] [modiwl/gorchymyn]. Defnyddio * am pob modiwlau a gorchmynion."
|
||||
"cy": "{user}: Defnydd: ~ban [defnyddiwr] [modiwl/gorchymyn]. Defnyddio * am pob modiwlau a gorchmynion.",
|
||||
"nl": "{user}: Gebruik: ~ban [gebruiker] [module/commando]. Gebruik * voor alle modules en alle commandos.",
|
||||
"de": "{user}: Benutzung ~ban [Benutzer] [module/Befehl]. Benutze * für alle Module und Befehle."
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user