コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
ファイル: ChannelManager.php プロジェクト: nask0/Wild-IRC-Bot
 /**
  * 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);
 }
コード例 #3
0
ファイル: ChannelAdmin.php プロジェクト: nask0/Wild-IRC-Bot
 /**
  * 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;
 }
コード例 #4
0
 /**
  * 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)));
 }