3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-30 16:09:27 +01:00
dbot/modules/user.js

86 lines
2.6 KiB
JavaScript
Raw Normal View History

var userCommands = function(dbot) {
var dbot = dbot;
var commands = {
'~kc': function(data, params) {
dbot.say('aisbot', '.karma ' + data.message.split(' ')[1]);
dbot.waitingForKarma = data.channel;
},
'~q': function(data, params) {
2011-08-26 13:42:44 +02:00
var q = data.message.valMatch(/^~q ([\d\w\s]*)/, 2)
if(q) {
dbot.say(data.channel, dbot.quotes.get(q[1].trim()));
}
},
'~qadd': function(data, params) {
2011-08-26 13:42:44 +02:00
var q = data.message.valMatch(/^~qadd ([\d\w\s]*)=(.+)$/, 3);
if(q) {
dbot.say(data.channel, dbot.quotes.add(q));
} else {
dbot.say(data.channel, 'Burn the invalid syntax!');
}
},
'~qset': function(data, params) {
2011-08-26 13:42:44 +02:00
var q = data.message.match(/^~qset ([\d\w\s]*)=(.+)$/, 3);
if(q) {
dbot.say(data.channel, dbot.quotes.set(q));
2011-08-26 13:42:44 +02:00
} else {
dbot.say(data.channel, 'Burn the invalid syntax!');
}
},
'~qcount': function(data, params) {
2011-08-26 13:42:44 +02:00
var q = data.message.valMatch(/^~qcount ([\d\w\s]*)/, 2);
if(q) {
dbot.say(data.channel, dbot.quotes.count(q[1].trim()));
}
},
'~reality': function(data, params) {
dbot.say(data.channel, dbot.db.realiPuns.random());
},
'~d': function(data, params) {
dbot.say(data.channel, data.user + ': ' + dbot.db.quoteArrs['depressionbot'].random());
},
'~rq': function(data, params) {
dbot.say(data.channel, dbot.quotes.random());
},
'~kickcount': function(data, params) {
if(!dbot.db.kicks.hasOwnProperty(params[1])) {
dbot.say(data.channel, params[1] + ' has either never been kicked or does not exist.');
} else {
dbot.say(data.channel, params[1] + ' has been kicked ' + dbot.db.kicks[params[1]] + ' times.');
}
}
};
return {
'listener': function(data) {
params = data.message.split(' ');
if(data.channel == dbot.name) data.channel = data.user;
if(commands.hasOwnProperty(params[0])) {
commands[params[0]](data, params);
2011-08-26 13:42:44 +02:00
dbot.save();
} else {
2011-08-26 13:42:44 +02:00
var q = data.message.valMatch(/^~([\d\w\s]*)/, 2)
if(q) {
dbot.say(data.channel, dbot.quotes.get(q[1].trim()));
}
}
},
'on': 'PRIVMSG'
};
};
exports.fetch = function(dbot) {
return userCommands(dbot);
};