Use jsbot ignore instead of having it build into the modules

This commit is contained in:
Luke Slater 2012-05-25 16:45:47 +01:00
parent 4c72bd327c
commit 5677cad1fa
5 changed files with 41 additions and 54 deletions

View File

@ -11,28 +11,25 @@ var autoshorten = function(dbot) {
return { return {
'listener': function(event) { 'listener': function(event) {
if((dbot.db.ignores.hasOwnProperty(event.user) && var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
dbot.db.ignores[event.user].include(name)) == false) { var urlMatches = event.message.match(urlRegex);
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var urlMatches = event.message.match(urlRegex);
if(urlMatches !== null && urlMatches[0].length > 80) { if(urlMatches !== null && urlMatches[0].length > 80) {
var url = urlMatches[0]; // Only doing one, screw you. var url = urlMatches[0]; // Only doing one, screw you.
// TODO: Make this use a decent URL shortener. Mine is shit. // TODO: Make this use a decent URL shortener. Mine is shit.
var options = { var options = {
'host': 'nc.no.de', 'host': 'nc.no.de',
'port': 80, 'port': 80,
'path': '/mkurl?url=' + escape(url) 'path': '/mkurl?url=' + escape(url)
}; };
http.get(options, function(res) { http.get(options, function(res) {
res.setEncoding('utf8'); res.setEncoding('utf8');
res.on('data', function (response) { res.on('data', function (response) {
event.reply(dbot.t('shorten_link', {'user': event.user}) + JSON.parse(response).surl); event.reply(dbot.t('shorten_link', {'user': event.user}) + JSON.parse(response).surl);
});
}); });
} });
} }
}, },

View File

@ -5,16 +5,12 @@ var puns = function(dbot) {
return { return {
'listener': function(event) { 'listener': function(event) {
event.user = dbot.cleanNick(event.user); event.user = dbot.cleanNick(event.user);
if(dbot.moduleNames.include('quotes') &&
if((dbot.db.ignores.hasOwnProperty(event.user) && dbot.db.quoteArrs.hasOwnProperty(event.user)) {
dbot.db.ignores[event.user].include(name)) == false) { event.message = '~q ' + event.user;
if(dbot.moduleNames.include('quotes') && event.action = 'PRIVMSG';
dbot.db.quoteArrs.hasOwnProperty(event.user)) { event.params = event.message.split(' ');
event.message = '~q ' + event.user; dbot.instance.emit(event)
event.action = 'PRIVMSG';
event.params = event.message.split(' ');
dbot.instance.emit(event)
}
} }
}, },

View File

@ -39,25 +39,22 @@ var spelling = function(dbot) {
return { return {
'listener': function(event) { 'listener': function(event) {
if((dbot.db.ignores.hasOwnProperty(event.user) && var q = event.message.valMatch(/^(?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 3);
dbot.db.ignores[event.user].include(name)) == false) { var otherQ = event.message.valMatch(/^([\d\w\s]*): (?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 4);
var q = event.message.valMatch(/^(?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 3); if(q) {
var otherQ = event.message.valMatch(/^([\d\w\s]*): (?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 4); correct(event, q[1] || q[2], event.user, function (e) {
if(q) { event.reply(dbot.t('spelling_self', e));
correct(event, q[1] || q[2], event.user, function (e) { });
event.reply(dbot.t('spelling_self', e)); } else if(otherQ) {
}); correct(event, otherQ[2] || otherQ[3], otherQ[1], function (e) {
} else if(otherQ) { event.reply(dbot.t('spelling_other', e));
correct(event, otherQ[2] || otherQ[3], otherQ[1], function (e) { });
event.reply(dbot.t('spelling_other', e)); } else {
}); if(last.hasOwnProperty(event.channel)) {
last[event.channel][event.user] = event.message;
} else { } else {
if(last.hasOwnProperty(event.channel)) { last[event.channel] = { };
last[event.channel][event.user] = event.message; last[event.channel][event.user] = event.message;
} else {
last[event.channel] = { };
last[event.channel][event.user] = event.message;
}
} }
} }
}, },

View File

@ -3,13 +3,10 @@ var youAre = function(dbot) {
return { return {
'listener': function(event) { 'listener': function(event) {
if((dbot.db.ignores.hasOwnProperty(event.user) && var key = event.message.valMatch(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/, 5);
dbot.db.ignores[event.user].include(name)) == false) {
var key = event.message.valMatch(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/, 5);
if(key && key[2] != "" && Number.prototype.chanceIn(1, 100) && event.user != 'aisbot') { if(key && key[2] != "" && Number.prototype.chanceIn(1, 100) && event.user != 'aisbot') {
event.reply(event.user + ': You\'re ' + key[2] + '.'); event.reply(event.user + ': You\'re ' + key[2] + '.');
}
} }
}, },

2
run.js
View File

@ -53,7 +53,7 @@ var DBot = function(timers) {
// Populate bot properties with config data // Populate bot properties with config data
this.name = this.config.name || 'dbox'; this.name = this.config.name || 'dbox';
this.admin = this.config.admin || [ 'reality' ]; this.admin = this.config.admin || [ 'reality' ];
this.moduleNames = this.config.modules || [ 'admin', 'command', 'dice', 'js', 'kick', 'puns', 'quotes', 'spelling', 'youare' ]; this.moduleNames = this.config.modules || [ 'ignore', 'admin', 'command', 'dice', 'js', 'kick', 'puns', 'quotes', 'spelling', 'youare' ];
this.language = this.config.language || 'english'; this.language = this.config.language || 'english';
// It's the user's responsibility to fill this data structure up properly in // It's the user's responsibility to fill this data structure up properly in