示例#1
0
文件: client.php 项目: ZaneA/ProtoIRC
// 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);
});
// Catch outgoing messages and print them
$irc->out('/^PRIVMSG (.*) :(.*)/', function ($irc, $channel, $msg) {
    $irc->stdout("{$irc->ansi->_black}({$channel}.{$irc->ansi->_blue}{$irc->nick}{$irc->ansi->_black})> {$irc->ansi->_white}{$msg}\n");
});
// Display the topic when joining a channel
$irc->in('/^:.* 332 .* (.*) :(.*)/', function ($irc, $channel, $topic) {
    $irc->stdout("The topic of {$channel} is {$topic}\n", '_brown');
});
// Someone is joining or parting
$irc->in('/^:(.*)!.* (JOIN|PART) :?(.*)/', function ($irc, $nick, $cmd, $channel) {
    if ($cmd == 'JOIN') {
        $irc->stdout(">> {$nick} has joined {$channel}\n", '_green');
    } else {
        $irc->stdout("<< {$nick} has left {$channel}\n", '_red');
    }
});
// Someone has messaged a channel or PM'd us, so print it
$irc->in('/^:(.*)!.* PRIVMSG (.*) :(.*)/', function ($irc, $nick, $channel, $msg) {