2012-04-19 13:01:06 +02:00
|
|
|
// Find which badwords are currently enacted in the current channel
|
|
|
|
var badwords = function(dbot) {
|
|
|
|
var name = 'badwords';
|
|
|
|
var dbot = dbot;
|
|
|
|
var badWordLock = false;
|
|
|
|
|
|
|
|
var commands = {
|
|
|
|
'~badwords': function(data, params) {
|
|
|
|
if(badWordLock == true) {
|
|
|
|
dbot.say('reality', 'Another badwords query is in action. Try again in a few seconds.');
|
|
|
|
} else {
|
|
|
|
data.channel = '#42';
|
|
|
|
badWordLock = true;
|
|
|
|
|
2012-04-19 13:20:57 +02:00
|
|
|
dbot.sessionData.badwords.finished = false;
|
2012-04-19 13:01:06 +02:00
|
|
|
|
|
|
|
dbot.say('bots', 'badwords ' + data.channel + ' list');
|
|
|
|
dbot.instance.addListener('PRIVMSG', function(data) {
|
|
|
|
if(data.channel === 'bots') {
|
|
|
|
if(data.message.indexOf('bad words list is empty') != -1) {
|
2012-04-19 13:20:57 +02:00
|
|
|
dbot.sessionData.badwords.count = 0;
|
|
|
|
dbot.sessionData.badwords.finished = true;
|
2012-04-19 13:01:06 +02:00
|
|
|
} else {
|
|
|
|
var wordMatch = data.message.valMatch(/\w([1-10])\w(.*)/, 2);
|
|
|
|
dbot.say('reality', wordMatch[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-04-19 13:20:57 +02:00
|
|
|
dbot.sessionData.badwords = {};
|
2012-04-19 13:01:06 +02:00
|
|
|
badWordLock = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
2012-04-19 13:19:09 +02:00
|
|
|
'onLoad': function() {
|
2012-04-19 13:22:04 +02:00
|
|
|
if(!dbot.sessionData.hasOwnProperty('badwords')) {
|
2012-04-19 13:20:57 +02:00
|
|
|
dbot.sessionData.badwords = {};
|
2012-04-19 13:01:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return commands;
|
|
|
|
},
|
|
|
|
|
|
|
|
'name': name,
|
|
|
|
|
|
|
|
'ignorable': true
|
|
|
|
};
|
2012-04-19 13:14:08 +02:00
|
|
|
};
|
2012-04-19 13:01:06 +02:00
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
2012-04-19 13:02:27 +02:00
|
|
|
return badwords(dbot);
|
2012-04-19 13:01:06 +02:00
|
|
|
};
|