示例#1
0
文件: client.php 项目: ZaneA/ProtoIRC
<?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);