Here is an example of what a minimal bot looks like:
- <?php
- require('protoirc.php');
- $irc = new ProtoIRC('hostname', 6667, 'NickName', 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.
- // This will run once, until disconnected
- $irc->go();
