Scripts for Baxter can be written in any programming language that runs in BeOS. From programming languages like C or C++ to perl, python, tcl, and bash shell scripts, all a program has to do to work with Baxter is be able to read the arguments passed to it, parse them, and print out responses. When Baxter starts up each script placed in the "Scripts" sub-directory of the "Baxter" directory is executed twice.

The first time it is executed it is passed a single argument: user_commands. The next time Baxter executes the script it is executed with the command server_messages. If a script wants to be called when the user types a specific command, or when a specific server message is received from the server, the commands or messages should be printed out to standard output. For example, if a bash shell script wants to be called when the user types /foo and when the user types /bar the script might look something like this:


#!/bin/sh
if [ "$1" = "user_commands" ]   # Called when Baxter starts to find out what
        then echo "/foo"       # user commands this script handles
	echo "/bar"
fi

All the script does is check if the first argument is received was equal to "user_commands". If it was, the script prints /foo and /bar to standard output. "server_messages" work in exactly the same way:


#!/bin/sh
if [ "$1" = "server_messages" ]       # Find out what server messages this
        then echo "JOIN"                # script handles
	echo "PART"
fi

This script tells Baxter it would like to be notified of JOIN messages and PART messages. Consult the documentation of the specific language you would like to write your scripts in. In C/C++ doing a strcmp on argv[1] should work fine. You're on your own for perl, python, etc.

Now that Baxter knows what user commands and server messages your script wants to be notified of you'll need to add code to handle the user command and server message. When the user types /foo Baxter will execute your script as follows:

script.sh user_command nickname viewname selected_users user_entry

  • Argument 1: user_command is simply the string user_command
  • Argument 2: nickname is the user's nickname
  • Argument 3: viewname is the name of view from which the user executed the command
  • Argument 4: selected_users is the selected users all as one argument separated by spaces. If your script executes something on the selected users, make sure users are selected first.
  • Argument 5, 6, 7... : user_entry is whatever the user typed. If the user typed "/foo #beos tigers and lions and bears oh my!" the argument 5 will be "foo" argument 6 will be "#beos" argument 7 will be "tigers", and so on.

    Useful Commands: Use /echo to tell the user something. /run and /rrun may also prove useful. /run runs a command and echos its output to the user. /rrun runs a command and echos its output to everyone (if the user is in a channel).

    Server Messages

    If your script is set to be notified of JOINs, for example, when Baxter receives a JOIN from the server your script will be executed as follows:

    script.sh server_message message

  • Argument 1: server_message is the string server_message
  • Argument 2, 3, 4... : message can be any number of arguments. If the server sends a message like this:

    :Nick^!ident@www.host.com PRIVMSG #beos :a b c

    Argument 2 will be ":Nick^!ident@www.host.com" argument 3 will be "PRIVMSG" and so on.

    If you don't want Baxter to continue the handling of the server message you just received, the first line you print out should be "DNC", short for do not continue. In bash this is as simple as:

    echo "DNC"