Calling api.createClient through a function kills its host script. For instance...
var factory = require('irc-factory'),
api = new factory.Api();
function factory () {
var client = api.createClient('test', {
nick : 'testIRCBot',
user : 'testuser',
server : 'irc.freenode.net',
realname: 'realbot',
port: 6667,
secure: false
});
*** SCRIPT DIES HERE ***
// create a client by giving it a unique key, and a config object
// You can see more info on the config options and the client class at the bottom of the page
api.hookEvent('test', '*', function(message) {
console.log(message);
});
// hook to all events for our client and output them to console
api.hookEvent('test', 'registered', function(message) {
client.irc.join('##cydrobolt');
});
}
factory();
However, when it is called like so:
var factory = require('irc-factory'),
api = new factory.Api();
var client = api.createClient('test', {
nick : 'testIRCBot',
user : 'testuser',
server : 'irc.freenode.net',
realname: 'realbot',
port: 6667,
secure: false
});
// create a client by giving it a unique key, and a config object
// You can see more info on the config options and the client class at the bottom of the page
api.hookEvent('test', '*', function(message) {
console.log(message);
});
// hook to all events for our client and output them to console
api.hookEvent('test', 'registered', function(message) {
client.irc.join('##cydrobolt');
});
did you try wrapping the createClient in a try/catch block and console.loging the error? Sometimes scripts, due to their environment, can silently eat errors
Calling
api.createClient
through a function kills its host script. For instance...However, when it is called like so:
everything works like normal.