[TASK] Finalized modifications on ClientManager.
[TASK] Added support for further class paths to ClassLoader. [TASK] Started to implement the irc client dispatcher. (partially works now)
This commit is contained in:
@@ -1,42 +1,44 @@
|
||||
<?php
|
||||
namespace JPT\IrcClient;
|
||||
|
||||
/**
|
||||
* IrcClient class that contains all the Plugins
|
||||
* The ClientDispatcher for this IrcBot.
|
||||
*
|
||||
* @author jpt
|
||||
* @package Client
|
||||
* @depends Client_AbstractClient
|
||||
*/
|
||||
class Client_IrcClient extends Client_AbstractClient {
|
||||
|
||||
class ClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatcher {
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $joined;
|
||||
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $got001;
|
||||
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $authed;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $nick;
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $channels;
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $lines;
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* @return void
|
||||
@@ -46,7 +48,7 @@ class Client_IrcClient extends Client_AbstractClient {
|
||||
$this->channels = array();
|
||||
$this->resetConnectionStatus();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Will reset the clients internal variables concerning the connection status.
|
||||
* @return void
|
||||
@@ -57,7 +59,7 @@ class Client_IrcClient extends Client_AbstractClient {
|
||||
$this->joined = FALSE;
|
||||
$this->authed = FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function gets called every time, the connection is established.
|
||||
* This allows the client to send initial data.
|
||||
@@ -68,46 +70,45 @@ class Client_IrcClient extends Client_AbstractClient {
|
||||
$data = "USER poweruser as as :JPTs Bot\r\nNICK " . $this->nick . "\r\n";
|
||||
$this->authed = TRUE;
|
||||
}
|
||||
$this->protocolHandler->sendRaw($data);
|
||||
//$this->protocolHandler->sendRaw($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes the resulting ContentObject from a ProtocolHandler.
|
||||
* Does all the hard work.
|
||||
* @param string $data
|
||||
* @return void
|
||||
* Forwards incoming data to the ProtocolHandler
|
||||
* Let's the ProtocolHandler do all the work and forward its results to the Clients.
|
||||
* Return resulting raw data.
|
||||
*
|
||||
* @param string $rawData
|
||||
* @return string
|
||||
*/
|
||||
protected function processContentObject($contentObject) {
|
||||
$data = $contentObject->getRawData();
|
||||
//DEBUG
|
||||
var_dump($contentObject);
|
||||
public function processRawData($rawData) {
|
||||
$data = $rawData;
|
||||
var_dump($data);
|
||||
|
||||
//respond to pings
|
||||
if($contentObject->getCommand() === "PING") $this->protocolHandler->pong($contentObject->getParams());
|
||||
|
||||
|
||||
//respond to pings
|
||||
//if($contentObject->getCommand() === "PING") $this->protocolHandler->pong($contentObject->getParams());
|
||||
|
||||
$this->clientManager->sendToGroup("srv", "[#".$this->ID."] ".$data);
|
||||
|
||||
if($contentObject->getCommand() === "001") $this->got001 = TRUE;
|
||||
|
||||
|
||||
//if($contentObject->getCommand() === "001") $this->got001 = TRUE;
|
||||
|
||||
$return = "";
|
||||
|
||||
|
||||
$this->lines++;
|
||||
|
||||
|
||||
if(!$this->joined && $this->got001) {
|
||||
$this->joined = TRUE;
|
||||
foreach($this->channels AS $channel) $return .= "JOIN " . $channel . "\r\n";
|
||||
}
|
||||
|
||||
|
||||
if(strpos($data, "musdsdsafgagltivitamin") !== FALSE) {
|
||||
$return .= "PRIVMSG ".$this->channels[0]." :roger that :D\r\n";
|
||||
$return .= "QUIT :lol\r\n";
|
||||
}
|
||||
|
||||
//workaround. will be removed soon
|
||||
$this->protocolHandler->sendRaw($return);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads the given configuration.
|
||||
* @param array $config
|
||||
@@ -118,6 +119,6 @@ class Client_IrcClient extends Client_AbstractClient {
|
||||
$this->channels = $config["channels"];
|
||||
$this->userident = $config["userident"];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user