PHP
Class ViiIrcBot {
protected $BotSocket;
protected $BotConfig;
protected $BotData;
public function __construct () {
$this->BotConfig = array(
/**
* Bot configuration for information
*/
'nickname' => 'ViiBot2',
'realname' => 'Vii personal bot',
'ident' => 'ViiBot',
/**
* Bot server configration
*/
'hostname' => 0,
'server' => 'ogn1.ogamenet.net',
'port' => 6667,
/**
* Bot channel configration
*/
'channel' => array('#Vii')
);
/**
* Prepare for bot connection
*/
if(!$this->ConnectViiBot()) {
die('Connection failed.');
}
else {
$this->ConnectToIrc();
$this->BotMainLoop();
}
}
protected function ConnectViiBot() {
/**
* Create a socket for bot connection
*/
$this->BotSocket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
if (!$this->BotSocket) {
return false;
}
/**
* Bind the socket to make it irc'able
*/
if(!socket_bind($this->BotSocket, $this->BotConfig['hostname'])) {
return false;
}
if(!socket_connect($this->BotSocket, $this->BotConfig['server'], $this->BotConfig['port'])) {
return false;
}
/**
* Return positive result
*/
return $this->BotSocket;
}
protected function ConnectToIrc () {
/**
* Utilize connection
*/
$this->RawWrite('USER ' . $this->BotConfig['ident']. ' ' . $this->BotConfig['hostname'] . ' ' . $this->BotConfig['server'] . ' :'. $this->BotConfig['realname']);
/**
* Define bot nickname to use
* on the server
*/
$this->RawWrite('NICK ' . $this->BotConfig['nickname']);
return true;
}
protected function RawWrite ($Parameter) {
/**
* Write raw data to server
*/
echo $Parameter;
if(!socket_write($this->BotSocket, $Parameter . '\r\n')){
die('error!');
}
}
protected function BotMainLoop () {
$inKanaal = false;
while($data = socket_read($this->BotSocket,65000,PHP_NORMAL_READ)) {
if($data == "\n") continue;
if ($data = 'NOTICE AUTH :*** No ident response') {
$this->RawWrite('USER ' . $this->BotConfig['ident']. ' ' . $this->BotConfig['hostname'] . ' ' . $this->BotConfig['server'] . ' :'. $this->BotConfig['realname']);
}
$write = fopen('log.txt', 'w');
$writenow = fwrite($write, $data);
}
}
}
$ViiBot = new ViiIrcBot();
?>
Toon Meer
probleem is dat hij blijft haken op dat hij geen ident, toe krijgt gestuurd daar in tegen doe ik wel sturen met de "nick" en "user" writing...
op 1 of andere manier pakt hij die niet >_>
en btw let niet op de loop