WildBillBot is my Internet Relay Chat bot. Initially started for fun in 2003, this project of mine has evolved from being a crude outlet of entertainment and annoyance to being a serious project that became what is perhaps one of the most functional IRC bots ever. As of version 4, it is written in PHP 5 and is (still) backed by Net_SmartIRC. Designed in a modular fashion, WildBillBot itself is intended to be a framework enabling the rapid development of complex bots with highly friendly user interfaces.
Introduction
History
- Versions 1 and 2
-
The initial versions of WildBillBot were the most crude. Loaded with annoying features, such as profanity alerts, greet messages and "You said my name" responses, these versions followed the simple nature of the SmartIRC example scripts: a single bot object with methods called by SmartIRC regex matches. It included attempts at some more intricate functionalities I wished to incorporate, such as command toggling, but due to the structure and my ignorance of OOP, the code was heavily redundant.
- Version 3
-
This version of WildBillBot saw the advancement of the bot to a more functional structure and established the underlying principles of its design today. Instead of its functions being hardcoded into a single script, it kept a master list of scripts to include when necessary. It split these up by message type (such as channel, query, join, part, and so on) and allowed "commands," which were run when a message matches a certain criteria, and "processes," which were run unconditionally each time a message of the relevant type was received. This structure was quite beneficial and allowed for a more advanced bot to be written, but still did little to ease the development process for features.
- Version 4
-
Started in late 2006, this version of WildBillBot is the truly complete rewrite. Designed to be self-maintaining as possible, it uses an object-oriented approach to more cleanly follow in the footsteps of its predecessor. In and of itself, it contains only developmental and governmental features; all user end features are established by modules, which are objects themselves that can be loaded and removed while the bot itself is still connected to the IRC server.
Features
- Modular approach to feature design that handles (optionally)
- Channel commands
- Query commands
- Channel processes
- Channel notice processes
- Query processes
- Join processes
- Part processes
- Kick processes
- Quit processes
- Nickchange processes
- Channel modechange processes
- A timer
- Bot's outgoing channel messages
- Bot's outgoing channel notices
- Bot's outgoing queries
- Reloadable and unloadable modules
- Permission system allowing bans, a level for each channel rank (voice, op, etc), admins, and owners
- Disabling of the bot and its commands globally and in channels/query
- Restriction of command usage to X times per Y seconds
- Logging of useful information about users, such as hostnames and recent actions
- Automatic regular backup and restoration of temporary bot and module data
Modules
WildBillBot modules are PHP classes which extend the core WildBillBotModule class. This design provides the module author with all of the numerous useful methods contained in the WildBillBot and WildBillBot module classes. Because WildBillBot interprets the purpose and design of each module by the values and existence of a few properties and methods, writing complex WildBillBot modules is easy to do.
As an example, let's take a not-so-simple Hello World module:
<?php
class Hello extends WildBillBotModule {
var $title = 'Hello World';
var $author = 'Wild Bill <http://wildbill.purezc.com/>';
var $version = '1.1';
var $description = 'A test WildBillBot module.';
var $command = 'hello';
var $access_channel = WBB_CHAN1;
var $limit_user = '5 60';
var $limit_userchannel = '1 60';
var $limit_userquery = '1 60';
var $limit_channel = '5 60';
var $limit_query = '10 60';
var $limit_global = '100 600';
var $args_max = 0;
var $help = array(
'<B>Syntax:<B> <P>hello',
'Says Hello World to you!'
);
var $timer_interval = 3600;
/*
* Channel command handler
*/
function _command_channel(&$irc, &$data, &$wbb) {
$this->_channel_out('Hello World, '.$data->nick.'!');
}
/*
* Query command handler
*/
function _command_query(&$irc, &$data, &$wbb) {
$this->_user_out('Hello World, '.$data->nick.'!');
}
/*
* Timer
*/
function _timer(&$irc, &$wbb) {
if(!($wbb->disabled() || $this->_disabled()))
foreach($irc->channel as $channel)
if(!($wbb->disabled($channel->name) || $this->_disabled($channel->name))
$this->_privmsg($channel->name, 'Hello World, '.$channel->name.'!');
}
}
?>
This short module does many things:
- Creates the channel and query command "hello" which says "Hello World" to the person who calls it
- Restricts the channel command to users who have voice access
- Limits command usage
- A user may use it five times per minute
- A user may use it one time per minute in a single channel or by query
- A channel may use it five times per minute
- Spanning all users, it may be used ten times per minute by query
- Globally (via channel and query by all users), it may be used 100 times every ten minutes
- Restricts the number of arguments to none, thereby returning a syntax error if any are passed
- Establishes command documentation that can be read by the standard WildBillBot help module
- Creates a timer, run once per hour, which says "Hello World" to every channel WildBillBot has joined
- If WildBillBot is not disabled globally
- If the command "hello" is not disabled globally
- If WildBillBot is not disabled for that channel
- If the command "hello" is not disabled for that channel
This module is only a tiny sample of the vast functionality that WildBillBot provides for complex module development.



