forked from GitHub/dbot
Transformed config file to accept multiple servers and changed dbot constructors to reflect this
This commit is contained in:
parent
2954df3a52
commit
ccc36d67a7
@ -1,8 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "depressionbot",
|
"name": "testressionbot",
|
||||||
"password": "fishes",
|
"servers": {
|
||||||
|
"freenode": {
|
||||||
|
"server": "irc.freenode.net",
|
||||||
|
"port": 6667,
|
||||||
|
"nickserv": "nickserv",
|
||||||
|
"password": "lolturtles",
|
||||||
|
"channels": [
|
||||||
|
"#realitest"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"admin": [ "batman" ],
|
"admin": [ "batman" ],
|
||||||
"channels": [
|
|
||||||
"#42"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
49
run.js
49
run.js
@ -43,34 +43,49 @@ var DBot = function(timers) {
|
|||||||
this.db.ignores = {};
|
this.db.ignores = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the strings file
|
// Load Strings file
|
||||||
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
|
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
|
||||||
|
|
||||||
|
// Initialise run-time resources
|
||||||
|
this.sessionData = {};
|
||||||
|
this.timers = timers.create();
|
||||||
|
|
||||||
// Populate bot properties with config data
|
// Populate bot properties with config data
|
||||||
this.name = this.config.name || 'dbox';
|
this.name = this.config.name || 'dbox';
|
||||||
this.admin = this.config.admin || [ 'reality' ];
|
this.admin = this.config.admin || [ 'reality' ];
|
||||||
this.password = this.config.password || 'lolturtles';
|
this.moduleNames = this.config.modules || [ 'command', 'js' ];
|
||||||
this.nickserv = this.config.nickserv || 'zippy';
|
|
||||||
this.server = this.config.server || 'elara.ivixor.net';
|
|
||||||
this.port = this.config.port || 6667;
|
|
||||||
this.webPort = this.config.webPort || 443;
|
|
||||||
this.moduleNames = this.config.modules || [ 'command', 'js', 'admin', 'kick', 'modehate', 'quotes', 'puns', 'spelling', 'web', 'youare', 'autoshorten' ];
|
|
||||||
this.language = this.config.language || 'english';
|
this.language = this.config.language || 'english';
|
||||||
this.sessionData = {};
|
|
||||||
|
|
||||||
this.timers = timers.create();
|
// It's the user's responsibility to fill this data structure up properly in
|
||||||
|
// the config file. They can d-d-d-deal with it if they have problems.
|
||||||
this.instance = jsbot.createJSBot(this.name, this.server, this.port, this, function() {
|
this.servers = this.config.servers || {
|
||||||
if(this.config.hasOwnProperty('channels')) {
|
'freenode': {
|
||||||
this.config.channels.each(function(channel) {
|
'server': 'irc.freenode.net',
|
||||||
this.instance.join(channel);
|
'port': 6667,
|
||||||
}.bind(this));
|
'nickserv': 'nickserv',
|
||||||
|
'password': 'lolturtles',
|
||||||
|
'channels': [
|
||||||
|
'#realitest'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}.bind(this), this.nickserv, this.password);
|
};
|
||||||
|
|
||||||
|
// Create JSBot and connect to each server
|
||||||
|
this.instance = jsbot.createJSBot(this.name);
|
||||||
|
for(var name in this.servers) {
|
||||||
|
if(this.servers.hasOwnProperty(name)) {
|
||||||
|
var server = this.servers[name];
|
||||||
|
this.instance.addConnection(name, server.server, server.port, this.admin, function(event) {
|
||||||
|
server.channels.each(function(channel) {
|
||||||
|
instance.join(event, channel)
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this), server.nickserv, server.password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load the modules and connect to the server
|
// Load the modules and connect to the server
|
||||||
this.reloadModules();
|
this.reloadModules();
|
||||||
this.instance.connect();
|
this.instance.connectAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Say something in a channel
|
// Say something in a channel
|
||||||
|
Loading…
Reference in New Issue
Block a user