From ae902e3c21f47c01a4253ed4128e3ab647e3a9ae Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 30 Dec 2012 18:53:20 +0000 Subject: [PATCH] Consolidate puns and quotes modules [#90] --- modules/puns/puns.js | 25 ------------------ modules/quotes/quotes.js | 55 ++++++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 50 deletions(-) delete mode 100644 modules/puns/puns.js diff --git a/modules/puns/puns.js b/modules/puns/puns.js deleted file mode 100644 index 187a652..0000000 --- a/modules/puns/puns.js +++ /dev/null @@ -1,25 +0,0 @@ -var puns = function(dbot) { - var name = 'puns'; - var dbot = dbot; - - return { - 'name': name, - 'ignorable': true, - - 'listener': function(event) { - event.user = dbot.cleanNick(event.user); - if(dbot.config.moduleNames.include('quotes') && - dbot.db.quoteArrs.hasOwnProperty(event.user)) { - event.message = '~q ' + event.user; - event.action = 'PRIVMSG'; - event.params = event.message.split(' '); - dbot.instance.emit(event); - } - }, - 'on': 'JOIN' - }; -} - -exports.fetch = function(dbot) { - return puns(dbot); -}; diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index 7ece49c..800fe72 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -265,38 +265,43 @@ var quotes = function(dbot) { 'commands': commands, 'listener': function(event) { - // Reality Once listener - if((dbot.db.ignores.hasOwnProperty(event) && - dbot.db.ignores[event.user].include(name)) == false) { - if(event.user == 'reality') { - var once = event.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2); - } else { - var once = event.message.valMatch(/^reality ([\d\w\s,'-]* once)/, 2); - } - - if(once) { - if((dbot.db.bans.hasOwnProperty('~qadd') && - dbot.db.bans['~qadd'].include(event.user)) || - dbot.db.bans['*'].include(event.user)) { - event.reply(dbot.t('command_ban', {'user': event.user})); + if(event.action == 'PRIVMSG') { + if((dbot.db.ignores.hasOwnProperty(event) && + dbot.db.ignores[event.user].include(name)) == false) { + if(event.user == 'reality') { + var once = event.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2); } else { - if(!dbot.db.quoteArrs.hasOwnProperty('realityonce')) { - dbot.db.quoteArrs['realityonce'] = []; - } - if(dbot.db.quoteArrs['realityonce'].include('reality ' + once[1] + '.')) { - event.reply(event.user + ': reality has already done that once.'); + var once = event.message.valMatch(/^reality ([\d\w\s,'-]* once)/, 2); + } + + if(once) { + if((dbot.db.bans.hasOwnProperty('~qadd') && + dbot.db.bans['~qadd'].include(event.user)) || + dbot.db.bans['*'].include(event.user)) { + event.reply(dbot.t('command_ban', {'user': event.user})); } else { - dbot.db.quoteArrs['realityonce'].push('reality ' + once[1] + '.'); - addStack.push('realityonce'); - rmAllowed = true; - event.reply('\'reality ' + once[1] + '.\' saved.'); + if(!dbot.db.quoteArrs.hasOwnProperty('realityonce')) { + dbot.db.quoteArrs['realityonce'] = []; + } + if(dbot.db.quoteArrs['realityonce'].include('reality ' + once[1] + '.')) { + event.reply(event.user + ': reality has already done that once.'); + } else { + dbot.db.quoteArrs['realityonce'].push('reality ' + once[1] + '.'); + addStack.push('realityonce'); + rmAllowed = true; + event.reply('\'reality ' + once[1] + '.\' saved.'); + } } } } + } else if(event.action == 'JOIN') { + event.message = '~q ' + event.user; + event.action = 'PRIVMSG'; + event.params = event.message.split(' '); + dbot.instance.emit(event); } }, - - 'on': 'PRIVMSG' + 'on': ['PRIVMSG', 'JOIN'] }; };