From 23bd69192706675df2b4275e57dfd1ab2a4fb9b6 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Mon, 5 Mar 2012 18:17:15 +0000 Subject: [PATCH 1/3] test --- modules/drama.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/drama.js b/modules/drama.js index 2e2e6f7..2334a6d 100644 --- a/modules/drama.js +++ b/modules/drama.js @@ -60,6 +60,9 @@ var drama = function(dbot) { 'listener': function(data) { var category = bayes.classify(data.message, function(category) { console.log(category + '!'); + if(category === 'beinganasshole') { + dbot.say(data.channel, data.user + ': Quit being an asshole') + } }.bind(this)); if(last.hasOwnProperty(data.channel)) { From dfb17dc107a86f8015bb14a660102028dc255469 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Tue, 6 Mar 2012 14:44:38 +0000 Subject: [PATCH 2/3] change spelling correction order in command ~ --- run.js | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/run.js b/run.js index fc29667..022d4bf 100644 --- a/run.js +++ b/run.js @@ -114,30 +114,28 @@ DBot.prototype.reloadModules = function() { } else { var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2); if(q) { - // See if it's similar to anything - var winnerDistance = Infinity; - var winner = false; - for(var commandName in this.commands) { - var distance = String.prototype.distance(params[0], commandName); - if(distance < winnerDistance) { - winner = commandName; - winnerDistance = distance; - } - } - - if(winnerDistance < 3) { - this.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!'); - } else { // See if there's anything in quotes - if(this.db.bans['*'].include(data.user)) { - this.say(data.channel, data.user + - ' is banned from using this command. Commence incineration.'); + if(this.db.bans['*'].include(data.user)) { + this.say(data.channel, data.user + + ' is banned from using this command. Commence incineration.'); + } else { + q[1] = q[1].trim(); + key = this.cleanNick(q[1]) + if(this.db.quoteArrs.hasOwnProperty(key)) { + this.say(data.channel, q[1] + ': ' + this.db.quoteArrs[key].random()); } else { - q[1] = q[1].trim(); - key = this.cleanNick(q[1]) - if(this.db.quoteArrs.hasOwnProperty(key)) { - this.say(data.channel, q[1] + ': ' + this.db.quoteArrs[key].random()); - } else { - this.say(data.channel, 'Nobody loves ' + q[1]); + // See if it's similar to anything + var winnerDistance = Infinity; + var winner = false; + for(var commandName in this.commands) { + var distance = String.prototype.distance(params[0], commandName); + if(distance < winnerDistance) { + winner = commandName; + winnerDistance = distance; + } + } + + if(winnerDistance < 3) { + this.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!'); } } } From 514af801d21ba6ffc7147923ec9b4159c4f28bba Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Tue, 6 Mar 2012 19:55:35 +0000 Subject: [PATCH 3/3] drama stats recorded per user --- modules/drama.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/drama.js b/modules/drama.js index 2334a6d..c7d3daa 100644 --- a/modules/drama.js +++ b/modules/drama.js @@ -59,9 +59,20 @@ var drama = function(dbot) { 'listener': function(data) { var category = bayes.classify(data.message, function(category) { - console.log(category + '!'); - if(category === 'beinganasshole') { - dbot.say(data.channel, data.user + ': Quit being an asshole') + if(category !== 'normal') { + if(category === 'beinganasshole') { + if(dbot.db.drama.beinganasshole.hasOwnProperty(data.user)) { + dbot.db.drama.beinganasshole[data.user]++; + } else { + dbot.db.drama.beinganasshole[data.user] = 1; + } + } else if(category === 'sd') { + if(dbot.db.drama.sd.hasOwnProperty(data.user)) { + dbot.db.drama.sd[data.user]++; + } else { + dbot.db.drama.sd[data.user] = 1; + } + } } }.bind(this));