Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- error_reporting(E_ALL);
- ini_set('display_errors', '1');
- class draggy {
- var $telnet,$errno, $errmsg;
- var $canal, $botnick;
- function draggy($datos) {
- $this->login=$datos['login'];
- $this->pass=$datos['pass'];
- $this->server=$datos['ip'];
- $this->puerto=$datos['puerto'];
- }
- function sendtxt($str) {
- fputs($this->telnet, "$str\n");
- }
- function conectar() {
- $this->telnet = fsockopen($this->server,$this->puerto, $errnum, $errstr, 10);
- if (!$this->telnet) {
- echo "Error: $errstr";
- return(false);
- }
- $s = fgets($this->telnet, 4096);
- while ((strpos($s,"ickname")===false) && ($s!==false)) $s=fgets($this->telnet, 4096);
- if ($s===false) return(false);
- $this->sendtxt($this->login);
- while ((strpos($s,"assword")===false) && ($s!==false)) $s=fgets($this->telnet, 4096);
- if ($s===false) return(false);
- $this->sendtxt($this->pass);
- while (strpos($s,"joined")===false && ($s!==false)) $s=fgets($this->telnet, 4096);
- if ($s===false) return(false);
- $this->sendtxt(".console +mpjkco");
- set_socket_blocking($this->telnet,false);
- // $this->telnet = $telnet;
- return(true);
- }
- function desconectar() { $this->sendtxt(".quit"); fclose($this->telnet); }
- function msg($nick, $msg) { $this->sendtxt(".msg $nick $msg"); }
- function say($msg, $chan = "") { $this->sendtxt(".say $chan $msg"); }
- function cambiarcanal($chan) { $this->sendtxt(".console $chan"); }
- }
- $data['login'] = 'angelbroz';
- $data['pass'] = 'w3b0s';
- $data['puerto'] = '33340';
- $data['ip'] = 'localhost';
- $mybot = & new draggy($data);
- echo "Conectando con el servidor<br>";
- $mybot->conectar() or die("No me puedo conectar\n");
- $mybot->cambiarcanal('#ikimlinux');
- echo "Saying AngelBroz connected<br>";
- $mybot->say('AngelBroz connected','#ikimlinux');
- echo "Descoenctandose<br>";
- $mybot->desconectar();
- ?>
Add Comment
Please, Sign In to add comment