Last active
August 6, 2018 19:27
-
-
Save nitind/a995d005c202be65cea319006806e352 to your computer and use it in GitHub Desktop.
This file contains 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 config = { | |
channels : [ '#channel' ], | |
server : "irc.freenode.net", | |
botName : "sentinel123456", | |
}; | |
var irc = require('irc'); | |
var kickables = ['IRC ad service','bryanostergaard','Freenodegate','MattSTrout','engagement rates!','freenode and their ICO scam','"denial" on the freenode blog','unethical of Christel','freenode voting rights. Andrew Lee','those donations she speaks of']; | |
// Create the bot | |
var client = new irc.Client(config.server, config.botName, { | |
channels : config.channels, | |
showErrors: false, | |
}); | |
client.on('error', function(message) { | |
console.error(message); | |
}); | |
client.addListener("message", function(from, to, text, message) { | |
console.log(to + ' message from ' + message.nick + ': "' + text + '"');//+ message.user + '@' + message.host); | |
for (var offense of kickables) { | |
if (text.toLowerCase().includes(offense.toLowerCase())) { | |
// blows up with an error if not OP | |
//console.log('Banning ' + message.nick); | |
//try { | |
// client.send('MODE', to, '+b', '*!*@' + message.host); | |
//} | |
//catch(error) { | |
// console.error(error); | |
//} | |
console.log('Kicking ' + message.nick); | |
try { | |
client.send('KICK', to, message.nick, 'Spam is off topic on freenode.'); | |
} | |
catch(error) { | |
console.error(error); | |
} | |
return; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment