From 1f02e29a8594293a2afb96acad5c10e093b2a8e5 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Sat, 19 May 2012 19:14:07 +0100 Subject: [PATCH] Made DBot load listeners in The New Way. Massively simplified Command module, converted to new format. Converted JS module to new format. All working. Moved ~ignore functionality away for now as it needs to be combined with jsbot. --- modules/command.js | 150 +++++++++++++-------------------------------- modules/js.js | 13 ++-- modules/quotes.js | 13 ++++ run.js | 2 +- 4 files changed, 64 insertions(+), 114 deletions(-) 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