Skip to content

Instantly share code, notes, and snippets.

@niclasleonbock
Created June 20, 2015 10:45
Show Gist options
  • Save niclasleonbock/3794d703d64ed399971b to your computer and use it in GitHub Desktop.
Save niclasleonbock/3794d703d64ed399971b to your computer and use it in GitHub Desktop.
IRC Relay Bot
#!/usr/bin/node
var Client = require('coffea'); // npm install coffea
var sourceChannel = '#source',
targetChannel = '#target',
target = new Client([
{
host: '', // target host
port: 6667, // default value: 6667
nick: 'relaybot', // default value: 'coffea' with random number
username: 'relaybot', // default value: username = nick
realname: 'relaybot', // default value: realname = nick
},
]),
source = new Client([
{
host: '', // source host
port: 6667, // default value: 6667
nick: 'relaybot', // default value: 'coffea' with random number
username: 'relaybot', // default value: username = nick
realname: 'relaybot', // default value: realname = nick
},
]);
// join channels
target.on('motd', function (err, event) {
target.join([targetChannel], event.network);
});
source.on('motd', function (err, event) {
source.join([sourceChannel], event.network);
});
// relay messages from source to target
source.on('message', function (err, event) {
target.send(targetChannel, '<' + event.user.getNick() + '> ' + event.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment