From ee06dc634bf8cf6e03a91b3419a5547e5ec7678e Mon Sep 17 00:00:00 2001 From: Matt Molyneaux Date: Thu, 11 Apr 2013 20:25:18 +0100 Subject: [PATCH 1/9] I warned you about porn bro, I told you dog! I told you man I TOLD you about porn! --- modules/imgur/imgur.js | 2 +- modules/imgur/strings.json | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 modules/imgur/strings.json diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index 3db7f1c..88bb35b 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -31,7 +31,7 @@ var imgur = function(dbot) { this.commands = { '~ri': function(event) { this.api.getRandomImage(function(link) { - event.reply(event.user + ': ' + link); + event.reply(event.user + ' (' + dbot.t('nsfw') + '): ' + link); }); } } diff --git a/modules/imgur/strings.json b/modules/imgur/strings.json new file mode 100644 index 0000000..2d30288 --- /dev/null +++ b/modules/imgur/strings.json @@ -0,0 +1,6 @@ +{ + "nsfw": { + "en": "might be NSFW", + "na'vi": "kxawm ke wivìntxu evengur" + } +} From 3d918414b80c7bcb94faf860dffc307a3fd6faa1 Mon Sep 17 00:00:00 2001 From: Matt Molyneaux Date: Thu, 11 Apr 2013 20:33:33 +0100 Subject: [PATCH 2/9] Put the colon next to the name, moron --- modules/imgur/imgur.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index 88bb35b..2bc6512 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -31,7 +31,7 @@ var imgur = function(dbot) { this.commands = { '~ri': function(event) { this.api.getRandomImage(function(link) { - event.reply(event.user + ' (' + dbot.t('nsfw') + '): ' + link); + event.reply(event.user + ': (' + dbot.t('nsfw') + ') ' + link); }); } } From 68cdf34cc384bcebc07aac69924435308c661a97 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Thu, 11 Apr 2013 23:57:42 +0200 Subject: [PATCH 3/9] Added multiple colors. --- modules/flashy/flashy.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index 3122dcb..7c553c4 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -12,8 +12,14 @@ var flashy = function(dbot) { 'green': '00FF00', 'blue': '0000FF', 'yellow': 'FFFF00', + 'pink': 'FFC0CB', 'magenta': 'FF00FF', - 'cyan': '00FFFF' + 'purple': 'AA00FF', + 'cyan': '00FFFF', + 'orange': 'FFAA00', + 'lime': 'AAFF00', + 'grey': 'AAAAAA', + 'infrared': '000000' }; this.commands = { From 74328ada86b9505e48fe52c7aec1e2ae36fd87cf Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 12 Apr 2013 18:25:08 +0000 Subject: [PATCH 4/9] bump jsbot for changed needed for [#348] --- jsbot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsbot b/jsbot index 84a4783..2be1731 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit 84a4783db76bdd729bd720c43485893ebe78a8c9 +Subproject commit 2be1731911bf2a207b963ac79656f626e09eac6f From 3a33c2be04ac89524b270b20c28f675901ec035d Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 12 Apr 2013 18:31:02 +0000 Subject: [PATCH 5/9] option to notify voiced users with ~report [Close #348] --- modules/report/config.json | 1 + modules/report/report.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/report/config.json b/modules/report/config.json index 424160e..c495082 100644 --- a/modules/report/config.json +++ b/modules/report/config.json @@ -1,5 +1,6 @@ { "ignorable": true, + "notifyVoice": false, "dependencies": [ "command", "users" ], "help": "http://github.com/reality/depressionbot/blob/master/modules/report/README.md" } diff --git a/modules/report/report.js b/modules/report/report.js index 2e9bbe9..89910ba 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -12,8 +12,12 @@ var report = function(dbot) { if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) { var nick = dbot.api.users.resolveUser(event.server, nick, true); var ops = _.filter(channel.nicks, function(user) { - return user.op; - }); + if(this.config.notifyVoice) { + return user.op || user.voice; + } else { + return user.op; + } + }, this); _.each(ops, function(user) { dbot.say(event.server, user.name, dbot.t('report', { From e667d95ca825474e817c44ebc83bcb2e67cacc0e Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 12 Apr 2013 18:33:49 +0000 Subject: [PATCH 6/9] Return correct head info is related result term is given by UD [Close #341] --- modules/link/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/link/link.js b/modules/link/link.js index 12adf09..6cfcd9b 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -84,7 +84,7 @@ var link = function(dbot) { try { var result = JSON.parse(body); if(_.has(result, 'result_type') && result.result_type != 'no_results') { - event.reply(query + ': ' + result.list[0].definition.split('\n')[0]); + event.reply(result.list[0].word + ': ' + result.list[0].definition.split('\n')[0]); } else { event.reply(event.user + ': No definition found.'); } From 5d30261770c753dc37fa20b01079383323c2fe11 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 12 Apr 2013 19:03:01 +0000 Subject: [PATCH 7/9] Create addHandler API for link module and have dent use it. Removed its own listener. [#344] --- modules/dent/dent.js | 19 ++++++------------- modules/link/link.js | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/modules/dent/dent.js b/modules/dent/dent.js index fcbb8a4..6071932 100644 --- a/modules/dent/dent.js +++ b/modules/dent/dent.js @@ -64,20 +64,13 @@ var dent = function(dbot) { } }.bind(this)); } - }.bind(this); - - this.listener = function(event) { - for (s in this.StatusRegex) { - if (this.StatusRegex.hasOwnProperty(s)) { - var matches = this.StatusRegex[s].exec(event.message); - if (matches != null) { - this.lookup(event, matches[1], s); - } - } - } - }.bind(this); - this.on = 'PRIVMSG'; + for(s in this.StatusRegex) { + dbot.api.link.addHandler(this.StatusRegex[s], function(event, matches) { + this.lookup(event, matches[1], s); + }.bind(this)); + } + }.bind(this); }; exports.fetch = function(dbot) { diff --git a/modules/link/link.js b/modules/link/link.js index 6cfcd9b..3657a38 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -10,6 +10,7 @@ var request = require('request'), var link = function(dbot) { this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; this.links = {}; + this.handlers = []; this.fetchTitle = function(event, link) { var limit = 1000000, size = 0, @@ -30,6 +31,12 @@ var link = function(dbot) { } }); }; + + this.api = { + 'addHandler': function(regex, handler) { + this.handlers.push({ 'regex': regex, 'callback': handler }); + } + }; var commands = { '~title': function(event) { @@ -100,7 +107,15 @@ var link = function(dbot) { if(urlMatches !== null) { this.links[event.channel.name] = urlMatches[0]; if(dbot.config.link.autoTitle == true) { - this.fetchTitle(event, urlMatches[0]); + var handlerFound = false; + for(var i=0;i Date: Fri, 12 Apr 2013 19:11:55 +0000 Subject: [PATCH 8/9] Fix for the Identica bit by allowing a name argument to be passed [#344] --- modules/dent/dent.js | 4 ++-- modules/link/link.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/dent/dent.js b/modules/dent/dent.js index 6071932..a990984 100644 --- a/modules/dent/dent.js +++ b/modules/dent/dent.js @@ -66,8 +66,8 @@ var dent = function(dbot) { } for(s in this.StatusRegex) { - dbot.api.link.addHandler(this.StatusRegex[s], function(event, matches) { - this.lookup(event, matches[1], s); + dbot.api.link.addHandler(s, this.StatusRegex[s], function(event, matches, name) { + this.lookup(event, matches[1], name); }.bind(this)); } }.bind(this); diff --git a/modules/link/link.js b/modules/link/link.js index 3657a38..e145538 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -33,8 +33,12 @@ var link = function(dbot) { }; this.api = { - 'addHandler': function(regex, handler) { - this.handlers.push({ 'regex': regex, 'callback': handler }); + 'addHandler': function(name, regex, handler) { + this.handlers.push({ + 'name': name, + 'regex': regex, + 'callback': handler + }); } }; @@ -111,7 +115,7 @@ var link = function(dbot) { for(var i=0;i Date: Fri, 12 Apr 2013 19:17:22 +0000 Subject: [PATCH 9/9] spotify module uses addHandler [#344] also spaceinvader sort your bloody indentation out --- modules/spotify/spotify.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/spotify/spotify.js b/modules/spotify/spotify.js index e10203d..f309e9f 100644 --- a/modules/spotify/spotify.js +++ b/modules/spotify/spotify.js @@ -58,14 +58,13 @@ var spotify = function(dbot) { } }; commands['~spotify'].regex = [/^~spotify (.*)/, 2]; - this.listener = function(event) { - var spotifyMatches = event.message.match(this.spotifyRegex); - if (spotifyMatches != null) { - this.lookup(event, spotifyMatches[0]); - } - }.bind(this); - this.on = 'PRIVMSG'; this.commands = commands; + + this.onLoad = function() { + dbot.api.link.addHandler(this.name, this.spotifyRegex, function(event, matches, name) { + this.lookup(event, matches[0]); + }.bind(this)); + }.bind(this); }; exports.fetch = function(dbot) {