index.js
function init(_config) {
  if (initialized)
    return;

  // Validate the config
  config = helpers.validateConfig(_config);

  // Create a user for the bot
  users[config.name] = helpers.createUser(true);

  // Create a user for the channel owner
  var name = config.channel.replace('#', '');
  users[name] = helpers.createUser(true);

  // Init the client
  ircClient = new irc.Client(config.server, config.name, {
    userName: config.name,
    realName: config.name,
    password: config.password,
    port:     config.port,
    secure:   config.secure,
  });

  // Add listeners
  ircClient.addListener('error',                    onError);
  ircClient.addListener('registered',               onRegistered);
  ircClient.addListener('join' + config.channel,    onJoin);
  ircClient.addListener('part' + config.channel,    onPart);
  ircClient.addListener('motd',                     onMotd);
  ircClient.addListener('notice',                   onNotice);
  ircClient.addListener('message' + config.channel, onMessage);
  ircClient.addListener('raw',                      onRaw);

  // If there is a discord token
  if (config.discordToken) {
    // Init the discord client
    discordClient = new Discord.Client({
      token:   config.discordToken,
      autorun: true,
    });

    // Add listeners
    discordClient.on('ready',   onDiscordReady);
    discordClient.on('message', onDiscordMessage);
  }

  // If we are logging, create the directory if not exists
  if (config.log && typeof config.log === 'string')
    mkdirp.sync(config.log);

  // Init stream checker
  if (config.autoExit || config.discordToken)
    streamInterval = setInterval(onCheckStream, 60 * 1000)

  initialized = true;
}
function init(_config) {
  if (initialized)
    return;

  // Validate the config
  config = helpers.validateConfig(_config);

  // Create a user for the bot
  users[config.name] = helpers.createUser(true);

  // Create a user for the channel owner
  var name = config.channel.replace('#', '');
  users[name] = helpers.createUser(true);

  // Init the client
  ircClient = new irc.Client(config.server, config.name, {
    userName: config.name,
    realName: config.name,
    password: config.password,
    port:     config.port,
    secure:   config.secure,
  });

  // Add listeners
  ircClient.addListener('error',                    onError);
  ircClient.addListener('registered',               onRegistered);
  ircClient.addListener('join' + config.channel,    onJoin);
  ircClient.addListener('part' + config.channel,    onPart);
  ircClient.addListener('motd',                     onMotd);
  ircClient.addListener('notice',                   onNotice);
  ircClient.addListener('message' + config.channel, onMessage);
  ircClient.addListener('raw',                      onRaw);

  // If there is a discord token
  if (config.discordToken) {
    // Init the discord client
    discordClient = new Discord.Client({
      token:   config.discordToken,
      autorun: true,
    });

    // Add listeners
    discordClient.on('ready',   onDiscordReady);
    discordClient.on('message', onDiscordMessage);
  }

  // If we are logging, create the directory if not exists
  if (config.log && typeof config.log === 'string')
    mkdirp.sync(config.log);

  // Init stream checker
  if (config.autoExit || config.discordToken)
    streamInterval = setInterval(onCheckStream, 60 * 1000)

  initialized = true;
}
function init ( _config ) { if ( initialized ) return ; // Validate the config config = helpers . validateConfig ( _config ) ; // Create a user for the bot users [ config . name ] = helpers . createUser ( true ) ; // Create a user for the channel owner var name = config . channel . replace ( '#' , '' ) ; users [ name ] = helpers . createUser ( true ) ; // Init the client ircClient = new irc . Client ( config . server , config . name , { userName : config . name , realName : config . name , password : config . password , port : config . port , secure : config . secure , } ) ; // Add listeners ircClient . addListener ( 'error' , onError ) ; ircClient . addListener ( 'registered' , onRegistered ) ; ircClient . addListener ( 'join' + config . channel , onJoin ) ; ircClient . addListener ( 'part' + config . channel , onPart ) ; ircClient . addListener ( 'motd' , onMotd ) ; ircClient . addListener ( 'notice' , onNotice ) ; ircClient . addListener ( 'message' + config . channel , onMessage ) ; ircClient . addListener ( 'raw' , onRaw ) ; // If there is a discord token if ( config . discordToken ) { // Init the discord client discordClient = new Discord . Client ( { token : config . discordToken , autorun : true , } ) ; // Add listeners discordClient . on ( 'ready' , onDiscordReady ) ; discordClient . on ( 'message' , onDiscordMessage ) ; } // If we are logging, create the directory if not exists if ( config . log && typeof config . log === 'string' ) mkdirp . sync ( config . log ) ; // Init stream checker if ( config . autoExit || config . discordToken ) streamInterval = setInterval ( onCheckStream , 60 * 1000 ) initialized = true ; }
Init the twitch bot

@param _config {object} - config to init the bot with
Init the twitch bot