Last active
August 30, 2016 22:28
-
-
Save xCoreDev/21ebd80c53f8ecf36d23 to your computer and use it in GitHub Desktop.
Node.JS - Quick & Dirty Poloniex Trollbox IRC Relay. Debian/Ubuntu: apt-get install libicu-dev / NPM Modules: npm install autobahn ent irc irc-colors
This file contains 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 autobahn = require('autobahn'); | |
var ent = require('ent'); | |
var irc = require('irc'); | |
var c = require('irc-colors'); | |
var wsuri = "wss://api.poloniex.com"; | |
var connection = new autobahn.Connection({ | |
url: wsuri, | |
realm: "realm1" | |
}); | |
var client = new irc.Client('irc.freenode.net', 'Trollbox', { | |
userName: 'Trollbox', | |
realName: 'Poloniex Trollbox IRC Relay', | |
port: 6667, | |
debug: false, | |
autoRejoin: true, | |
channels: ['##yourRelayChan'], | |
}); | |
client.addListener('error', function(message) { | |
console.log('error: ', message); | |
}); | |
connection.onopen = function (session) { | |
function trollboxEvent (args,kwargs) { | |
var nick = args[2]; | |
var msg = ent.decode(args[3]); | |
client.say('##yourRelayChan', '-> ' + c.bold(nick) + ': ' + msg); | |
} | |
session.subscribe('trollbox', trollboxEvent); | |
} | |
connection.onclose = function () { | |
console.log("Websocket connection closed"); | |
} | |
connection.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment