From 617ce3ca12806eee73abce9322c9980d30b1abf9 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Thu, 6 Oct 2011 13:14:56 +0100 Subject: [PATCH] Merge quotes and reality --- modules/quotes.js | 20 +++++++++++++++++++- modules/reality.js | 26 -------------------------- run.js | 2 +- 3 files changed, 20 insertions(+), 28 deletions(-) delete mode 100644 modules/reality.js diff --git a/modules/quotes.js b/modules/quotes.js index c7f0730..5834ed5 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -105,7 +105,25 @@ var quotes = function(dbot) { rmAllowed = true; }); return commands; - } + }, + + // For automatic quote retrieval + 'listener': function(data, params) { + if(data.user == 'reality') { + var once = data.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2); + } else { + var once = data.message.valMatch(/^reality ([\d\w\s,'-]* once)/, 2); + } + + if(once) { + dbot.db.quoteArrs['realityonce'].push('reality ' + once[1] + '.'); + dbot.instance.say(data.channel, '\'reality ' + once[1] + '.\' saved.'); + dbot.save(); + } + }, + + 'on': 'PRIVMSG' + }; }; diff --git a/modules/reality.js b/modules/reality.js deleted file mode 100644 index efff097..0000000 --- a/modules/reality.js +++ /dev/null @@ -1,26 +0,0 @@ -var reality = function(dbot) { - var dbot = dbot; - - return { - 'listener': function(data, params) { - // Ternary for I/reality doesn't seem to work with the regex. Investigate. - if(data.user == 'reality') { - var once = data.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2); - } else { - var once = data.message.valMatch(/^reality ([\d\w\s,'-]* once)/, 2); - } - - if(once) { - dbot.db.quoteArrs['realityonce'].push('reality ' + once[1] + '.'); - dbot.instance.say(data.channel, '\'reality ' + once[1] + '.\' saved.'); - dbot.save(); - } - }, - - 'on': 'PRIVMSG' - }; -} - -exports.fetch = function(dbot) { - return reality(dbot); -} diff --git a/run.js b/run.js index da933da..09aed44 100644 --- a/run.js +++ b/run.js @@ -3,7 +3,7 @@ var timers = require('./timer'); var jsbot = require('./jsbot'); require('./snippets'); -var modules = ['user', 'web', 'admin', 'puns', 'kick', 'reality', 'karma', 'youare', 'quotes']; +var modules = ['user', 'web', 'admin', 'puns', 'kick', 'karma', 'youare', 'quotes']; var DBot = function(dModules, timers) { this.admin = 'reality';