Implementation
The implementation of the chat administration is designed to be quite similar to the main chat script. A bot is launched, which, with the help of phpIRC, logs into IRC and tries to register itself as IRC operator. Then it waits for further commands from a Web interface. These commands are issued like those in a database-backed RPC (remote procedure call). The bot will frequently query a table in the database that contains input commands for it. The commands are put into the database by the Web interface and consist of a function name, a session ID, and a parameter array. Whenever the bot finds a new command in the database, it executes it and writes the command results in an output table along with the session ID. Thus, the Web interface just has to write a command with a self-generated session ID and then only needs to wait until a result dataset with the same session ID pops up in the output table (see Figure 3.11).
This method allows flexible remote control over the bot.
Figure 3.11. Database-backed RPC control over the administration bot.