forked from GitHub/dbot
Merge git://github.com/reality/depressionbot into database
This commit is contained in:
commit
36254c9e03
@ -64,20 +64,13 @@ var dent = function(dbot) {
|
|||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
}.bind(this);
|
|
||||||
|
|
||||||
this.listener = function(event) {
|
for(s in this.StatusRegex) {
|
||||||
for (s in this.StatusRegex) {
|
dbot.api.link.addHandler(s, this.StatusRegex[s], function(event, matches, name) {
|
||||||
if (this.StatusRegex.hasOwnProperty(s)) {
|
this.lookup(event, matches[1], name);
|
||||||
var matches = this.StatusRegex[s].exec(event.message);
|
}.bind(this));
|
||||||
if (matches != null) {
|
|
||||||
this.lookup(event, matches[1], s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.on = 'PRIVMSG';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.fetch = function(dbot) {
|
exports.fetch = function(dbot) {
|
||||||
|
@ -12,8 +12,14 @@ var flashy = function(dbot) {
|
|||||||
'green': '00FF00',
|
'green': '00FF00',
|
||||||
'blue': '0000FF',
|
'blue': '0000FF',
|
||||||
'yellow': 'FFFF00',
|
'yellow': 'FFFF00',
|
||||||
|
'pink': 'FFC0CB',
|
||||||
'magenta': 'FF00FF',
|
'magenta': 'FF00FF',
|
||||||
'cyan': '00FFFF'
|
'purple': 'AA00FF',
|
||||||
|
'cyan': '00FFFF',
|
||||||
|
'orange': 'FFAA00',
|
||||||
|
'lime': 'AAFF00',
|
||||||
|
'grey': 'AAAAAA',
|
||||||
|
'infrared': '000000'
|
||||||
};
|
};
|
||||||
|
|
||||||
this.commands = {
|
this.commands = {
|
||||||
|
@ -31,7 +31,7 @@ var imgur = function(dbot) {
|
|||||||
this.commands = {
|
this.commands = {
|
||||||
'~ri': function(event) {
|
'~ri': function(event) {
|
||||||
this.api.getRandomImage(function(link) {
|
this.api.getRandomImage(function(link) {
|
||||||
event.reply(event.user + ': ' + link);
|
event.reply(event.user + ': (' + dbot.t('nsfw') + ') ' + link);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
modules/imgur/strings.json
Normal file
6
modules/imgur/strings.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"nsfw": {
|
||||||
|
"en": "might be NSFW",
|
||||||
|
"na'vi": "kxawm ke wivìntxu evengur"
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ var request = require('request'),
|
|||||||
var link = function(dbot) {
|
var link = function(dbot) {
|
||||||
this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
||||||
this.links = {};
|
this.links = {};
|
||||||
|
this.handlers = [];
|
||||||
this.fetchTitle = function(event, link) {
|
this.fetchTitle = function(event, link) {
|
||||||
var limit = 1000000,
|
var limit = 1000000,
|
||||||
size = 0,
|
size = 0,
|
||||||
@ -31,6 +32,16 @@ var link = function(dbot) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'addHandler': function(name, regex, handler) {
|
||||||
|
this.handlers.push({
|
||||||
|
'name': name,
|
||||||
|
'regex': regex,
|
||||||
|
'callback': handler
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var commands = {
|
var commands = {
|
||||||
'~title': function(event) {
|
'~title': function(event) {
|
||||||
var link = this.links[event.channel.name];
|
var link = this.links[event.channel.name];
|
||||||
@ -84,7 +95,7 @@ var link = function(dbot) {
|
|||||||
try {
|
try {
|
||||||
var result = JSON.parse(body);
|
var result = JSON.parse(body);
|
||||||
if(_.has(result, 'result_type') && result.result_type != 'no_results') {
|
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 {
|
} else {
|
||||||
event.reply(event.user + ': No definition found.');
|
event.reply(event.user + ': No definition found.');
|
||||||
}
|
}
|
||||||
@ -100,7 +111,15 @@ var link = function(dbot) {
|
|||||||
if(urlMatches !== null) {
|
if(urlMatches !== null) {
|
||||||
this.links[event.channel.name] = urlMatches[0];
|
this.links[event.channel.name] = urlMatches[0];
|
||||||
if(dbot.config.link.autoTitle == true) {
|
if(dbot.config.link.autoTitle == true) {
|
||||||
this.fetchTitle(event, urlMatches[0]);
|
var handlerFound = false;
|
||||||
|
for(var i=0;i<this.handlers.length;i++) {
|
||||||
|
var matches = this.handlers[i].regex.exec(urlMatches[0]);
|
||||||
|
if(matches) {
|
||||||
|
this.handlers[i].callback(event, matches, this.handlers[i].name);
|
||||||
|
handlerFound = true; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!handlerFound) this.fetchTitle(event, urlMatches[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ignorable": true,
|
"ignorable": true,
|
||||||
|
"notifyVoice": false,
|
||||||
"dependencies": [ "command", "users" ],
|
"dependencies": [ "command", "users" ],
|
||||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/report/README.md"
|
"help": "http://github.com/reality/depressionbot/blob/master/modules/report/README.md"
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,12 @@ var report = function(dbot) {
|
|||||||
if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) {
|
if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) {
|
||||||
var nick = dbot.api.users.resolveUser(event.server, nick, true);
|
var nick = dbot.api.users.resolveUser(event.server, nick, true);
|
||||||
var ops = _.filter(channel.nicks, function(user) {
|
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) {
|
_.each(ops, function(user) {
|
||||||
dbot.say(event.server, user.name, dbot.t('report', {
|
dbot.say(event.server, user.name, dbot.t('report', {
|
||||||
|
@ -58,14 +58,13 @@ var spotify = function(dbot) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
commands['~spotify'].regex = [/^~spotify (.*)/, 2];
|
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.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) {
|
exports.fetch = function(dbot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user