Skip to content

Instantly share code, notes, and snippets.

@xCoreDev
Last active August 30, 2016 22:28
Show Gist options
  • Save xCoreDev/21ebd80c53f8ecf36d23 to your computer and use it in GitHub Desktop.
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
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