Skip to content

Instantly share code, notes, and snippets.

@nitind
Last active August 6, 2018 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitind/a995d005c202be65cea319006806e352 to your computer and use it in GitHub Desktop.
Save nitind/a995d005c202be65cea319006806e352 to your computer and use it in GitHub Desktop.
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