diff --git a/modules/dent/dent.js b/modules/dent/dent.js index fcbb8a4..a990984 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(s, this.StatusRegex[s], function(event, matches, name) { + this.lookup(event, matches[1], name); + }.bind(this)); + } + }.bind(this); }; exports.fetch = function(dbot) { 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 = { diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index 3db7f1c..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 + ': ' + 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" + } +} diff --git a/modules/link/link.js b/modules/link/link.js index 12adf09..e145538 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,16 @@ var link = function(dbot) { } }); }; + + this.api = { + 'addHandler': function(name, regex, handler) { + this.handlers.push({ + 'name': name, + 'regex': regex, + 'callback': handler + }); + } + }; var commands = { '~title': function(event) { @@ -84,7 +95,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.'); } @@ -100,7 +111,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