/** * @param $message * @return $this */ protected function sendToIrc($message) { if (!$this->irc) { $this->irc = new IrcConnection($this->config->getIrcConfig()); $this->irc->getEvent()->addListener('ping', array(new PingResponder(), 'onPing'))->addListener('433', array(new IrcEventListener(), 'NickAlreadyUse')); $this->irc->connect(); $start = time(); do { $data = $this->irc->irc_read(3); if ($data === false) { continue; } $this->irc->callListeners($data); } while (!$this->irc->feof() && ($data === false || $data['command'] != '001') && time() - $start < 5); if ($this->config->getNickServPassword()) { $this->irc->privmsg('NickServ', sprintf('IDENTIFY %s', $this->config->getNickServPassword())); sleep(1); // The time that the identification is treated by NickServ } if ($this->config->getJoin()) { $this->irc->join($this->config->getChannel(), $this->config->getPassword()); } } if ($this->config->getNotice()) { $this->irc->notice($this->config->getChannel(), $message); } else { $this->irc->privmsg($this->config->getChannel(), $message); } return $this; }