Exemplo n.º 1
0
Arquivo: bot.php Projeto: tseeker/LWB5
 private function createBot($bot)
 {
     $this->connectToDatabase($bot);
     $bot->socketClass = $this->socketClass;
     $bot->timerClass = new timers();
     $bot->parserClass = new parser();
     $bot->dccClass = new dcc();
     $bot->ircClass = new irc();
     $bot->ircClass->setConfig($bot->config, $bot->configFilename);
     $bot->ircClass->setSocketClass($this->socketClass);
     $bot->ircClass->setParserClass($bot->parserClass);
     $bot->ircClass->setDccClass($bot->dccClass);
     $bot->ircClass->setTimerClass($bot->timerClass);
     $bot->ircClass->setProcQueue($this->procQueue);
     $bot->dccClass->setSocketClass($this->socketClass);
     $bot->dccClass->setTimerClass($bot->timerClass);
     $bot->dccClass->setParserClass($bot->parserClass);
     $bot->dccClass->setProcQueue($this->procQueue);
     $bot->parserClass->setTimerClass($bot->timerClass);
     $bot->parserClass->setSocketClass($this->socketClass);
     $bot->parserClass->setDatabase($bot->db);
     $bot->timerClass->setIrcClass($bot->ircClass);
     $bot->timerClass->setSocketClass($this->socketClass);
     $bot->timerClass->setProcQueue($this->procQueue);
     $bot->parserClass->init();
     //Okay, this function adds the connect timer and starts up this bot class.
     $bot->ircClass->init();
     bot::createChannelArray($bot->ircClass);
 }
Exemplo n.º 2
0
 public function dcc_rehash($chat, $args)
 {
     $chat->dccSend("Rehashing main config file, please wait...");
     $currConfig = $this->ircClass->getClientConf();
     $newConfig = bot::parseConfig($this->ircClass->getConfigFilename());
     if ($newConfig == false) {
         $chat->dccSend("Could not find config file or IO error.");
         return;
     }
     $this->ircClass->setConfig($newConfig, $this->ircClass->getConfigFilename());
     if ($currConfig['nick'] != $newConfig['nick']) {
         $chat->dccSend("Changing nick...");
         $this->ircClass->changeNick($newConfig['nick']);
     }
     if ($currConfig['server'] != $newConfig['server']) {
         $chat->dccSend("Connecting to new server...");
         $this->ircClass->disconnect();
         $this->ircClass->reconnect();
     } else {
         if (isset($currConfig['channel'])) {
             if (!is_array($currConfig['channel'])) {
                 $currConfig['channel'] = array($currConfig['channel']);
             }
             if (!is_array($newConfig['channel'])) {
                 $newConfig['channel'] = array($newConfig['channel']);
             }
             foreach ($currConfig['channel'] as $chan) {
                 if (!in_array($chan, $newConfig['channel'])) {
                     $chan = trim($chan) . " ";
                     $chan = trim(substr($chan, 0, strpos($chan, chr(32)) + 1));
                     $this->ircClass->sendRaw("PART " . $chan);
                 }
             }
         }
     }
     $this->ircClass->purgeMaintainList();
     $chat->dccSend("Rehashing channel list...");
     bot::createChannelArray($this->ircClass);
     $chat->dccSend("Rehashing IP address...");
     if (isset($newConfig['natip'])) {
         if (isset($currConfig['natip'])) {
             if ($currConfig['natip'] != $newConfig['natip']) {
                 $this->ircClass->setClientIP($newConfig['natip']);
             }
         } else {
             $this->ircClass->setClientIP($newConfig['natip']);
         }
     } else {
         if ($this->ircClass->getStatusRaw() != STATUS_CONNECTED_REGISTERED) {
             $chat->dccSend("NOTICE: Cannot reset IP address unless connected to server. No change made.");
         } else {
             $this->ircClass->setClientIP();
         }
     }
     if (isset($newConfig['dccrangestart']) && $newConfig['dccrangestart'] != $currConfig['dccrangestart']) {
         $chat->dccSend("Updating TCP Range...");
         $this->socketClass->setTcpRange($newConfig['dccrangestart']);
     }
     if (isset($newConfig['logfile']) && $newConfig['logfile'] != $currConfig['logfile']) {
         $chat->dccSend("Changing log file...");
         $this->ircClass->closeLog();
     }
     if (isset($newConfig['functionfile'])) {
         if ($newConfig['functionfile'] != $currConfig['functionfile']) {
             $this->parserClass->loadFuncs($newConfig['functionfile']);
         }
     } else {
         $chat->dccSend("Fatal Error, functionfile directive not set.  The performance of this bot is no longer guaranteed (please restart and fix your error)");
         return;
     }
     $chat->dccSend("Main config rehash complete.");
 }