/** * 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); }
/** * The Part command. * @param CommandEvent $e The last data received. */ public function partCommand(CommandEvent $e) { // If no argument specified, attempt to leave the current channel. if (empty($e->getParams())) { $c = array($e->getMessage()->getChannel()); } else { $c = $e->getParams(); } foreach ($c as $chan) { $this->bot->sendData('PART ' . $chan); } }
/** * 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; }