mirror of
https://github.com/reality/dbot.git
synced 2025-01-23 10:34:31 +01:00
adding support for ban/unban from ignore module, with wildcards
This commit is contained in:
parent
e90572aebf
commit
af3a8bf1f2
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"ignorable": false,
|
"ignorable": false,
|
||||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md",
|
"help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md",
|
||||||
"dbKeys": [ "ignores" ]
|
"dbKeys": [ "ignores", "bans" ]
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,66 @@ var ignore = function(dbot) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'~ban': function(event) {
|
||||||
|
var user = event.params[1];
|
||||||
|
var module = event.params[2];
|
||||||
|
|
||||||
|
if(_.isUndefined(user) || _.isUndefined(module)) {
|
||||||
|
event.reply(dbot.t('ban_usage', {'user': event.user}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(module == '*' || _.include(dbot.config.moduleNames, module) || _.include(dbot.commands, module)) {
|
||||||
|
if(_.has(dbot.db.bans, user) && _.include(dbot.db.bans[user], module)) {
|
||||||
|
event.reply(dbot.t('already_banned', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': user
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_.has(dbot.db.bans, event.params[1])) {
|
||||||
|
dbot.db.bans[event.params[1]].push(module);
|
||||||
|
} else {
|
||||||
|
dbot.db.bans[event.params[1]] = [module];
|
||||||
|
}
|
||||||
|
|
||||||
|
event.reply(dbot.t('banned_success', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': user,
|
||||||
|
'module': module
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('invalid_ban', {'user': event.user}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~unban': function(event) {
|
||||||
|
var bannedModules = [];
|
||||||
|
|
||||||
|
var user = event.params[1];
|
||||||
|
var module = event.params[2];
|
||||||
|
|
||||||
|
if(_.isUndefined(user) || _.isUndefined(module)) {
|
||||||
|
event.reply(dbot.t('unban_usage', {'user': event.user}));
|
||||||
|
} else {
|
||||||
|
if(_.has(dbot.db.bans, user) && _.include(dbot.db.bans[user], module)) {
|
||||||
|
dbot.db.bans[user].splice(dbot.db.bans[user].indexOf(module), 1);
|
||||||
|
|
||||||
|
event.reply(dbot.t('unbanned_success', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': user,
|
||||||
|
'module': module
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('invalid_unban', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': user
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
'~ignorechannel': function(event) {
|
'~ignorechannel': function(event) {
|
||||||
var channel = ((event.params[1] == '@') ? event.channel.name : event.params[1]);
|
var channel = ((event.params[1] == '@') ? event.channel.name : event.params[1]);
|
||||||
var module = event.params[2];
|
var module = event.params[2];
|
||||||
@ -118,6 +178,8 @@ var ignore = function(dbot) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
commands['~ban'].access = 'moderator';
|
||||||
|
commands['~unban'].access = 'moderator';
|
||||||
commands['~ignorechannel'].access = 'moderator';
|
commands['~ignorechannel'].access = 'moderator';
|
||||||
commands['~unignorechannel'].access = 'moderator';
|
commands['~unignorechannel'].access = 'moderator';
|
||||||
|
|
||||||
|
@ -41,6 +41,27 @@
|
|||||||
"na'vi": "{user}: Nga terìng mikyun {module}ne set",
|
"na'vi": "{user}: Nga terìng mikyun {module}ne set",
|
||||||
"cy": "{user}: Ddim yn anwybyddu {module} bellach"
|
"cy": "{user}: Ddim yn anwybyddu {module} bellach"
|
||||||
},
|
},
|
||||||
|
"ban_usage": {
|
||||||
|
"en": "{user}: Usage: ~ban [user] [module/command]. Use * for all modules and commands."
|
||||||
|
},
|
||||||
|
"already_banned": {
|
||||||
|
"en": "{user}: {banned} is already banned from that module."
|
||||||
|
},
|
||||||
|
"banned_success": {
|
||||||
|
"en": "{user}: {banned} is now banned from {module}."
|
||||||
|
},
|
||||||
|
"invalid_ban": {
|
||||||
|
"en": "{user}: That isn't a valid module name."
|
||||||
|
},
|
||||||
|
"unban_usage": {
|
||||||
|
"en": "{user}: Usage: ~unban [user] [module]."
|
||||||
|
},
|
||||||
|
"invalid_unban": {
|
||||||
|
"en": "{user}: {banned} is not banned from that module or it doesn't exist."
|
||||||
|
},
|
||||||
|
"unbanned_success": {
|
||||||
|
"en": "{user}: {banned} is no longer banned from {module}."
|
||||||
|
},
|
||||||
"ignoring_channel": {
|
"ignoring_channel": {
|
||||||
"en": "Now ignoring {module} in {channel}",
|
"en": "Now ignoring {module} in {channel}",
|
||||||
"na'vi": "Oe ke stayawm {module}ur mì {channel}"
|
"na'vi": "Oe ke stayawm {module}ur mì {channel}"
|
||||||
|
Loading…
Reference in New Issue
Block a user