/** * The Say command. * @param CommandEvent $e The data received. */ public function sayCommand($e) { if (empty($e->getParams())) { return; } if (Validation::isChannel($e->getParams()[0])) { $args = $e->getParams(); $to = array_shift($args); $message = implode(' ', $args); } else { $to = $e->getMessage()->getTargets(); $message = implode(' ', $e->getParams()); } if ($to === null) { return; } $this->bot->say($to, $message); }
/** * Join a channel. * @param string $channel The channel name. */ public function joinChannel($channel) { if (empty($channel) || !Validation::isChannel($channel)) { return; } $this->bot->sendData('JOIN ' . $channel); }
/** * Try to get a channel out of the gathered data. * @param CommandEvent $e The last data received. * @return false|string False on failure, channel as string on success. */ public function parseChannel($e) { if (empty($e->getParams())) { return false; } $parts = $e->getParams(); if (Validation::isChannel($parts[0])) { $chan = array_shift($parts); } else { $chan = $e->getMessage()->getTargets(); } if ($chan === null) { return false; } return $chan; }
/** * Join a channel. * * @param string|string[] $channel The channel name(s). */ public function joinChannel($channel) { if (!is_array($channel)) { $channel = [$channel]; } foreach ($channel as $id => $chan) { if (empty($chan) || !Validation::isChannel($chan)) { unset($channel[$id]); } } $this->api->getIrcConnection()->write($this->api->getGenerator()->ircJoin(implode(',', $channel))); }