Exemplo n.º 1
0
 /**
  * Reads from the XMPP Socket and writes to the IRC channel
  */
 private function attachSocketReadTimer()
 {
     /**
      * Read messages from the socket and write them to the channel
      *
      * @noinspection PhpParamsInspection
      */
     $this->client->addPeriodicTimer(1, function () {
         if (!$this->connected) {
             return;
         }
         $text = $this->xmppStream->read();
         if (!empty($text)) {
             $messageParts = explode(' ', $text);
             $nickName = str_replace(['<', '>'], '', $messageParts[0]);
             if ($nickName != $this->getContainer()->get('config')['xmpp']['nickname'] && $nickName != $this->getContainer()->get('config')['irc']['nickname']) {
                 $this->getContainer()->get('logger')->debug('Found a message in the XMPP socket. Writing it to the IRC channel');
                 $this->write->ircPrivmsg($this->getContainer()->get('config')['irc']['channel'], htmlspecialchars_decode($text));
             }
         }
     });
 }
Exemplo n.º 2
0
 /**
  * @param string $msg
  */
 public function send($msg)
 {
     $this->writeStream->ircPrivmsg($this->channel, $msg);
 }