<?php // 1:08pm - 1:42pm $githubFeed = (object) array('name' => 'ZaneA', 'repo' => 'ProtoIRC', 'branch' => 'master'); require '../protoirc.php'; $irc = new ProtoIRC('Githubbot@127.0.0.1:6667/Bottest', function ($irc) { $irc->send('#Bottest', 'Githubbot reportin\' in!'); }); $irc->msg('/^!name (.*)/', function ($irc, $nick, $channel, $name) use(&$githubFeed) { $irc->send($channel, "Setting name to \"{$name}\".."); $githubFeed->name = $name; }); $irc->msg('/^!repo (.*)/', function ($irc, $nick, $channel, $repo) use(&$githubFeed) { $irc->send($channel, "Setting repository to \"{$repo}\".."); $githubFeed->repo = $repo; }); $irc->msg('/^!branch (.*)/', function ($irc, $nick, $channel, $branch) use(&$githubFeed) { $irc->send($channel, "Setting branch to \"{$branch}\".."); $githubFeed->branch = $branch; }); $irc->msg('/^!latest/', function ($irc, $nick, $channel) use($githubFeed) { $irc->send($channel, 'Please wait..'); $irc->async(function ($irc) use($githubFeed, $channel) { $feed = @file_get_contents("https://github.com/api/v2/json/commits/list/{$githubFeed->name}/{$githubFeed->repo}/{$githubFeed->branch}"); if (!empty($feed)) { $json = json_decode($feed); for ($i = 0; $i < 3; $i++) { if (isset($json->commits[$i])) { $commit = $json->commits[$i]; $irc->send($channel, "{$commit->id}: {$commit->message}"); }
<?php // // Sample ProtoIRC Client/Bot // Author: Zane Ashby // require 'protoirc.php'; // Create IRC Class $irc = new ProtoIRC('ProtoBot@10.1.1.9:6667/Bottest', function ($irc) { $irc->notice('#Bottest :Hey there!')->send('#Bottest', "Hey there!"); }); // Include addons foreach (glob('addons/*.php') as $addon) { include $addon; } // Send raw IRC data by typing "/quote SOME DATA TO SEND" $irc->stdin('/^\\/(quote|raw) (.*)/', function ($irc, $command, $data) { $irc->send($data); }); // Execute command by typing "/exec command" and send output to current channel $irc->stdin('/^\\/exec (.*)/', function ($irc, $args) { exec($args, $output); $irc->send($irc->last, $output); }); // Send to channel by typing "#channel, message" $irc->stdin('/^([#\\-[:alnum:]]*), (.*)/', function ($irc, $channel, $msg) { $irc->send("{$channel}", $msg); }); // Catch-all: Send to default channel $irc->stdin('/(.*)/', function ($irc, $msg) { $irc->send($irc->last, $msg);