Source code raw phps
<?php
require_once 'modules/class.Module.php';
class Module_Protocol extends Module {
protected $_registered = false;
public function update(Observed $bot, $raw, $type) {
if (($type & Bot::U_STATUS) == Bot::U_STATUS && $raw == 'Reconnect') {
$this->_registered = false;
return Bot::E_CONTINUE;
}
if (($type & Bot::U_INPUT) != Bot::U_INPUT) {
return Bot::E_CONTINUE;
}
$raw_pieces = explode(' ', $raw);
// Register
if (isset($raw_pieces[0]) && $raw_pieces[0] == 'NOTICE' && !$this->_registered) {
$user = $bot->configs['username'] . " " . $bot->configs['hostname'] . " " . $bot->configs['servername'] . " :" . $bot->configs['realname'];
$bot->send("USER $user");
$bot->send("NICK " . $bot->configs['nickname']);
$this->_registered = true;
}
// Answer to PING
if (isset($raw_pieces[0]) && $raw_pieces[0] == 'PING') {
$raw[1] = 'O';
$bot->send($raw);
}
// Used nick
if (isset($raw_pieces[1]) && $raw_pieces[1] == '443') {
$bot->send("NICK " . $raw_pieces[3] . rand(1, 20));
}
return Bot::E_CONTINUE;
}
}
Comments
There is currently no comment here.