Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- ini_set('display_errors', 'on');
- /* --- Varibles and Config Info --- */
- $config = array(
- 'server' => 'irc.toribash.com',
- 'port' => 6667,
- 'name' => 'Kozbot',
- 'nick' => 'Kozzy',
- 'pass' => 'koz',
- 'channel' => '#koz',
- 'channel2' => '#dat',
- 'logging' => false,
- 'warning' => false,
- );
- /* --- IRCBot Class --- */
- class IRCBot {
- //This is going to hold our TCP/IP connection
- var $socket;
- //This is going to hold all of the messages both server and client
- var $ex = array();
- //var $logging = true;
- /*
- Construct item, opens the server connection, logs the bot in
- @param array
- */
- function __construct($config)
- {
- $this->socket = fsockopen($config['server'], $config['port']);
- $this->login($config);
- $this->main($config);
- }
- /*
- Logs the bot in on the server
- @param array
- */
- function login($config)
- {
- $this->send_data('USER', $config['nick'].' KozEnko '.$config['nick'].' :'.$config['name']);
- $this->send_data('NICK', $config['nick']);
- $this->send_data('NICKSERV', 'identify pass');
- sleep(1);
- $this->join_channel($config['channel']);
- $this->join_channel($config['channel2']);
- if($config['logging']) {
- $date = date("n-j-y");
- $time = date('h:i:s A');
- $logfile = fopen("$date-log.html","a");
- fwrite($logfile,"<br/>**************** Logging Started at $time ****************<br/>");
- fclose($logfile);
- //Warn that logging has been enabled
- if($config['warning']) {
- $this->send_data('PRIVMSG '.$config['channel'].' :', "Chat Logging has been [Enabled]");
- }
- }
- }
- /*
- This is the workhorse function, grabs the data from the server and displays on the browser
- */
- function main($config)
- {
- $data = fgets($this->socket, 256);
- echo nl2br($data);
- flush();
- $this->ex = explode(' ', $data);
- if($this->ex[0] == 'PING')
- {
- $this->send_data('PONG', $this->ex[0]); //Plays ping-pong with the server to stay connected.
- }
- //Logs the chat
- if($config['logging'])
- {
- $logtxt = $this->filter_log($this->ex[1], $this->ex[2], $this->ex[0], $this->get_msg($this->ex)); //Gets human readable text from irc data
- if($logtxt != null) { //Writes to log if it is a message
- $date = date("n-j-y");
- $logfile = fopen("$date-log.html","a");
- fwrite($logfile,"$logtxt<br />");
- fclose($logfile);
- }
- }
- $command = str_replace(array(chr(10), chr(13)), '', $this->ex[3])." ".$this->ex[0];
- switch($command) {
- //enseñar
- case ':Kozzy= '.$this->ex[0]:
- $cmd = explode("Kozzy",$this->ex[0]);
- $cmd[0] = trim($nick[0], ":");
- //jour
- case ':!jour '.$this->ex[0]:
- $time = date('l jS \of F Y h:i:s A');
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$time);
- break;
- //hora
- case ':!hora '.$this->ex[0]:
- $time = date('h:i:s A');
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$time);
- break;
- //dia
- case ':!dia '.$this->ex[0]:
- $date = date("j-n-y");
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$date);
- break;
- //change nick
- case ':!nik :Koz!Koz@Enko.ar ':
- $nik = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $nik .= $this->ex[$i]." "; }
- $this->send_data('NICK '.$nik);
- break;
- //listacmd
- case ":!cmd ".$this->ex[0] :
- $nick = explode("!",$this->ex[0]);
- $nick[0] = trim($nick[0], ":");
- $this->send_data("PRIVMSG ".$nick[0]. " !say [msg] - !me [msg] - !sayxquery [msg] - !sayxchan [msg]");
- $this->send_data("PRIVMSG ".$nick[0]. " WTF - back - chau - !frase - !hora - !dia - !jour - !version");
- $this->send_data("PRIVMSG ".$nick[0]. " !pegar - !mear - !matar - !cagar - !fag - !fail - !amar - !odiar - !morder - !epic - !suck - !lol - !cookie - !escupir - !chupar - !kick");
- $this->send_data("PRIVMSG ".$nick[0]. " !ocmd ");
- break;
- //cmds owner
- case ':!ocmd :Koz!Koz@Enko.ar':
- $nick = explode("!",$this->ex[0]);
- $nick[0] = trim($nick[0], ":");
- $this->send_data("PRIVMSG ".$nick[0]. " !cmd ");
- $this->send_data("PRIVMSG ".$nick[0]. " ident ");
- $this->send_data("PRIVMSG ".$nick[0]. " !join !restart !shutdown GTFO! ");
- $this->send_data("PRIVMSG ".$nick[0]. " !kick !ban !unban !bk !topic");
- $this->send_data("PRIVMSG ".$nick[0]. " !owner !deowner !deprotect !protect !op !deop !hop !dehop !voice !devoice !aown !mute !unmute");
- break;
- //names
- case ':!names :Koz!Koz@Enko.ar':
- $this->send_data('NAMES', $this->ex[2]);
- break;
- //invert
- case ':!invert '.$this->ex[0]:
- $message = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $message .= $this->ex[$i].""; }
- $messagge = strrev($message);
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$messagge);
- break;
- //random frases
- case ':!frase '.$this->ex[0]:
- $input = array ("you suck", "you are epic", "try again", "I am better than you", "Koz is better that you","master5000 is the overlord of wibbles etc");
- $rand_keys = array_rand($input, 1);
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION says ".$input[$rand_keys]);
- break;
- //servant
- case ':servant? '.$this->ex[0]:
- $this->send_data('PRIVMSG', $this->ex[2]." Yes sir?");
- break;
- //nickserv
- case ':ident :Koz!Koz@Enko.ar':
- $this->send_data('NICKSERV', 'identify poliupoliu');
- $this->send_data("PRIVMSG ".$this->ex[2], "Identified");
- break;
- //nick change
- case ':!nick :Koz!Koz@Enko.ar':
- $nik = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $nik .= $this->ex[$i]." "; }
- $this->send_data('NICK' .$nik);
- break;
- // say & me & sayxquery & sayxhan
- case ':!me '.$this->ex[0]:
- $me = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $me .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION ".$me);
- break;
- case ':!sayxchan':
- $message = "";
- for($i=5; $i <= (count($this->ex)); $i++)
- {
- $message .= $this->ex[$i]." ";
- }
- $this->send_data('PRIVMSG '.$this->ex[2].' :', $message);
- break;
- case ':!say '.$this->ex[0]:
- $message = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $message .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$message);
- break;
- case ':!sayxquery '.$this->ex[0]:
- $nick = explode("!",$this->ex[0]);
- $nick[0] = trim($nick[0], ":");
- $query = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $query .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG',$nick[0].' :'.$query);
- break;
- case ':!sayxchan '.$this->ex[0]:
- $message = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $message .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG ',$message);
- break;
- //version
- case ':!version '.$this->ex[0]:
- $version = " 2.8 beta 2";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$version);
- break;
- case ':VERSION '.$this->ex[0]:
- $version = " 2.8 beta 2";
- $this->send_data('TOPIC', $this->ex[2].' :'.$version);
- break;
- //topic
- case ':!topic '.$this->ex[0]:
- $topic = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $topic .= $this->ex[$i]." "; }
- $this->send_data('TOPIC', $this->ex[2].' :'.$topic);
- break;
- //epic commands
- case ':!kick '.$this->ex[0]:
- $kick = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $kick .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION kicks in the balls to".$kick);
- break;
- case ':!suck '.$this->ex[0]:
- $suck = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $suck .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." you suck ".$suck);
- break;
- case ':!cookie '.$this->ex[0]:
- $cookie = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $cookie .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION gives a cookie to ".$cookie);
- break;
- case ':!cagar '.$this->ex[0]:
- $cagar = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $cagar .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION se caga en ".$cagar);
- break;
- case ':!mear '.$this->ex[0]:
- $mear = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $mear .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION se hecha un cloro en la cara de ".$mear);
- break;
- case ':!pegar '.$this->ex[0]:
- $pegar = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $pegar .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION le pega en la cara a ".$pegar." tan fuerte que le rompe la nariz");
- break;
- case ':!matar '.$this->ex[0]:
- $matar = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $matar .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION le pega un tiro a ".$matar);
- break;
- case ':!odiar'.$this->ex[0]:
- $odiar = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $odiar .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION odia a ".$odiar);
- break;
- case ':!amar '.$this->ex[0]:
- $amar = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $amar .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION ama a ".$amar);
- break;
- case ':!fail '.$this->ex[0]:
- $fail = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $matar .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION eres un fail ".$fail);
- break;
- case ':!fag '.$this->ex[0]:
- $fag = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $fag .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION eres un puto fag ".$fag."!");
- break;
- case ':!morder '.$this->ex[0]:
- $morder = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $morder .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION le muerde el culo a ".$morder."!");
- break;
- case ':!epic '.$this->ex[0]:
- $epic = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $epic .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." eres epic ".$epic."!");
- break;
- case ':!lol '.$this->ex[0]:
- $lol = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $lol .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." se le rie en la cara a ".$lol."!");
- break;
- case ':!escupir '.$this->ex[0]:
- $esc = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $esc .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." :\x01ACTION le encaja un terrible garzo en la cara a ".$esc."!");
- break;
- case ':!chupar '.$this->ex[0]:
- $esc = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $esc .= $this->ex[$i]." "; }
- $this->send_data('PRIVMSG', $this->ex[2]." Hacelo vos!");
- break;
- //basics commands
- case ':Kozzy '.$this->ex[0]:
- $nick = explode("!",$this->ex[0]);
- $nick[0] = trim($nick[0], ":");
- $this->send_data('PRIVMSG', $this->ex[2]." que sucede ".$nick[0]);
- break;
- case ':WTF '.$this->ex[0]:
- $WTF = "Dunno";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$WTF);
- break;
- case ':Ping '.$this->ex[0]:
- $WTF = "Pong";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$WTF);
- break;
- case ':ping '.$this->ex[0]:
- $WTF = "Pong";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$WTF);
- break;
- case ':!putear '.$this->ex[0]:
- $putear = "La reconcha de la lora y la puta madre que te re mil re parió!";
- $puteo = "hijo de un trasatlantico lleno de travestis!";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$putear);
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$puteo);
- break;
- case ':back '.$this->ex[0]:
- $Back = "Puff! Cuanto tiempo! e.e";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$Back);
- break;
- case ':cya '.$this->ex[0]:
- $Cya = "Hasta luego!";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$Cya);
- break;
- //mute
- case ':!mute :Koz!Koz@Enko.ar':
- $m = "+m";
- $this->send_data('MODE ', $this->ex[2].' :'.$m);
- break;
- case ':!unmute :Koz!Koz@Enko.ar':
- $mm = "-m";
- $this->send_data('MODE ', $this->ex[2].' :'.$mm);
- break;
- // joins & quits
- case ':!join :Koz!Koz@Enko.ar':
- $this->join_channel($this->ex[4]);
- break;
- case ':!part :Koz!Koz@Enko.ar':
- $byee = "Cya guys!";
- $this->send_data('PART', $this->ex[2]);
- break;
- case ':!autodestruir :Koz!Koz@Enko.ar':
- $auto3 = "Auto destruyendo en 3";
- $auto2 = "Auto destruyendo en 2";
- $auto1 = "Auto destruyendo en 1";
- $auto0 = "Auto destruyendo en 0";
- $boom = "BOOM";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$auto3);
- sleep(1);
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$auto2);
- sleep(1);
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$auto1);
- sleep(1);
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$auto0);
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$aboom);
- $this->send_data('PART', $this->ex[2]. " x|");
- break;
- case ':GTFO! :Koz!Koz@Enko.ar':
- $shutup = "Ok Koz =(";
- $this->send_data('PRIVMSG', $this->ex[2].' :'.$shutup);
- $this->send_data('QUIT', ' =,(');
- break;
- case ':!restart :Koz!Koz@Enko.ar':
- if($config['warning']) {
- $this->send_data('PRIVMSG '.$config['channel'].' :', "Chat Logging has been [Disabled]");
- }
- echo "<meta http-equiv=\"refresh\" content=\"3\">";
- if($config['logging']) {
- $date = date("n-j-y");
- $time = date('h:i:s A');
- $logfile = fopen("$date-log.html","a");
- fwrite($logfile,"<br/>**************** Logging Ended at $time ****************<br/>");
- fclose($logfile);
- }
- exit;
- case ':!shutdown :Koz!Koz@Enko.ar':
- if($config['warning']) {
- $this->send_data('PRIVMSG '.$config['channel'].' :', "Chat Logging has been [Disabled]");
- }
- if($config['logging']) {
- $date = date("n-j-y");
- $time = date('h:i:s A');
- $logfile = fopen("$date-log.html","a");
- fwrite($logfile,"<br/>**************** Logging Ended at $time ****************<br/>");
- fclose($logfile);
- }
- exit;
- //register chanel
- case ':!register :Koz!Koz@Enko.ar':
- $pass = "poliupoliu kozzy";
- $this->send_data('CHANSERV register', $this->ex[2]." ".$pass);
- break;
- //kick
- case ':!kickk :Koz!Koz@Enko.ar':
- $this->kick_user($this->ex[2], $this->ex[4]);
- break;
- //ban
- case ':!ban :Koz!Koz@Enko.ar':
- $this->ban_user($this->ex[2], $this->ex[4]);
- break;
- case ':!unban :Koz!Koz@Enko.ar':
- $this->ban_user($this->ex[2], $this->ex[4], false);
- break;
- //kick ban
- case ':!bk :Koz!Koz@Enko.ar':
- $this->ban_user($this->ex[2], $this->ex[4]);
- $this->kick_user($this->ex[2], $this->ex[4]);
- break;
- //auto-owner
- case ':!aown :Koz!Koz@Enko.ar':
- $pass = "poliupoliu";
- $this->send_data('NICKSERV', 'identify poliupoliu');
- $this->send_data('CHANSERV', " Identify #koz ".$pass);
- sleep(1);
- $this->send_data('CHANSERV', " owner");
- break;
- //owner multi
- case ':!own :Koz!Koz@Enko.ar':
- $own = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $own .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." +qqqqqqqqqqqqqq ".$own);
- break;
- case ':!deown :Koz!Koz@Enko.ar':
- $own = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $own .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." -qqqqqqqqqqqqqq ".$own);
- break;
- //admin multi
- case ':!admin :Koz!Koz@Enko.ar':
- $adm = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $adm .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." +aaaaaaaaaaaaaa ".$adm);
- break;
- case ':!deop :Koz!Koz@Enko.ar':
- $adm = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $adm .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." -aaaaaaaaaaaaaa ".$adm);
- break;
- //op multi
- case ':!op :Koz!Koz@Enko.ar':
- $op = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $op .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." +ooooooooooooo ".$op);
- break;
- case ':!deop :Koz!Koz@Enko.ar':
- $op = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $op .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." -ooooooooooooo ".$op);
- break;
- //hop multi
- case ':!hop :Koz!Koz@Enko.ar':
- $hop = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $hop .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." +hhhhhhhhhhhh ".$hop);
- break;
- case ':!dehop :Koz!Koz@Enko.ar':
- $hop = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $hoc .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." -hhhhhhhhhhhh ".$hop);
- break;
- // voice multi
- case ':!voice :Koz!Koz@Enko.ar':
- $voc = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $voc .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." +vvvvvvvvvvv ".$voc);
- break;
- case ':!devoice :Koz!Koz@Enko.ar':
- $voc = "";
- for($i=4; $i <= (count($this->ex)); $i++) { $voc .= $this->ex[$i]." "; }
- $this->send_data('MODE', $this->ex[2]." -vvvvvvvvvvv ".$voc);
- break;
- //voice all
- }
- $this->main($config);
- }
- /* --- IRCBot Class's Functions --- */
- function filter_log($type, $chan, $nick, $msg) {
- $nick = ltrim($nick, ":");
- $nick = substr($nick, 0, strpos($nick, "!"));
- $msg = ltrim($msg, ":");
- if($type == "PRIVMSG") {
- return date("[H:i]")." <".$nick."> ".$msg;
- }
- return null ;
- }
- function get_msg($n) {
- $message = "";
- for($i=$n; $i <= (count($this->ex)); $i++) { $message .= $this->ex[$i]." "; }
- return $message;
- }
- function send_data($cmd, $msg = null) {
- if($msg != null) {
- fputs($this->socket, $cmd.' '.$msg."\r\n");
- echo '<strong>'.$cmd.' '.$msg.'</strong><br />';
- } else {
- fputs($this->socket, $cmd."\r\n");
- echo '<strong>'.$cmd.'</strong><br />';
- }
- }
- function join_channel($channel) {
- $this->send_data('JOIN', $channel);
- }
- function ban_user($chan = "#DAT", $user = "Koz", $ban = true) {
- if($ban) { $this->send_data('MODE', $chan.' +b '.$user);
- } else { $this->send_data('MODE', $chan.' -b '.$user); }
- }
- function kick_user($chan = "#DAT", $user = "Koz") {
- $this->send_data('KICK ' . $chan, $user);
- }
- function build($offset) {
- $out = "";
- for($i=($offset); $i<=(count($this->ex)-1); $i++) {
- $out = $out.$this->ex[$i]." ";
- }
- return $out;
- }
- }
- $bot = new IRCBot($config);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement