2011-08-16 18:41:29 +02:00
|
|
|
var fs = require('fs');
|
2011-08-18 19:03:00 +02:00
|
|
|
var jsbot = require('./jsbot');
|
2011-08-22 14:20:06 +02:00
|
|
|
var quote = require('./quotes');
|
2011-08-22 18:54:12 +02:00
|
|
|
var userCommands = require('./user');
|
2011-08-22 19:56:36 +02:00
|
|
|
var adminCommands = require('./admin');
|
|
|
|
var puns = require('./puns');
|
2011-08-22 20:24:23 +02:00
|
|
|
var kick = require('./kick');
|
|
|
|
var reality = require('./reality');
|
|
|
|
var karma = require('./karma');
|
2011-08-16 18:41:29 +02:00
|
|
|
|
|
|
|
///////////////////////////
|
|
|
|
|
|
|
|
Array.prototype.random = function() {
|
|
|
|
return this[Math.floor((Math.random()*this.length))];
|
2011-08-16 19:05:43 +02:00
|
|
|
};
|
2011-08-16 18:41:29 +02:00
|
|
|
|
2011-08-22 18:54:12 +02:00
|
|
|
///////////////////////////
|
2011-08-22 20:24:23 +02:00
|
|
|
|
2011-08-22 18:54:12 +02:00
|
|
|
var dbot = Class.create({
|
2011-08-22 19:56:36 +02:00
|
|
|
initialize: function(dModules, quotes) {
|
2011-08-22 18:54:12 +02:00
|
|
|
this.admin = 'reality';
|
|
|
|
this.waitingForKarma = false;
|
|
|
|
this.name = 'depressionbot';
|
|
|
|
this.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
2011-08-22 19:56:36 +02:00
|
|
|
this.quotes = quotes.fetch(this);
|
2011-08-22 18:54:12 +02:00
|
|
|
|
|
|
|
this.instance = jsbot.createJSBot(this.name, 'elara.ivixor.net', 6667, this, function() {
|
|
|
|
this.instance.join('#realitest');
|
|
|
|
}.bind(this));
|
|
|
|
|
2011-08-22 19:56:36 +02:00
|
|
|
this.modules = dModules.collect(function(n) {
|
|
|
|
var module = n.fetch(this);
|
|
|
|
this.instance.addListener(module.on, module.listener);
|
|
|
|
return n.fetch(this);
|
|
|
|
}.bind(this));
|
2011-08-22 14:20:06 +02:00
|
|
|
|
2011-08-22 19:56:36 +02:00
|
|
|
this.instance.connect();
|
2011-08-22 18:54:12 +02:00
|
|
|
},
|
2011-08-22 14:20:06 +02:00
|
|
|
|
2011-08-22 18:54:12 +02:00
|
|
|
say: function(channel, data) {
|
|
|
|
this.instance.say(channel, data);
|
|
|
|
},
|
2011-08-22 14:20:06 +02:00
|
|
|
|
2011-08-22 18:54:12 +02:00
|
|
|
save: function() {
|
|
|
|
fs.writeFile('db.json', JSON.stringify(this.db, null, ' '));
|
|
|
|
}
|
|
|
|
});
|
2011-08-22 14:20:06 +02:00
|
|
|
|
2011-08-22 20:24:23 +02:00
|
|
|
new dbot([userCommands, adminCommands, puns, kick, reality, karma], quote);
|