Skip to content

Instantly share code, notes, and snippets.

@TrainerGuy22
Created June 6, 2014 03:09
Show Gist options
  • Select an option

  • Save TrainerGuy22/e10cb492b32047d765fe to your computer and use it in GitHub Desktop.

Select an option

Save TrainerGuy22/e10cb492b32047d765fe to your computer and use it in GitHub Desktop.
var NodeicusBot = require('./lib/bot.js'),
chalk = require('chalk'),
colors = require('irc-colors');
var config = require('./lib/config.js').loadConfig();
var BotInstance = new NodeicusBot(config.server.hostname, config.server.port, function() {
BotInstance.getSocket().write("NICK " + config.client.nickname + "\r\n");
BotInstance.getSocket().write("USER " + config.client.nickname + " 8 * :" + config.client.realname + "\r\n");
});
BotInstance.getSocket().on('data', function(data) {
data = data.toString();
BotInstance.getLogger().info(chalk.green("READ: ") + data);
var params = data.split(" ");
if(params[0].indexOf(":") == 0) {
BotInstance.getEmitter().emit('raw', params[1], params.slice(2));
} else {
BotInstance.getEmitter().emit('raw', params[0], params.slice(1));
}
});
BotInstance.addRawHandler("PING", function(args) {
BotInstance.sendRaw("PONG " + args[0]);
});
// lol. Kind of hacky.
var channelChecked = false;
BotInstance.addRawHandler("MODE", function(args) {
if(args[0] === config.client.nickname && args[1] === ":+i" && !channelChecked) {
channelChecked = !channelChecked;
for(channel in config.client.channels) {
BotInstance.joinChannel(channel);
BotInstance.sendMessage(channel, colors.red(config.client.joinMessage()));
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment