So I made a tiny and very hackable IRC bot/client base in PHP for rapid prototyping. Of course I threw it on GitHub. It makes heavy use of PHP >= 5.3 closure support as well as regular expressions for defining just about everything. Basic knowledge of the IRC protocol is recommended. You can find more information in the README file in the previous link.

Here is an example of what a minimal bot looks like:


$irc = new ProtoIRC('nick@hostname:6667', function ($irc) {
        // This code will run on connect
        $irc->send('JOIN #channel');

$irc->in('/^:(.*)!~.* PRIVMSG (.*) :!echo (.*)/', function ($irc, $nick, $channel, $args) {
        // Arguments are self documenting
        $irc->send($channel, "Echoing '{$args}' for you {$nick}", 'green');

// Also available is the ability to catch stdin, irc in, and irc out. Set up timers, and call functions asynchronously (fork/join).


(Maybe) Related posts: