Hack 76 Set Up an Eggdrop Bot


years, so plenty of authors have had time to write Tcl scripts or C
modules that make these kinds of bots very powerful. This hack shows
you how to install and set up a simple Eggdrop.
Eggdrop is
the oldest IRC bot still in active development. It supports multiple
channels and can be extended using Tcl scripts or C
modulesthousands of which can be downloaded freely to perform
common tasks, which Eggdrop does not support natively.Downloading, installing, and configuring Eggdrop is relatively
simple. The first step is to connect to the server you will run the
bot on, probably via SSH or Telnet. When you are connected, you can
obtain a copy of the Eggdrop source code. The easiest way to obtain
the latest version of the source code is to use
wget. If you type wget
eggheads.org, the current (stable) version of
the Eggdrop code will be
downloaded to the current directory, as shown in Figure 12-1.
Figure 12-1. Using wget to get the Eggdrop source code

would rather not use it, you can download the files manually from
http://www.eggheads.org and
upload the files to the server via FTP or SCP.The Eggdrop source code is distributed as a tarball, so the next
thing to do is "untar" it. This is
done using the tar command, like so:
% tar zxvf eggdrop1.6.15.tar.gzYou may need to change the
filename if you have downloaded a more recent version.This will copy all of the files in the tarball to a new directory, as
shown in Figure 12-2.
Figure 12-2. Eggdrop extracted into its own directory

% cd eggdrop1.6.15If you are curious about Eggdrop, you may want to read the README and
INSTALL files. They contain information on installing and running
Eggdrop. When
you have read these files, you can run Eggdrop's
configure script:
% ./configureThis allows Eggdrop to adjust its settings so it can work correctly
on your system. When this has finished, type:
% make configThis allows Eggdrop to configure the modules it needs. When the
default modules have finished compiling, you should see something
like Figure 12-3.
Figure 12-3. Configuring the required modules with make config

% makeThis will compile the bot, but it may take a few minutes depending on
the speed of your server. Now you're ready to
install the bot. Type this:
% make installand you should see something like Figure 12-4.
Figure 12-4. Installing Eggdrop

~/eggdropthat is, it will create an
eggdrop directory in your home directory.
cd to this folder, and you are now ready to edit
the configuration file for your Eggdrop.
12.5.1 Configuring Eggdrop
The
first step is to open the config file in your favorite editor, for
example:
% pico -w eggdrop.confAs you look through the file, remember that all the lines that begin
with a hash (#) are comments and will not be
interpreted by Eggdrop. You can safely ignore most of these if
you're in a rush, but they can often provide
valuable help when it comes to setting up the more exotic features.Most of Eggdrop's settings are in the form of
set variable "value", which assigns the
"value" to the variable. For
example set nick "Hacky" would set the
Eggdrop's nickname to
"Hacky." The most important
settings follow:username
This is the login that Eggdrop will use as its Ident if there is no
identd running.
admin
This should tell users how to contact the administrator of the bot
(most likely you). The information is given out when a user types
/msg bot help.
network
This is used only if you are linking your Eggdrop to another bot and
allows the bots to establish a connection whether they are on the
same network or not. It should be either the name of the network (for
example, "freenode") or a server
name.
timezone
This controls which time zone the bot will be running in and should
probably be set to the same time zone as the server.
userfile
This determines where Eggdrop will look for its user file. This
contains details about all of the users known to the bot. It can be
named anything you like. Something like
hacky.users is the easiest to keep track of,
however.
listen
This command takes a different format than most others. The syntax is
listen port type, and it needs to be uncommented
and altered if you wish to link your Eggdrop to other bots or if you
wish to telnet to it. Chose a number for the port, somewhere between
1024 and 10000, and make sure the # is removed
from the line.
owner
This command is required for your bot to recognize you as its owner.
Uncomment the line, and replace the value with the nickname you use
on IRC.
die
A few lines beneath the owner setting is a line
beginning with die. This must be removed or
commented out; otherwise your bot will not start. This is cunningly
placed there to ensure that people edit the config file fully before
using the bot.
chanfile
This is the file that Eggdrop will store its channels and settings
in. You may like to name it in a similar fashion to the user file.
net-type
This setting allows the bot to determine which commands it can use on
the server it is connecting to. Most networks will probably be of
type "other."
nick
This is the nickname the bot uses on IRC. It can be anything you
like, as long as the IRC server allows it. Most servers will not
allow a nickname beginning with numbers, for example.
altnick
This is the nickname the bot will try to use if its preferred
nickname is in use. It can contain a question mark, which tells
Eggdrop to insert a random number at that point. For example, setting
this to "Hacky?" could result in
the nick ending up as "Hacky123."
realname
This is what will be displayed as the bot's real
name on IRC. Most people set this to "/msg botname
hello" or list the bot's primary
channel. Other users are then able to view this information when they
type /whois hacky.
servers
This is a list of servers the bot will try to connect to. Delete the
two examples and add the addresses of one or more servers on the
network you want the bot to connect to.
learn-users
This controls whether users can create their own account on the bot
by saying "hello" to it. Setting it
to "1" will make it easier to set
up the bot via IRC.
notefile
This is the file in which the bot will store notes (messages from one
user to another). This should probably be named similarly to the user
file.
die
Shortly after the notefile setting is another
die command that needs to be commented out.
blowfish
This is a commented-out loadmodule command. You
must uncomment this line, as blowfish is required to encrypt the
passwords in the bot's user file.
When you have finished editing the file, save the changes and quit
back to the shell. You can now start the bot by typing:
% ./eggdrop -m eggdrop.confThis launches the bot for the first time. To run it again, type:
% ./eggdrop eggdrop.confChris Smith