public function message($from, $text) { // TODO: No external messages flag: +n // TODO: Modes +mMbn // Announce the message foreach ($this->clients as &$client) { if ($client == $from) { continue; } // Don't send it to the person who sent it (or the IRC client will echo it twice) $client->write(IRC::sprintf(IRC::Message, $from, $this->name, $text)); } }
function cmd_mode($client, $argv) { $name = $argv[0]; $set = isset($argv[1]) ? implode(' ', array_slice($argv, 1)) : false; if (Channel::is_valid($name)) { // Valid channel name if (($channel = Channel::find($name)) === false) { // Channel doesn't exist. $client->write(IRC::sprintf(IRC::NoSuchNickChannel, &$client, $name)); return; } if ($set === false) { // Not setting anything. // Modes $client->write(IRC::sprintf(IRC::ChannelModes, &$client, $name, $channel->modes->make_string())); // Creation time $client->write(IRC::sprintf(IRC::ChannelCreated, &$client, $name, $channel->created)); } else { // TODO: Check for mode +o, etc, before allowing this. $channel->modes->mode($set); } return; } // Treat as a PM if (($user = Client::find_by_nick($name)) === false) { // Couldn't find a channel or user under this name $client->write(IRC::sprintf(IRC::NoSuchNickChannel, &$client, $name)); } else { // Found a user // TODO: User modes (oper only?) } }
public function init() { if ($this->nick === false || $this->user === false) { return false; } $this->registered = true; $this->write(IRC::sprintf(IRC::Connect(), &$this)); return true; }
function cmd_mem($client, $argv) { $mem = mod_mem::format_bytes(memory_get_usage(true)); $client->write(IRC::sprintf(mod_mem::MemoryUsage, $mem)); }