Skip to content

Instantly share code, notes, and snippets.

@KarbonDallas
Last active August 29, 2015 14:07
Show Gist options
  • Save KarbonDallas/42fec9ec0d75c43351eb to your computer and use it in GitHub Desktop.
Save KarbonDallas/42fec9ec0d75c43351eb to your computer and use it in GitHub Desktop.
unbanner bot
var irc = require('irc')
var bans = [ ]
var client = new irc.Client('irc.freenode.net', 'xyxne', {
userName : 'nexxy'
, realName : 'b& hammer bot'
, debug : true
, floodProtection : true
, floodProtectionDelay : 5000
})
client.addListener('pm', function(f, m) {
console.log("> Exiting.")
process.exit(0)
})
client.on('registered', function(msg) {
console.log("> Server says: %s", msg)
client.send('NICKSERV', 'identify', 'thisistotallymyrealnickservpasswordiswearlolol')
})
client.on('error', function(e) {
console.log(">>> ERROR")
console.log(e)
})
client.on('raw', function(r) {
// vhost has been set by services
if(r.command && r.command == '396') {
client.join('#node.js', function(chan, nick, msg) {
console.log("> Joined %s... getting bans", chan)
getBans()
})
}
else if(r.command == 'rpl_banlist') {
if(r.args && r.args[2]) {
console.log(r.args[2])
bans.push(r.args[2])
}
}
else if (r.command == 'rpl_endofbanlist') {
bans.forEach(unban)
}
})
client.on('rpl_banlist', function(r) {
console.log("non-raw")
console.log(r)
})
function getBans() { client.send('MODE', '#node.js', '+b') }
function unban(ban) {
if(ban) {
console.log("Unbanning %s", ban)
client.send('MODE', '#node.js', '-b', ban)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment