(Go Back)
ProtoIRC
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:
  1. <?php
  2. require('protoirc.php');
  3.  
  4. $irc = new ProtoIRC('hostname', 6667, 'NickName', function ($irc) {
  5.         // This code will run on connect
  6.         $irc->send('JOIN #channel');
  7. });
  8.  
  9. $irc->in('/^:(.*)!~.* PRIVMSG (.*) :!echo (.*)/', function ($irc, $nick, $channel, $args) {
  10.         // Arguments are self documenting
  11.         $irc->send($channel, "Echoing '{$args}' for you {$nick}", 'green');
  12. });
  13.  
  14. // Also available is the ability to catch stdin, irc in, and irc out. Set up timers, and call functions asynchronously.
  15.  
  16. // This will run once, until disconnected
  17. $irc->go();

blog comments powered by Disqus