From 4d50f1eff2a5c931153fe6679d611a6a94a7ae40 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 24 Mar 2015 19:17:54 +0000 Subject: [PATCH] random should response whatsit --- modules/words/words.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/words/words.js b/modules/words/words.js index 5a3c3b1..eb03f0d 100644 --- a/modules/words/words.js +++ b/modules/words/words.js @@ -111,6 +111,26 @@ var words = function(dbot) { }; this.commands['~jimble'].regex = [/^jimble (.+)$/, 2]; + this.listener = function(event) { + var matchOne = event.message.match(new RegExp(dbot.config.name + + ': should (\w+) (.+) or (.*)\?', 'i')); + if(matchOne) { + var pre = match[1]; + if(pre == 'i' || pre == 'I') { + pre = 'You'; + } + + if(Math.floor(Math.random() * (26)) == 1) { + dbot.api.quotes.getQuote('should_responses', function(q) { + event.reply(pre + ' should ' + q); + }); + } else { + event.reply(pre + ' should ' + match[_.random(2, 3)].replace(/,/,'').replace(/should/,'')); + } + } + }; + this.on = 'PRIVMSG'; + this.onLoad = function() { this.wn = new Wordnik({ 'api_key': this.config.api_key