[TASK] Added a WrongDatatypeException [TASK] Started to implement the ProtocolHandler in a different way. [TASK] Started to put buffers into the ProtocolHandler. [!!!] Committing broken code.
		
			
				
	
	
		
			87 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * IrcClient class that contains all the Plugins
 | |
|  * @author jpt
 | |
|  * @package Client
 | |
|  * @depends Client_AbstractClient
 | |
|  */
 | |
| class Client_IrcClient extends Client_AbstractClient {
 | |
| 
 | |
| 	protected $got_001;
 | |
| 	protected $joined;
 | |
| 	protected $authed;
 | |
| 	protected $nick;
 | |
| 	protected $channels;
 | |
| 	protected $lines;
 | |
| 
 | |
| 	/**
 | |
| 	 * Default constructor.
 | |
| 	 * @return void
 | |
| 	 */
 | |
| 	function __construct() {
 | |
| 		$this->nick = "Serena";
 | |
| 		$this->channels = array();
 | |
| 		$this->resetConnectionStatus();
 | |
| 	}
 | |
| 
 | |
| 	/**
 | |
| 	 * Will reset the clients internal variables concerning the connection status.
 | |
| 	 * @return void
 | |
| 	 */
 | |
| 	public function resetConnectionStatus() {
 | |
| 		$this->lines = 0;
 | |
| 		$this->got_001 = FALSE;
 | |
| 		$this->joined = FALSE;
 | |
| 		$this->authed = FALSE;
 | |
| 	}
 | |
| 
 | |
| 	/**
 | |
| 	 * Processes the resulting ContentObject from a ProtocolHandler.
 | |
| 	 * Does all the hard work.
 | |
| 	 * @param string $data
 | |
| 	 * @return string
 | |
| 	 */
 | |
| 	public function processContentObject($contentObject) {
 | |
| 		$data = $contentObject->rawData;
 | |
| 		echo "[RECV] ".$data;
 | |
| 		$this->clientManager->sendToGroup("srv", "[#".$this->ID."] ".$data."\r\n\r\n");
 | |
| 
 | |
| 		$return = "";
 | |
| 
 | |
| 		if(strpos($data, "PING :") !== FALSE) $return .= str_replace("PING", "PONG", $data);
 | |
| 
 | |
| 		if(preg_match("/001/", $data)) $this->got_001 = TRUE;
 | |
| 		$this->lines++;
 | |
| 
 | |
| 		if(!$this->authed && $this->lines > 1) {
 | |
| 			$return .= "USER as as as :Asdfg\r\nNICK :" . $this->nick . "\r\n";
 | |
| 			$this->authed = TRUE;
 | |
| 		}
 | |
| 
 | |
| 		if($this->got_001 && !$this->joined) {
 | |
| 			$this->joined = TRUE;
 | |
| 			foreach($this->channels AS $channel) $return .= "JOIN " . $channel . "\r\n";
 | |
| 		}
 | |
| 
 | |
| 		if(strpos($data, "hau ab") !== FALSE) {
 | |
| 			$return .= "PRIVMSG ".$this->channels[0]." :roger that :D\r\n";
 | |
| 			$return .= "QUIT :lol\r\n";
 | |
| 		}
 | |
| 
 | |
| 		//if($return !== "") echo "[SEND] ".$return;
 | |
| 		return $return;
 | |
| 	}
 | |
| 
 | |
| 	/**
 | |
| 	 * Loads the given configuration.
 | |
| 	 * @param array $config
 | |
| 	 * @return void
 | |
| 	 */
 | |
| 	public function loadConfig($config) {
 | |
| 		$this->nick = $config["nick"];
 | |
| 		$this->channels = $config["channels"];
 | |
| 		$this->userident = $config["userident"];
 | |
| 	}
 | |
| 
 | |
| }
 | |
| ?>
 |