Skip to content

Instantly share code, notes, and snippets.

@JordanMussi
Last active August 29, 2015 13:57
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 JordanMussi/9417791 to your computer and use it in GitHub Desktop.
Save JordanMussi/9417791 to your computer and use it in GitHub Desktop.
An IRC bot to inform icyboards101 users that support is not provided at irc.icyboards.com#icynetwork
var config = {
server: 'irc.icyboards.com',
channels: ['#icynetwork'],
nick: 'IcyBot',
password: '',
floodProtectionDelay: 1000,
supportKeywords: ['support', 'help', 'question']
};
/*
----------------------
END OF CONFIGURATION
----------------------
*/
/*
Some useful snippits of code have been magpied from DennisTT's
node-mybb-irc-bot <https://github.com/DennisTT/node-mybb-irc-bot>
*/
var irc = require('irc');
var bot = new irc.Client(config.server, config.nick, {
channels: [],//config.channels,
userName: config.nick,
floodProtection: true,
floodProtectionDelay: config.floodProtectionDelay
});
bot.addListener('join', function(channel, nick, message) {
if(nick.indexOf('icyboards') == 0) {
console.log('Icyboards user joined: ' + nick);
bot.say(channel, nick + ': Please note that support is not provided here. Please use the forums instead!');
}
});
bot.addListener('message#', function(from, to, message) {
if(from.indexOf('icyboards') == 0 && isSupport(message)) {
bot.say(to, '/msg ChanServ KICK ' + to + ' ' + from + ' No support is provided here. Please use the forums instead!');
console.log('Kicked ' + from + ' for requesting support on ' + to);
}
});
bot.addListener('motd', function(message) {
console.log('MOTD received');
// Check name
if (config.password != '') {
recoverNick();
}
// Join channels
joinChans();
});
/*
-------------------
HELPFUL FUNCTIONS
-------------------
*/
var recoverNick = function() {
bot.say('NickServ', 'identify ' + config.nick + ' ' + config.password);
setTimeout(function() {
bot.say('NickServ', 'ghost ' + config.nick);
}, 3000);
setTimeout(function() {
bot.say('NickServ', 'release ' + config.nick);
}, 6000);
setTimeout(function() {
bot.send('NICK', config.nick);
}, 9000);
}
var joinChans = function() {
var i = 0,
channels = config.channels;
for(i = 0; i < channels.length; i++) {
console.log('Joining channel: ' + channels[i]);
bot.join(channels[i]);
}
}
var isSupport = function(message) {
var i = 0,
keywords = config.supportKeywords;
message = message.toLowerCase();
for(i = 0; i < keywords.length; i++) {
if(message.indexOf(keywords[i]) != -1) {
return true;
}
}
return false;
}

IcyBot

An IRC bot to inform icyboards101 users that support is not provided at irc.icyboards.com#icynetwork

To Install

  • Install Node.js
  • Download the package.json and the icybot.js files.
  • Run npm install

To Run

  • Edit the configuration block at the top of the icybot.js file
  • Run node icybot.js
{
"name": "node-icybot",
"description": "An IRC bot to inform icyboards101 users that support is not provided at irc.icyboards.com#icynetwork",
"version": "1.0.0",
"maintainers": [
{
"name": "Jordan Mussi",
"email": "",
"web": "http://jordanmussi.github.io"
}
],
"dependencies": {
"irc": "~0.3.6",
},
"repositories": [
{
"type": "git",
"url": "https://gist.github.com/9417791.git"
}
],
"licenses": [
{
"name": "GPLv3",
"url": "http://www.gnu.org/licenses/gpl-3.0.txt"
}
],
"homepage": "httpshttp://jordanmussi.github.io"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment