Added ignore checkers to all ignorable modules with listeners, bit messy but eh.

This commit is contained in:
Luke Slater 2012-04-15 22:04:58 +01:00
parent 0062dde196
commit a600cb5da5
5 changed files with 82 additions and 61 deletions

View File

@ -1,10 +1,13 @@
var http = require('http'); var http = require('http');
var autoshorten = function(dbot) { var autoshorten = function(dbot) {
var name = 'autoshorten';
var dbot = dbot; var dbot = dbot;
return { return {
'listener': function(data) { 'listener': function(data) {
if((dbot.db.ignores.hasOwnProperty(data.user) &&
dbot.db.ignores[data.user].include(name)) == false) {
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var urlMatches = data.message.match(urlRegex); var urlMatches = data.message.match(urlRegex);
@ -25,11 +28,12 @@ var autoshorten = function(dbot) {
}); });
}); });
} }
}
}, },
'on': 'PRIVMSG', 'on': 'PRIVMSG',
'name': 'autoshorten', 'name': name,
'ignorable': true 'ignorable': true
}; };

View File

@ -1,8 +1,11 @@
var puns = function(dbot) { var puns = function(dbot) {
var names = 'puns';
var dbot = dbot; var dbot = dbot;
return { return {
'listener': function(data) { 'listener': function(data) {
if((dbot.db.ignores.hasOwnProperty(data.user) &&
dbot.db.ignores[data.user].include(name)) == false) {
if(dbot.moduleNames.include('quotes')) { if(dbot.moduleNames.include('quotes')) {
if(dbot.db.quoteArrs.hasOwnProperty(data.user.toLowerCase())) { if(dbot.db.quoteArrs.hasOwnProperty(data.user.toLowerCase())) {
data.message = '~q ' + data.user.toLowerCase(); data.message = '~q ' + data.user.toLowerCase();
@ -10,11 +13,12 @@ var puns = function(dbot) {
dbot.commands[params[0]](data, params); dbot.commands[params[0]](data, params);
} }
} }
}
}, },
'on': 'JOIN', 'on': 'JOIN',
'name': 'puns', 'name': name,
'ignorable': true 'ignorable': true
}; };

View File

@ -1,4 +1,5 @@
var quotes = function(dbot) { var quotes = function(dbot) {
var name = 'quotes';
var quotes = dbot.db.quoteArrs; var quotes = dbot.db.quoteArrs;
var addStack = []; var addStack = [];
var rmAllowed = true; var rmAllowed = true;
@ -276,6 +277,8 @@ var quotes = function(dbot) {
// For automatic quote retrieval // For automatic quote retrieval
'listener': function(data, params) { 'listener': function(data, params) {
if((dbot.db.ignores.hasOwnProperty(data.user) &&
dbot.db.ignores[data.user].include(name)) == false) {
if(data.user == 'reality') { if(data.user == 'reality') {
var once = data.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2); var once = data.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2);
} else { } else {
@ -297,11 +300,12 @@ var quotes = function(dbot) {
dbot.instance.say(data.channel, '\'reality ' + once[1] + '.\' saved.'); dbot.instance.say(data.channel, '\'reality ' + once[1] + '.\' saved.');
} }
} }
}
}, },
'on': 'PRIVMSG', 'on': 'PRIVMSG',
'name': 'quotes', 'name': name,
'ignorable': true 'ignorable': true
}; };

View File

@ -1,4 +1,5 @@
var spelling = function(dbot) { var spelling = function(dbot) {
var name = 'spelling';
var dbot = dbot; var dbot = dbot;
var last = {}; var last = {};
@ -38,6 +39,8 @@ var spelling = function(dbot) {
return { return {
'listener': function(data, params) { 'listener': function(data, params) {
if((dbot.db.ignores.hasOwnProperty(data.user) &&
dbot.db.ignores[data.user].include(name)) == false) {
var q = data.message.valMatch(/^(?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 3); var q = data.message.valMatch(/^(?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 3);
var otherQ = data.message.valMatch(/^([\d\w\s]*): (?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 4); var otherQ = data.message.valMatch(/^([\d\w\s]*): (?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 4);
if(q) { if(q) {
@ -56,11 +59,12 @@ var spelling = function(dbot) {
last[data.channel][data.user] = data.message; last[data.channel][data.user] = data.message;
} }
} }
}
}, },
'on': 'PRIVMSG', 'on': 'PRIVMSG',
'name': 'spelling', 'name': name,
'ignorable': true 'ignorable': true
} }

View File

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