3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 03:33:07 +01:00

Consolidate puns and quotes modules [#90]

This commit is contained in:
reality 2012-12-30 18:53:20 +00:00
parent 887e854012
commit ae902e3c21
2 changed files with 30 additions and 50 deletions

View File

@ -1,25 +0,0 @@
var puns = function(dbot) {
var name = 'puns';
var dbot = dbot;
return {
'name': name,
'ignorable': true,
'listener': function(event) {
event.user = dbot.cleanNick(event.user);
if(dbot.config.moduleNames.include('quotes') &&
dbot.db.quoteArrs.hasOwnProperty(event.user)) {
event.message = '~q ' + event.user;
event.action = 'PRIVMSG';
event.params = event.message.split(' ');
dbot.instance.emit(event);
}
},
'on': 'JOIN'
};
}
exports.fetch = function(dbot) {
return puns(dbot);
};

View File

@ -265,38 +265,43 @@ var quotes = function(dbot) {
'commands': commands,
'listener': function(event) {
// Reality Once listener
if((dbot.db.ignores.hasOwnProperty(event) &&
dbot.db.ignores[event.user].include(name)) == false) {
if(event.user == 'reality') {
var once = event.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2);
} else {
var once = event.message.valMatch(/^reality ([\d\w\s,'-]* once)/, 2);
}
if(once) {
if((dbot.db.bans.hasOwnProperty('~qadd') &&
dbot.db.bans['~qadd'].include(event.user)) ||
dbot.db.bans['*'].include(event.user)) {
event.reply(dbot.t('command_ban', {'user': event.user}));
if(event.action == 'PRIVMSG') {
if((dbot.db.ignores.hasOwnProperty(event) &&
dbot.db.ignores[event.user].include(name)) == false) {
if(event.user == 'reality') {
var once = event.message.valMatch(/^I ([\d\w\s,'-]* once)/, 2);
} else {
if(!dbot.db.quoteArrs.hasOwnProperty('realityonce')) {
dbot.db.quoteArrs['realityonce'] = [];
}
if(dbot.db.quoteArrs['realityonce'].include('reality ' + once[1] + '.')) {
event.reply(event.user + ': reality has already done that once.');
var once = event.message.valMatch(/^reality ([\d\w\s,'-]* once)/, 2);
}
if(once) {
if((dbot.db.bans.hasOwnProperty('~qadd') &&
dbot.db.bans['~qadd'].include(event.user)) ||
dbot.db.bans['*'].include(event.user)) {
event.reply(dbot.t('command_ban', {'user': event.user}));
} else {
dbot.db.quoteArrs['realityonce'].push('reality ' + once[1] + '.');
addStack.push('realityonce');
rmAllowed = true;
event.reply('\'reality ' + once[1] + '.\' saved.');
if(!dbot.db.quoteArrs.hasOwnProperty('realityonce')) {
dbot.db.quoteArrs['realityonce'] = [];
}
if(dbot.db.quoteArrs['realityonce'].include('reality ' + once[1] + '.')) {
event.reply(event.user + ': reality has already done that once.');
} else {
dbot.db.quoteArrs['realityonce'].push('reality ' + once[1] + '.');
addStack.push('realityonce');
rmAllowed = true;
event.reply('\'reality ' + once[1] + '.\' saved.');
}
}
}
}
} else if(event.action == 'JOIN') {
event.message = '~q ' + event.user;
event.action = 'PRIVMSG';
event.params = event.message.split(' ');
dbot.instance.emit(event);
}
},
'on': 'PRIVMSG'
'on': ['PRIVMSG', 'JOIN']
};
};