2010-11-21 23:48:11 +01:00
|
|
|
<?php
|
2011-12-04 14:31:18 +01:00
|
|
|
namespace JPT\IrcClient;
|
|
|
|
|
2010-11-21 23:48:11 +01:00
|
|
|
/**
|
2011-12-04 14:31:18 +01:00
|
|
|
* BotClient class that handles the controls or whatever...edit this later...
|
|
|
|
*
|
2010-11-21 23:48:11 +01:00
|
|
|
* @author jpt
|
|
|
|
* @package Client
|
2011-12-04 14:31:18 +01:00
|
|
|
* @depends \JPT\SocketFramework\Client\AbstractClientDispatcher
|
2010-11-21 23:48:11 +01:00
|
|
|
*/
|
2011-12-04 14:31:18 +01:00
|
|
|
class BotClientDispatcher extends \JPT\SocketFramework\Client\AbstractClientDispatcher {
|
2010-11-21 23:48:11 +01:00
|
|
|
|
|
|
|
/**
|
2011-12-04 14:31:18 +01:00
|
|
|
* 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
|
2010-11-21 23:48:11 +01:00
|
|
|
*/
|
2011-12-04 14:31:18 +01:00
|
|
|
public function processRawData($rawData) {
|
2010-11-28 03:45:25 +01:00
|
|
|
$return = "";
|
2011-06-26 00:13:53 +02:00
|
|
|
|
|
|
|
if(trim($rawData) === "list") {
|
2011-12-04 14:31:18 +01:00
|
|
|
$return = print_r(array(
|
|
|
|
"IDs" => $this->clientManager->getIDs(),
|
|
|
|
"Groups" => $this->clientManager->getGroups()
|
|
|
|
), TRUE);
|
2011-06-26 00:13:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(strpos($rawData, "-") !== FALSE ) {
|
|
|
|
$data = explode("-", $rawData, 2);
|
2010-11-21 23:48:11 +01:00
|
|
|
$this->clientManager->sendToID((int) $data[0], $data[1]."\r\n");
|
|
|
|
$return = print_r($data, TRUE);
|
|
|
|
}
|
|
|
|
|
2011-06-26 00:13:53 +02:00
|
|
|
if(strpos($rawData, "+") !== FALSE ) {
|
|
|
|
$data = explode("+", $rawData, 2);
|
2010-11-21 23:48:11 +01:00
|
|
|
$this->clientManager->sendToGroup($data[0], $data[1]."\r\n");
|
|
|
|
$return = print_r($data, TRUE);
|
|
|
|
}
|
|
|
|
|
2010-12-08 17:47:04 +01:00
|
|
|
//TODO: implement this correctly
|
2011-06-26 00:13:53 +02:00
|
|
|
$return = str_replace("\n", "\r\n", $return);
|
2011-12-04 14:31:18 +01:00
|
|
|
return $return;
|
2010-11-21 23:48:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads the given configuration.
|
|
|
|
* @param array $config
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function loadConfig($config) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|