ircbot/Classes/Client/IrcClient.php

80 lines
1.7 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->lines = 0;
$this->got_001 = FALSE;
$this->joined = FALSE;
$this->authed = FALSE;
}
/**
* Does all the hard work.
* @param string $data
* @return string
*/
public function processContentObject($contentObject) {
var_dump($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"];
}
}
?>