Created
June 6, 2014 03:09
-
-
Save TrainerGuy22/e10cb492b32047d765fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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