Created
February 14, 2012 12:14
-
-
Save DamianZaremba/1826421 to your computer and use it in GitHub Desktop.
CBNG Relay
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
#!/usr/bin/env node | |
var irc = require('irc'); | |
var dgram = require("dgram"); | |
var relay1 = dgram.createSocket("udp4"); | |
var relay2 = dgram.createSocket("udp4"); | |
var relay3 = dgram.createSocket("udp4"); | |
var client = new irc.Client( 'irc.cluenet.org', 'CBNGRelay', { | |
userName: 'CBNGRelay', | |
realName: 'CBNGRelay', | |
debug: false, | |
showErrors: false, | |
autoRejoin: true, | |
autoConnect: true, | |
secure: false, | |
channels: [ | |
'#cluebotng', | |
'#cluebotng-spam', | |
'#wikipedia-van', | |
], | |
}); | |
relay1.on('message', function(data, info) { | |
data = data.toString().substring( 0, 450 ) | |
try { | |
client.say( '#cluebotng', data ); | |
} catch ( e ){ | |
console.error( e ) | |
} | |
}); | |
relay2.on('message', function(data, info) { | |
data = data.toString().substring( 0, 450 ) | |
try { | |
client.say( '#cluebotng-spam', data ); | |
} catch ( e ){ | |
console.error( e ) | |
} | |
}); | |
relay3.on('message', function(data, info) { | |
data = data.toString().split(' :', 2) | |
try { | |
chan = data[0].toString() | |
msg = data[1].toString().substring( 0, 450 ) | |
client.say( chan, msg ); | |
} catch ( e ){ | |
console.error( e ) | |
} | |
}); | |
client.addListener('error', function(message) { | |
console.error('ERROR: %s: %s', message.command, message.args.join(' ')); | |
}); | |
client.addListener('motd', function(motd) { | |
console.log('Opering up') | |
client.conn.write('OPER something andsomethingelse' + "\r\n") | |
}); | |
relay1.bind( 3333 ) | |
relay2.bind( 3334 ) | |
relay3.bind( 1337 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment