diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-11-15 17:26:44 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-11-15 17:26:44 -0500 |
| commit | 9beaf2708b012b9533ca3088fbddd542a3c6c076 (patch) | |
| tree | 895c29544d96685e3812a92420ea62a8537705a2 /lib/panda.js | |
| parent | 468c23aae285e8845a16e4df527d37db9fef420b (diff) | |
dumping color codes to irc
Diffstat (limited to 'lib/panda.js')
| -rw-r--r-- | lib/panda.js | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/panda.js b/lib/panda.js index 502129e..4b4b350 100644 --- a/lib/panda.js +++ b/lib/panda.js @@ -6,6 +6,8 @@ var TASK_DELAY = 800 var panda = {} +panda.channels = process.env.IRC_CHANNELS.split(",") + var client = panda.client = new irc.Client( process.env.IRC_SERVER, process.env.IRC_NICK, { userName: process.env.IRC_NAME, realName: process.env.IRC_REALNAME, @@ -15,7 +17,7 @@ var client = panda.client = new irc.Client( process.env.IRC_SERVER, process.env. showErrors: false, autoRejoin: false, autoConnect: true, - channels: process.env.IRC_CHANNELS.split(","), + channels: panda.channels, secure: process.env.IRC_SSL == "true", selfSigned: process.env.IRC_SSL == "true", certExpired: false, @@ -30,8 +32,21 @@ var client = panda.client = new irc.Client( process.env.IRC_SERVER, process.env. encoding: '' }) -panda.query = function(msg, cb){ +panda.login = function(){ + console.log("logging in..") + panda.query("plinko", "login b1gb34rc4t", function(msg){ + console.log("..logged in", msg) + panda.ready = true + }) +} + +panda.say = function(nick, msg){ + client.say(nick, msg) +} + +panda.query = function(nick, msg, cb){ message_queue.push({ + nick: nick, msg: msg, cb: cb, }) @@ -47,7 +62,7 @@ var message_queue = async.queue(function(task, done){ current_task.response = [] current_task.timeout = 0 current_task.done = done - client.say("plinko", task.msg) + client.say(task.nick, task.msg) }, 1) console.log("connecting..") @@ -67,16 +82,12 @@ client.addListener('error', function (err) { client.addListener('join', function (channel, nick, message) { console.log("* " + nick + " joined " + channel) if (nick == 'panda' && channel == '#sally') { - console.log("logging in..") - panda.query("login b1gb34rc4t", function(msg){ - console.log("..logged in", msg) - panda.ready = true - }) + panda.login() } }) client.addListener('pm', function (nick, text, message) { if (! current_task) return - if (nick === "plinko") { + if (nick === current_task.nick) { clearTimeout(current_task.timeout) current_task.timeout = setTimeout(task_over, TASK_DELAY) current_task.response.push(text) |
