Site Meter
[Applications]   [Classes]   [Commands]   [Downloads]   [Egghelp]   [Features]   [Help]   [Information]   [Links]   [News]   [Policies]   [Staff]

Setting up an Eggdrop

Setting up a Botnet

1. TCL in General
2. Project: Talk Back

Lesson 1
Eggdrop TCL Scripts in General

A TCL script is created as an ordinary text file. Hence, appropriate programs to use in editing such a script would include Notepad (in Windows) and pico (in Linux).

The main eggdrop configuration file (usually named eggdrop.conf) is an example of a TCL script. Indeed, that file must be edited in order to add any other scripts to a bot. Let's take a look at how that is done:

  1. Create your TCL script (we will discuss how, later), and save it as a text file. Let's assume you save it using the file name testing.tcl and put it in the same directory as the main eggdrop configuration file.
  2. Edit the main configuration file, by adding one line to the bottom of the file. That line should be:
  3. source testing.tcl
That's all there is to it. When the bot is started up in the shell, the main configuration file will do whatever it normally did, and it will also load and execute the script named testing.tcl.

It is quite likely that the main configuration file already has several statements in it that begin with the word source. Naturally, they also load and run scripts. It is even possible to have a script that is loaded this way to contain source commands of its own, which will in turn load still more scripts.


Look at the contents of your bot's main configuration file, find all the source commands in it, and list the names of the script files loaded that way. Then go to each of those files, and repeat the process. You should end up with a (fairly lengthy) list of all the TCL scripts that your bot is already running.

What TCL Scripts Look Like

Every TCL file consists of a bunch of TCL commands, listed one after another. Nothing else can be in the file. The simplest arrangement is simply one command per line; in fact, the rule of thumb is that a command's end is indicated by the end of the line being reached Here is an example of that arrangement:
set horrible 42
set wonderful 16
putlog "I set the variable horrible to $horrible"
source horrible.tcl
In that example, there are four commands in the script: two set commands, a putlog command, and a source command. Notice that:
  • the first set command has two arguments or parameters, namely horrible and 42
  • the second set command has two arguments also: wonderful and 16
  • the putlog command has only one argument, namely, "I set the variable horrible to $horrible"
  • the source command has one argument: horrible.tcl

A second way to indicate the end of a command is with a semi-colon. Example:

set horrible 42; set wonderful 16
putlog "I set the variable horrible to $horrible"; # record in the log file
source horrible.tcl
That example has five commands: two set commands, a putlog command, a # command, and a source command, with 2, 2, 1, 5, and 1 arguments, respectively.

Finally, a command can go beyond one line, ending the first line of it with an open brace: {
In that case, the command is not deemed to have ended until a corresponding closing brace } is encountered, that is at the end of a line, or followed by a semi-colon. For example:

bind pubm - moron saidmoron
proc saidmoron { nick host handle chan text} {
    if { $nick == "Pulse" } {
        puthelp "PRIVMSG $chan :Pulse is the idiot."
    } else {
        puthelp "PRIVMSG $chan :Be nice, $nick"
In that example, there are two commands, namely bind and proc. The bind has four arguments, whereas the proc has only three. Notice how braces {} have been used to group five things together into the second argument of the proc command, and braces have been used again to group together a lot of things into the third argument. Moreover, the opening brace of that third argument ends the first line of the proc command. Now, the proc command expects its third argument to be a bunch of TCL commands -- essentially a whole TCL script. Let's look again at that third argument:
    if { $nick == "Pulse" } {
        puthelp "PRIVMSG $chan :Pulse is the idiot."
    } else {
        puthelp "PRIVMSG $chan :Be nice, $nick"
This third argument turns out in this case to consist of ONE command, namely an if command. That command has four arguments, of which only the third, namely else, is not enclosed in braces.

All of the above may seem rather trite at first glance. But it is CRUCIAL to think always if the code you write is consistent with the ideas discussed above. As a prime example of how crucial this is, consider that last example, where we discussed the third argument of the proc command. Suppose we had written it as follows:

    if { $nick == "Pulse" } {
        puthelp "PRIVMSG $chan :Pulse is the idiot."
    }     else {
        puthelp "PRIVMSG $chan :Be nice, $nick"
Doing it that way, we no longer have one if command with four arguments. Instead, we would have one if command with two arguments, and one else command with one argument. Since there is no such thing as an else command in TCL, that last version would produce an error, and the script would not work.


Consider the following TCL script:

set approvalfile "~/txt/approval.txt"
# maintaining the database
bind pub m|j approve approvaledit
bind msg m|j approve approvaleditmsg
proc approvaleditmsg { nick host handle text } {
    approvaledit $nick $host $handle "none" $text
proc approvaledit { nick host handle chan text } {
    global approvalfile
    if { $text == "" } { 
        puthelp "NOTICE $nick :Syntax: approve <information>"
        return 0
    set fp [open $approvalfile a]
    puts $fp $text
    close $fp
    puthelp "NOTICE $nick :Added \002$text\002 to the database"
    return 0
bind pub f approval approval
proc approval { nick host handle chan text } {
    global approvalfile
    searchfile 1 $nick $chan $approvalfile $text
putlog "Loaded approval Version 1.1, by terri{N}, for BotService"

For the above script:

  1. What is the name of the first command in the script?
  2. How many parameters does that first command have?
  3. List the rest of the commands in the script, along with how many arguments each has.
  4. List the names of the commands and how many arguments each has, that appear in the third argument of the second proc command.
  5. In the third proc command, in its third argument, the second command appearing there has what name and how many arguments?



  1. set
  2. 2
  3. # (3), bind (4), bind (4), proc (3), proc (3), bind (4), proc (3), putlog (1)
  4. global (1), if (2), set (2), puts (2), close (1), puthelp (1), return (1)
  5. searchfile (5)

©1998 - 2005 BotService