3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-18 08:32:42 +01:00

Converted drama kicks and puns to new format. Quite tired now.

This commit is contained in:
Luke Slater 2012-05-23 20:05:23 +01:00
parent 74369c5de6
commit 979399de46
3 changed files with 56 additions and 63 deletions

View File

@ -1,3 +1,7 @@
/**
* Module Name: Drama
* Description: Experimental, you probably don't want it.
*/
var brain = require('brain'); var brain = require('brain');
var drama = function(dbot) { var drama = function(dbot) {
@ -25,29 +29,29 @@ var drama = function(dbot) {
var bayes = new brain.BayesianClassifier(options); var bayes = new brain.BayesianClassifier(options);
var commands = { var commands = {
'~train': function(data, params) { '~train': function(event) {
if(dbot.admin.include(data.user)) { if(dbot.admin.include(event.user)) {
bayes.train(last[params[1]][params[2]], params[3]); bayes.train(last[event.params[1]][event.params[2]], event.params[3]);
dbot.say(data.channel, 'Last thing ' + params[2] + ' said in ' + event.reply('Last thing ' + event.params[2] + ' said in ' +
params[1] + ' (' + last[params[1]][params[2]] + ') classified as \'' + params[3] + '\''); event.params[1] + ' (' + last[event.params[1]][event.params[2]] + ') classified as \'' + event.params[3] + '\'');
} }
}, },
'~rtrain': function(data, params) { '~rtrain': function(event) {
if(dbot.admin.include(data.user)) { if(dbot.admin.include(event.user)) {
var category = params[1]; var category = event.params[1];
params.splice(0, 2); event.params.splice(0, 2);
var msg = params.join(' '); var msg = event.params.join(' ');
bayes.train(msg, category); bayes.train(msg, category);
dbot.say(data.channel, '\'' + msg + '\' classified as \'' + category + '\''); event.reply('\'' + msg + '\' classified as \'' + category + '\'');
} }
}, },
'~classify': function(data, params) { '~classify': function(event) {
params.splice(0, 1); event.params.splice(0, 1);
var msg = params.join(' '); var msg = event.params.join(' ');
bayes.classify(msg, function(category) { bayes.classify(msg, function(category) {
dbot.say(data.channel, 'Classified as: ' + category + '!'); event.reply('Classified as: ' + category + '!');
}.bind(this)); }.bind(this));
} }
} }
@ -61,26 +65,26 @@ var drama = function(dbot) {
var category = bayes.classify(data.message, function(category) { var category = bayes.classify(data.message, function(category) {
if(category !== 'normal') { if(category !== 'normal') {
if(category === 'beinganasshole') { if(category === 'beinganasshole') {
if(dbot.db.drama.beinganasshole.hasOwnProperty(data.user)) { if(dbot.db.drama.beinganasshole.hasOwnProperty(event.user)) {
dbot.db.drama.beinganasshole[data.user]++; dbot.db.drama.beinganasshole[event.user]++;
} else { } else {
dbot.db.drama.beinganasshole[data.user] = 1; dbot.db.drama.beinganasshole[event.user] = 1;
} }
} else if(category === 'sd') { } else if(category === 'sd') {
if(dbot.db.drama.sd.hasOwnProperty(data.user)) { if(dbot.db.drama.sd.hasOwnProperty(event.user)) {
dbot.db.drama.sd[data.user]++; dbot.db.drama.sd[event.user]++;
} else { } else {
dbot.db.drama.sd[data.user] = 1; dbot.db.drama.sd[event.user] = 1;
} }
} }
} }
}.bind(this)); }.bind(this));
if(last.hasOwnProperty(data.channel)) { if(last.hasOwnProperty(event.channel)) {
last[data.channel][data.user] = data.message; last[event.channel][event.user] = data.message;
} else { } else {
last[data.channel] = { }; last[event.channel] = { };
last[data.channel][data.user] = data.message; last[event.channel][event.user] = data.message;
} }
}, },

View File

@ -4,25 +4,27 @@ var kick = function(dbot) {
var commands = { var commands = {
// Give the number of times a given user has been kicked and has kicked // Give the number of times a given user has been kicked and has kicked
// other people. // other people.
'~kickcount': function(data, params) { '~kickcount': function(event) {
if(!dbot.db.kicks.hasOwnProperty(params[1])) { var username = event.params[1];
if(!dbot.db.kicks.hasOwnProperty(username)) {
var kicks = '0'; var kicks = '0';
} else { } else {
var kicks = dbot.db.kicks[params[1]]; var kicks = dbot.db.kicks[username];
} }
if(!dbot.db.kickers.hasOwnProperty(params[1])) { if(!dbot.db.kickers.hasOwnProperty(username)) {
var kicked = '0'; var kicked = '0';
} else { } else {
var kicked = dbot.db.kickers[params[1]]; var kicked = dbot.db.kickers[username];
} }
dbot.say(data.channel, dbot.t('user_kicks', {'user': params[1], 'kicks': kicks, 'kicked': kicked})); event.reply(dbot.t('user_kicks', {'user': username, 'kicks': kicks, 'kicked': kicked}));
}, },
// Output a list of the people who have been kicked the most and those // Output a list of the people who have been kicked the most and those
// who have kicked other people the most. // who have kicked other people the most.
'~kickstats': function(data, params) { '~kickstats': function(event) {
var orderedKickLeague = function(list, topWhat) { var orderedKickLeague = function(list, topWhat) {
var kickArr = []; var kickArr = [];
for(var kickUser in list) { for(var kickUser in list) {
@ -42,45 +44,32 @@ var kick = function(dbot) {
return kickString.slice(0, -2); return kickString.slice(0, -2);
}; };
dbot.say(data.channel, orderedKickLeague(dbot.db.kicks, 'Kicked')); event.reply(orderedKickLeague(dbot.db.kicks, 'Kicked'));
dbot.say(data.channel, orderedKickLeague(dbot.db.kickers, 'Kickers')); event.reply(orderedKickLeague(dbot.db.kickers, 'Kickers'));
} }
}; };
return { return {
// Counts kicks 'listener': function(event) {
'listener': function(data) { if(event.kickee == dbot.name) {
if(data.kickee == dbot.name) { dbot.instance.join(event, event.channel);
dbot.instance.join(data.channel); event.reply(dbot.t('kicked_dbot', {'botname': dbot.name}));
dbot.say(data.channel, dbot.t('kicked_dbot', {'botname': dbot.name}));
dbot.db.kicks[dbot.name] += 1; dbot.db.kicks[dbot.name] += 1;
} else { } else {
if(!dbot.db.kicks.hasOwnProperty(event.kickee)) {
if(dbot.db.modehate.include(data.user)) { dbot.db.kicks[event.kickee] = 1;
dbot.instance.send('KICK ' + data.channel + ' ' + data.user + ' :gtfo (MODEHATE)');
if(!dbot.db.kicks.hasOwnProperty(data.user)) {
dbot.db.kicks[data.user] = 1;
} else {
dbot.db.kicks[data.user] += 1;
}
}
if(!dbot.db.kicks.hasOwnProperty(data.kickee)) {
dbot.db.kicks[data.kickee] = 1;
} else { } else {
dbot.db.kicks[data.kickee] += 1; dbot.db.kicks[event.kickee] += 1;
} }
if(!dbot.db.kickers.hasOwnProperty(data.user)) { if(!dbot.db.kickers.hasOwnProperty(event.user)) {
dbot.db.kickers[data.user] = 1; dbot.db.kickers[event.user] = 1;
} else { } else {
dbot.db.kickers[data.user] += 1; dbot.db.kickers[event.user] += 1;
} }
dbot.say(data.channel, data.kickee + '-- (' + event.reply(event.kickee + '-- (' + dbot.t('user_kicks',
dbot.t('user_kicks', {'user': data.kickee, 'kicks': dbot.db.kicks[data.kickee], {'user': event.kickee, 'kicks': dbot.db.kicks[event.kickee], 'kicked': dbot.db.kickers[event.kickee]}) + ')');
'kicked': dbot.db.kickers[data.kickee]}) + ')');
} }
}, },

View File

@ -3,11 +3,11 @@ var puns = function(dbot) {
var dbot = dbot; var dbot = dbot;
return { return {
'listener': function(data) { 'listener': function(event) {
data.user = dbot.cleanNick(data.user); event.user = dbot.cleanNick(data.user);
if((dbot.db.ignores.hasOwnProperty(data.user) && if((dbot.db.ignores.hasOwnProperty(event.user) &&
dbot.db.ignores[data.user].include(name)) == false) { dbot.db.ignores[event.user].include(name)) == false) {
if(dbot.moduleNames.include('quotes') && if(dbot.moduleNames.include('quotes') &&
dbot.db.quoteArrs.hasOwnProperty(data.user)) { dbot.db.quoteArrs.hasOwnProperty(data.user)) {
data.message = '~q ' + data.user.toLowerCase(); data.message = '~q ' + data.user.toLowerCase();