mirror of
https://github.com/reality/dbot.git
synced 2025-04-01 13:27:30 +02:00
Add check for channel ignorance in command execution logic [#190]
This commit is contained in:
parent
27e24a8173
commit
eb62212626
@ -11,11 +11,12 @@ Command flow:
|
|||||||
command name
|
command name
|
||||||
2. Is the user banned from running the given command?
|
2. Is the user banned from running the given command?
|
||||||
3. Is the user ignoring the command?
|
3. Is the user ignoring the command?
|
||||||
3. Does the use have the access level to run the command?
|
4. Is the channel ignoring the command?
|
||||||
4. Is the command set as disabled?
|
5. Does the use have the access level to run the command?
|
||||||
4. Apply regex to the command, pass into event object.
|
6. Is the command set as disabled?
|
||||||
|
7. Apply regex to the command, pass into event object.
|
||||||
* If regex does not apply, show usage info.
|
* If regex does not apply, show usage info.
|
||||||
5. Run the command.
|
8. Run the command.
|
||||||
|
|
||||||
This is the only module which is force loaded, even if it's not specified in
|
This is the only module which is force loaded, even if it's not specified in
|
||||||
the configuration file.
|
the configuration file.
|
||||||
|
@ -34,15 +34,12 @@ var api = function(dbot) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is user ignoring command?
|
* Is item (user or channel) ignoring command?
|
||||||
*/
|
*/
|
||||||
'isIgnoring': function(user, command) {
|
'isIgnoring': function(item, command) {
|
||||||
var module = dbot.commands[command].module;
|
var module = dbot.commands[command].module;
|
||||||
var ignoring = false;
|
return (_.has(dbot.db.ignores, item) &&
|
||||||
if(_.has(dbot.db.ignores, user) && _.include(dbot.db.ignores[user], module)) {
|
_.include(dbot.db.ignores[item], module));
|
||||||
ignoring = true;
|
|
||||||
}
|
|
||||||
return ignoring;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +25,7 @@ var command = function(dbot) {
|
|||||||
event.reply(dbot.t('command_ban', {'user': event.user}));
|
event.reply(dbot.t('command_ban', {'user': event.user}));
|
||||||
} else {
|
} else {
|
||||||
if(!this.api.isIgnoring(event.user, commandName) &&
|
if(!this.api.isIgnoring(event.user, commandName) &&
|
||||||
|
!this.api.isIgnoring(event.channel, commandName) &&
|
||||||
this.api.hasAccess(event.user, commandName) &&
|
this.api.hasAccess(event.user, commandName) &&
|
||||||
dbot.commands[commandName].disabled !== true) {
|
dbot.commands[commandName].disabled !== true) {
|
||||||
if(this.api.applyRegex(commandName, event)) {
|
if(this.api.applyRegex(commandName, event)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user