diff --git a/modules/command.js b/modules/command.js index 1da6b65..300fedc 100644 --- a/modules/command.js +++ b/modules/command.js @@ -1,122 +1,58 @@ -// Module which handles the command execution syntax for DBot. Not much is going -// to work without this. +/** + * Module Name: Command + * Description: An essential module which maps PRIVMSG input to an appropriate + * command and then runs that command, given the user isn't banned from or + * ignoring that command. + */ var command = function(dbot) { var dbot = dbot; + /** + * Is user banned from using command? + */ + var is_banned = function(user, command) { + var banned = false; + if(dbot.db.bans.hasOwnProperty(command)) { + if(dbot.db.bans[command].include(user) || dbot.db.bans['*'].include(user)) { + banned = true; + } + } + return banned; + } + + /** + * Is user ignoring command? + */ + var is_ignoring = function(user, command) { + var module = dbot.commandMap[command]; + var ignoring = false; + if(dbot.db.ignores.hasOwnProperty(user) && dbot.db.ignores[user].include(module)) { + ignoring = true; + } + return ignoring; + } + return { - 'onLoad': function() { - return { - '~ignore': function(data, params) { - var ignorableModules = []; - for(var i=0;i