config['serv'] = "irc.HackersFoundation.org"; $this->config['port'] = 6667; $this->config['nick'] = "WCBot"; $this->config['user'] = "WarpedCoders.org IRC Bot By SkareCrow"; $this->config['chan'] = "#HBH"; $this->config['inch'] = 0; } function connect() { echo ">> Attempting to connect to {$this->config['serv']} on port {$this->config['port']}\n"; $this->con['socket'] = fsockopen($this->config['serv'], $this->config['port']); if (!$this->con['socket']) { echo ">> There was an error connecting to {$this->config['serv']} on port {$this->config['port']}\n"; } else { $this->sendCMD("USER {$this->config['nick']}{$this->config['user']} :{$this->config['user']}"); $this->sendCMD("NICK {$this->config['nick']}"); $this->sendCMD("JOIN {$this->config['chan']}"); while (!feof($this->con['socket'])) { $this->con['buffer'] = trim(fgets($this->con['socket'], 4096)); $this->outPut($this->con['buffer']); if(substr($this->con['buffer'], 0, 6) == "PING :") { $this->sendCMD('PONG :'.substr($this->con['buffer'], 6)); if ($this->config['inch'] == 0) { $this->sendCMD("JOIN {$this->config['chan']}"); $this->config['inch'] = 1; } } } } } function sendCMD($cmd) { fputs($this->con['socket'], "{$cmd}\n"); echo date("\[H:i:s\]")." > {$cmd}\n"; } function outPut($in) { echo date("\[H:i:s\]")." < {$in}\n"; } } ?>