Last active
August 29, 2015 14:07
-
-
Save KarbonDallas/42fec9ec0d75c43351eb to your computer and use it in GitHub Desktop.
unbanner bot
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
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