IRC was the best 10 years ago, now other softwares have eclipsed, but many savvy people keep using it for proper communication with special individuals. So, if you never heard or configured eggdrops, this is something similar.

So first you will need to install NodeJS, and I will consider that you already have it, then you should have NPM also installed, then just install the irc library:

npm install irc

Once you have that, you need to specify that you are using this module and then set the configure on connecting to know which channels the bot will join automatically, and then set up the port, which is not a regular port for IRC but you need to set something more stable for a bot.

var irc = require('irc');
var bot = new irc.Client('chat.freenode.net','w0bot', {
    channels: ['#botplace', '#w0b'],
    port: 8001,
    debug: true,
    userName: 'wizard', // on the host is like wizard@host/ip
    realName: 'Im a bot from Wizard of Bots ;)',  // real name on whois
    showErrors: true, 
    autoRejoin: true, // auto rejoin channel when kicked
    autoConnect: true, // persistence to connect
});

So as you see, first we set up the server, then the nick, and then we open encapsulation to add the channels, the port and a mode where we can see what is going on on your console.

NOTE: You might get some errors when connecting, but try again and again. When you are able to connect, no matter if you sleep your localhost, it will continue connecting. Also this is for leaving it working on a VPS or shell so you have a always online bot.

But now that you have your bot online, what’s next? You need to know wtf is going on in the channels that you join or the PM you receive, and for that we have listeners.

Before getting into this I will explain the functions we have available so we can use them when we get events on the listeners:

bot.join('#yourchannel yourpass'); // this will join a channel with a pass (or no pass)
bot.part('#yourchannel'); //part a channel
bot.say('#yourchannel', "I'm a bot for w0b!"); // send a message to a channel
bot.whois(nickname, function (whois) {
    console.log(whois); // you need this callback to log the results once it finished doing the whois
bot.notice(target, "your message for the notice"); //target is either a nickname or a channel
});
bot.send('MODE', '#yourchannel', '+o', 'yournick'); // Gives OP to yournick in #yourchannel

So now that you know the commands to use on the Events, we now are listing the Listeners for this stuff:

bot.addListener('pm', function (from, message) {
    console.log(from + ' => ME: ' + message); // when you get a PM you log into console
    bot.say(from, 'Hello I am a bot from Wizard of Bots '); // Also you can automatically respond to that message with the command say
});
bot.addListener('message#yourchannel', function (from, message) {
    console.log(from + ' => #yourchannel: ' + message); // if someone sends a message to a specific channel
});
bot.addListener('join', function(channel, who) {
    console.log('%s has joined %s', who, channel);
    bot.say(who, 'Hello and welcome to ' + channel); // When someone joins a channel automatically welcome him
});
bot.addListener('kick', function(channel, who, by, reason) {
    console.log('%s was kicked from %s by %s: %s', who, channel, by, reason); // when someone is kicked log into the console what happend.
});
bot.addListener('part', function(channel, who, reason) {
    console.log('%s has left %s: %s', who, channel, reason); // when someone part
    // you can also send a PM to this guy to convince to stay.
});
bot.addListener('message', function(from, to, message) {
    if(  message.indexOf('Know any good jokes?') > -1
      || message.indexOf('good joke') > -1
    ) {
        bot.say(to, 'Knock knock!');
    }
});  // and in like other eggdrops, if you say those words, it will answer Knock Knock

 

Tonight I was watching Mr. Robot chapter 4, season 2. And it remind me back the good old days where the IRC was above any other social network. People meet there in tons of channels to have chats and discussions. Also there were plenty of groups talking about many stuff, the best crews were the ones with coders.

So well, what do I like about IRC?, There were plenty of cool things back then in 1995, there were the amazing eggdrops that you programmed to respond to different messages. They also had TCL’s which mean addons/plugins that you could adapt to your bot, many were different cool games in group. Also there were PsyBNCs to be always online with your shell.

To run this just do the following:

mkdir bitchx
nano install_bitchx.sh

And then just paste this code:

#!/bin/sh
####################################################################################
#
# Download Compile and Install BitchX on Ubuntu
#
####################################################################################

# download bitchx source

# @todo make smarter, i.e. regexp, though now uses _always_ available commands (sic)
DOWNLOAD_URL=$(curl -s http://bitchx.sourceforge.net |\
        grep "http://sourceforge.net" |\
         sed -e "s|.*href=\"||g" |\
         sed -e "s|\".*||g" |\
         grep "/download" | uniq) # should only be one

if [ "${DOWNLOAD_URL}" = "" ]; then
  echo "ERROR: Could not find DOWNLOAD_URL from http://bitchx.sourceforge.net"
  exit 255;
fi

# @todo make smarter, i.e. regexp, though now uses _always_ available commands (sic)
VERSION=$(echo ${DOWNLOAD_URL} | sed -e "s|.*ircii-pana/bitchx-||g" | sed -e "s|\/.*||g")

if [ "${VERSION}" = "" ]; then
  echo "ERROR: Could not find VERSION from ${DOWNLOAD_URL}"
  exit 255;
fi

echo "Will try to download and install version ${VERSION}";

DOWNLOAD_URL=http://downloads.sourceforge.net/project/bitchx/ircii-pana/bitchx-${VERSION}/bitchx-${VERSION}.tar.gz

echo "Downloading: ${DOWNLOAD_URL}"
curl -L -s "${DOWNLOAD_URL}" -o bitchx-${VERSION}.tar.gz

# install required dev libraries
sudo apt-get install libssl-dev ncurses-dev

# unpack source
tar -xzf bitchx-${VERSION}.tar.gz

# go to source dir
cd bitchx-${VERSION}

# configure
./configure --prefix=/usr --with-ssl --with-plugins --enable-ipv6

# build
make

# install (change to "make install_local" for local installation; in your own $HOME)
sudo make install

# remove src + build
cd $OLDPWD && rm -rf bitchx-${VERSION}*

# done use "BitchX" to run...

Then you just have to:

chmod +x install_bitchx.sh
./install_bitchx.sh

And this will begin to install everything you need to run BitchX, then just type to run:

BitchX

By the way, did you know you can connect to Elliot’s IRC session using this page: http://irc.colo-solutions.net/