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

server information read from config file

This commit is contained in:
Luke Slater 2011-11-27 18:25:54 +00:00
parent 344ae848a4
commit 6145e55942

12
run.js
View File

@ -3,7 +3,7 @@ var timers = require('./timer');
var jsbot = require('./jsbot'); var jsbot = require('./jsbot');
require('./snippets'); require('./snippets');
var modules = ['spelling', 'web', 'modehate', 'user', 'admin', 'puns', 'kick', 'karma', 'youare', 'quotes']; var modules = [ ];
var DBot = function(dModules, timers) { var DBot = function(dModules, timers) {
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8')); this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
@ -13,11 +13,13 @@ var DBot = function(dModules, timers) {
this.admin = this.config.admin || 'reality'; this.admin = this.config.admin || 'reality';
this.password = this.config.password || 'lolturtles'; this.password = this.config.password || 'lolturtles';
this.nickserv = this.config.nickserv || 'zippy'; this.nickserv = this.config.nickserv || 'zippy';
this.server = this.config.server || 'elara.ivixor.net';
this.port = this.config.port || 6667;
this.timers = timers.create(); this.timers = timers.create();
this.waitingForKarma = false; this.waitingForKarma = false;
this.instance = jsbot.createJSBot(this.name, 'elara.ivixor.net', 6667, this, function() { this.instance = jsbot.createJSBot(this.name, this.server, this.port, this, function() {
if(this.config.hasOwnProperty('channels')) { if(this.config.hasOwnProperty('channels')) {
this.config.channels.each(function(channel) { this.config.channels.each(function(channel) {
this.instance.join(channel); this.instance.join(channel);
@ -93,8 +95,10 @@ DBot.prototype.reloadModules = function() {
if(data.channel == this.name) data.channel = data.user; if(data.channel == this.name) data.channel = data.user;
if(this.commands.hasOwnProperty(params[0])) { if(this.commands.hasOwnProperty(params[0])) {
if((this.db.bans.hasOwnProperty(params[0]) && this.db.bans[params[0]].include(data.user)) || this.db.bans['*'].include(data.user)) if((this.db.bans.hasOwnProperty(params[0]) &&
this.say(data.channel, data.user + ' is banned from using this command. Commence incineration.'); this.db.bans[params[0]].include(data.user)) || this.db.bans['*'].include(data.user))
this.say(data.channel, data.user +
' is banned from using this command. Commence incineration.');
else { else {
this.commands[params[0]](data, params); this.commands[params[0]](data, params);
this.save(); this.save();