mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
~ignorechannel and ~unignorechannel commands in [#190]
This commit is contained in:
parent
7cf2d051ad
commit
4a64928fd6
@ -2,7 +2,8 @@
|
||||
* Module Name: Ignore
|
||||
* Description: Handles commands in which users can choose to ignore listeners
|
||||
* and commands from certain modules. It also populates the JSBot instance with
|
||||
* this information, since that actually performs the ignorance.
|
||||
* this information, since that actually performs the ignorance. Also provides
|
||||
* commands for moderators to choose the bot to ignore certain channels.
|
||||
*/
|
||||
var _ = require('underscore')._;
|
||||
|
||||
@ -69,15 +70,64 @@ var ignore = function(dbot) {
|
||||
event.reply(dbot.t('invalid_unignore', { 'user': event.user }));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'~ignorechannel': function(event) {
|
||||
var channel = ((event.params[1] == '@') ? event.channel.name : event.params[1]);
|
||||
var module = event.params[2];
|
||||
|
||||
// Ignoring the value of 'ignorable' at the moment
|
||||
if(_.include(dbot.config.moduleNames, module)) {
|
||||
if(!_.has(dbot.db.ignores, channel)) dbot.db.ignores[channel] = [];
|
||||
if(!_.include(dbot.db.ignores[channel], module)) {
|
||||
dbot.db.ignores[channel].push(module);
|
||||
dbot.instance.ignoreTag(channel, module);
|
||||
event.reply(dbot.t('ignoring_channel', {
|
||||
'module': module,
|
||||
'channel': channel
|
||||
})e;
|
||||
} else {
|
||||
event.reply(dbot.t('already_ignoring_channel', {
|
||||
'module': module,
|
||||
'channel': channel
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
event.reply(dbot.t('module_not_exist', { 'module': module }));
|
||||
}
|
||||
},
|
||||
|
||||
'~unignorechannel': function(event) {
|
||||
var channel = ((event.params[1] == '@') ? event.channel.name : event.params[1]);
|
||||
var module = event.params[2];
|
||||
|
||||
if(!_.has(dbot.db.ignores, channel)) dbot.db.ignores[channel] = [];
|
||||
if(_.include(dbot.db.ignores[channel], module)) {
|
||||
dbot.db.ignores[channel] = _.without(dbot.db.ignores[channel], module);
|
||||
dbot.instance.removeIgnore(channel, module);
|
||||
event.reply(dbot.t('unignoring_channel', {
|
||||
'module': module,
|
||||
'channel': channel
|
||||
}));
|
||||
} else {
|
||||
event.reply(dbot.t('not_ignoring_channel', {
|
||||
'module': module,
|
||||
'channel': channel
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
commands['~ignorechannel'].access = 'moderator';
|
||||
commands['~unignorechannel'].access = 'moderator';
|
||||
|
||||
this.commands = commands;
|
||||
|
||||
this.onLoad = function() {
|
||||
dbot.instance.clearIgnores();
|
||||
_.each(dbot.db.ignores, function(ignores, user) {
|
||||
_.each(dbot.db.ignores, function(ignores, item) {
|
||||
_.each(ignores, function(ignore) {
|
||||
dbot.instance.ignoreTag(user, ignore);
|
||||
dbot.instance.ignoreTag(item, ignore);
|
||||
}, this);
|
||||
}, this);
|
||||
};
|
||||
|
@ -40,5 +40,20 @@
|
||||
"spanish": "{user}: Ya no ignoras {module}.",
|
||||
"na'vi": "{user}: Nga terìng mikyun {module}ne set",
|
||||
"welsh": "{user}: Ddim yn anwybyddu {module} bellach"
|
||||
},
|
||||
"ignoring_channel": {
|
||||
"english": "Now ignoring {module} in {channel}"
|
||||
},
|
||||
"already_ignoring_channel": {
|
||||
"english": "Already ignoring {module} in {channel}"
|
||||
},
|
||||
"module_not_exist": {
|
||||
"english": "{module} isn't loaded or doesn't exist."
|
||||
},
|
||||
"unignoring_channel": {
|
||||
"english": "No longer ignoring {module} in {channel}"
|
||||
},
|
||||
"not_ignoring_channel": {
|
||||
"english": "{module} wasn't being ignored in {channel}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user