addTimer((int)secs, [array([$object] or [(string)method])] or [(string)function], array([arguments for method]));
*/
function irc_highlight($string, $c=FALSE){
if(!$c) $c = array('function' => "\x0302", 'operator' => "\x0314", 'casts' => "\x0314", 'defining' => "\x02", 'data' => "\x0304", 'describing' => "\x0310", 'comments' => "\x0315", 'vars' => "\x0313");
if(!strstr("", $string)) $string = "";
$tokens = token_get_all($string);
$parser['function'] = array(T_REQUIRE_ONCE, T_REQUIRE, T_EVAL, T_INCLUDE_ONCE, T_INCLUDE, T_PRINT, T_EXIT, T_ECHO, T_UNSET, T_ISSET, T_EMPTY, T_HALT_COMPILER, T_LIST, T_ARRAY, T_STRING);
$parser['operator'] = array(T_LOGICAL_OR, T_LOGICAL_XOR, T_LOGICAL_AND, T_SR_EQUAL, T_SL_EQUAL, T_XOR_EQUAL, T_OR_EQUAL, T_AND_EQUAL, T_MOD_EQUAL, T_CONCAT_EQUAL, T_DIV_EQUAL, T_MUL_EQUAL, T_MINUS_EQUAL, T_PLUS_EQUAL, T_BOOLEAN_OR, T_BOOLEAN_AND, T_IS_NOT_IDENTICAL, T_IS_IDENTICAL, T_IS_NOT_EQUAL, T_IS_EQUAL, T_IS_GREATER_OR_EQUAL, T_IS_SMALLER_OR_EQUAL, T_SR, T_SL, T_INSTANCEOF, T_DEC, T_INC, T_OBJECT_OPERATOR, T_DOUBLE_ARROW, T_DOUBLE_COLON);
$parser['casts'] = array(T_UNSET_CAST, T_BOOL_CAST, T_OBJECT_CAST, T_ARRAY_CAST, T_STRING_CAST, T_DOUBLE_CAST, T_INT_CAST, T_STRING_VARNAME);
$parser['describing'] = array(T_CLONE, T_IF, T_ELSEIF, T_ELSE, T_ENDIF, T_DO, T_WHILE, T_ENDWHILE, T_FOR, T_ENDFOR, T_FOREACH, T_ENDFOREACH, T_DECLARE, T_ENDDECLARE, T_AS, T_SWITCH, T_ENDSWITCH, T_CASE, T_DEFAULT, T_BREAK, T_CONTINUE, T_RETURN, T_TRY, T_CATCH, T_THROW);
$parser['data'] = array(T_LNUMBER, T_DNUMBER, T_NUM_STRING, T_CHARACTER, T_BAD_CHARACTER, T_ENCAPSED_AND_WHITESPACE, T_CONSTANT_ENCAPSED_STRING, T_START_HEREDOC, T_END_HEREDOC);
$parser['defining'] = array(T_NEW, T_FUNCTION, T_CONST, T_GLOBAL, T_PUBLIC, T_PROTECTED, T_PRIVATE, T_FINAL, T_ABSTRACT, T_STATIC, T_VAR, T_CLASS, T_INTERFACE, T_EXTENDS, T_IMPLEMENTS, T_CLASS_C, T_METHOD_C, T_FUNC_C, T_LINE, T_FILE, T_USE);
$parser['comments'] = array(T_COMMENT, T_DOC_COMMENT);
$parser['vars'] = array(T_VARIABLE);
// $parser['misc'] = array(T_OPEN_TAG, OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_DOLLAR_OPEN_CURLY_BRACES); T_CURLY_OPEN);
$parser['disable'] = array(T_OPEN_TAG, OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_INLINE_HTML);
$ret = "";
foreach($tokens as $n => $token){
if(is_string($token)) $ret .= $token;
else{
$next = $tokens[$n+1];
foreach($parser as $type => $array){
if(in_array($token[0], $array)){
$co = $type;
}
}
if(!in_array($token[0], $parser['disable'])){
if($c[$co]){
$ret .= $c[$co].$token[1]."\x0F";
}else{
$ret .= $token[1];
}
}
$last = $token;
}
}
return $ret;
}
function truncate($string, $len){
for($x = 0; $x < $len; $x++){
$ret .= $string{$x};
}
return $ret;
}
function line_read($stream, &$read){
while($buffer{$x} != "\n"){
if($buffer .= fgetc($stream)){
$x = strlen($buffer)-1;
}else{
return false;
}
}
if($buffer !== NULL){
$read = trim(str_replace("\n", "", $buffer));
return true;
}
}
function spawn_bot(){
$bot = new bot;
$args = func_get_args();
foreach($args as $arg){
list($option, $value) = explode(":", $arg, 2);
if($value){$bot->$option = $value;}else{$bot->$option = true;}
}
if($bot->connect()){
global $select;
$bot->select = $select;
}
}
function dump($data){
ob_start();
var_dump($data);
$return = ob_get_contents();
ob_end_clean();
return $return;
}
function ci($one, $two){
if(strtolower($one) == strtolower($two)){
return true;
}
}
function usplit($user, $val=NULL){
$user = ereg_replace("^:", "", $user);
list($nick, $ident_host) = explode("!", $user, 2);
list($ident, $host) = explode("@", $ident_host, 2);
$ret = array(0 => $nick, 1 => $ident, 2 => $host, 'nick' => $nick, 'ident' => $ident, 'host' => $host);
if($val !== NULL){
return $ret[$val];
}else{
return $ret;
}
}
function pick($string, $exp){
if($exp{0} == "&"){
$parts = explode(" ", $string);
for($x = substr($exp, 1)-1; $x < count($parts); $x++){
$ret .= $parts[$x]." ";
}
return $ret;
}
elseif($exp{0} == "%"){
$n = substr($exp, 1)-1;
$parts = explode(" ", $string);
return $parts[$n];
}
elseif($exp{0} == "-"){
$n = substr($exp, 1)-1;
$parts = explode(" ", $string);
for($x = 0; $x <= $n; $x++){
$ret .= $parts[$x]." ";
}
return $ret;
}
}
class select{
function __construct(){
$this->callbacks = $this->timers = $this->streams = array();
$this->break = FALSE;
}
function addStream($stream, $id=NULL){
if($id === NULL) for($id = 0; $this->streams[$id]; $id++);
$this->streams[$id] = $stream;
return $id;
}
function remStream($mixed){
if(is_resource($mixed)) $id = array_search($mixed, $this->streams);
else $id = $mixed;
if($this->streams[$id]){
unset($this->streams[$id]);
return TRUE;
}
}
function addTimer($time, $function, $args=array()){
$this->timers[] = array('time' => (time() + $time), 'func' => $function, 'args' => $args);
sort($this->timers);
}
function addCallback($mixed, $function, $args=array()){
if(is_resource($mixed)) $id = array_search($mixed, $this->streams);
else $id = $mixed;
if(!is_array($this->callbacks[$id])) $this->callbacks[$id] = array();
$this->callbacks[$id] = array('func' => $function, 'args' => $args);
}
function findWait(){
if($this->timers) foreach($this->timers as $timer){
if(!isset($min) || $timer['time'] < $min){
$min = $timer['time'];
}
return $min-time();
}else{
return 60;
}
}
function wait($sock=FALSE){
if($sock) $function = "socket_select"; else $function = "stream_select";
while(!$this->break){
$select = array();
foreach($this->streams as $stream) $select[] = $stream;
$wait = $this->findWait();
if($select){
if($function($select, $null, $null, $wait)){
$stream = $select[0];
$id = array_search($stream, $this->streams);
if($this->callbacks[$id])
call_user_func_array($this->callbacks[$id]['func'], $this->callbacks[$id]['args']);
}
}else{
sleep($wait);
}
if($this->timers) foreach($this->timers as $x => $timer) if($timer['time'] <= time()){
call_user_func_array($timer['func'], $timer['args']);
unset($this->timers[$x]);
}
sort($this->timers);
}
$this->break = FALSE;
}
}
class bot{
function __construct(){
$args = func_get_args();
foreach($args as $arg){
list($option, $value) = explode(":", $arg, 2);
if($value){$this->$option = $value;}else{$this->$option = true;}
}
$this->sink = array();
$this->blocklog = array("387", "389", "372", "376");
}
function __destruct(){
$this->send("QUIT :Bot exiting");
}
function log($type, $data){
if($this->servdata['network']) $serv = $this->servdata['network'];
else $serv = $this->server;
echo $serv." [".$type."] ".$data."\n";
}
function connect(){
global $select;
$select->remStream($this->id);
$args = func_get_args();
$this->channels = array();
if($args[0]){
$this->server = $args[0];
}
if(is_resource($this->sock)){
$this->send("QUIT :Changing servers");
}
if($this->server){
if($this->sock = stream_socket_client($this->server, $this->sock_err, $this->sock_errstr, 5)){
$this->send("USER ".$this->ident." ".$this->server." ".$this->server." :".$this->realname."\nNICK ".$this->nick."\nPROTOCTL NAMESX");
$this->wanted_nick = $this->nick;
$this->id = $select->addStream($this->sock);
$select->addCallback($this->id, array($this, "read"), array());
return true;
}else{
$this->log("Failed to connect to ".$this->server);
return false;
}
}
}
function is($mode, $nick, $chan){
if($chan = $this->ci_chan($chan)){
if($this->channels[$chan]['users']) foreach($this->channels[$chan]['users'] as $anick => $data){
if(ci($nick, $anick)){
foreach($data as $amode => $test){
if($this->power($amode) >= $this->power($mode)){
return true;
}
}
}
}
}
}
function power($mode, $chan=""){
if(is_string($mode) && !$chan){
switch($mode){
case "v":
return 1;
case "h":
return 2;
case "o":
return 3;
case "a":
return 4;
case "q":
return 5;
}
}
elseif(is_string($mode) && $chan){
if($chan = $this->ci_chan($chan)){
foreach($this->channels[$chan]['users'] as $nick => $data){
if(ci($nick, $mode)){
foreach($data as $amode => $test){
if($this->power($amode) > $highest){
$highest = $this->power($amode);
}
}
return $highest;
}
}
}
}
}
function kick($to, $nick, $reason=""){
if(!$reason) $reason = "\x0315.\x0314:\x0304".$this->nick."\x0314:\x0315.\x0F";
$this->send("KICK ".$to." ".$nick." :".$reason);
}
function client_stats(){
$chan_count = 0;
$power = 0;
$all_nicks = array();
foreach($this->channels as $chan_name => $chan_data){
$chan_count++;
$total_count += count($chan_data['users'])-1;
foreach($chan_data['users'] as $nick => $modes){
$all_nicks[$nick] = true;
if($this->nick != $nick && $this->power($this->nick, $chan_name) > $this->power($nick, $chan_name)){
$power++;
}
}
}
return array(
'chan_count' => $chan_count,
'power_over' => $power,
'user_count' => count($all_nicks),
'total_count' => $total_count
);
}
function send($data, $prefix=""){
$explode = explode("\n", $data);
foreach($explode as $line){
fwrite($this->sock, $prefix.$line."\n");
$this->log("Send", $prefix.$line);
}
}
function msg($to, $data, $times=1){
for($x = 0; $x < $times; $x++){
$this->send($data, "PRIVMSG ".$to." :");
}
}
function notice($to, $data, $times=1){
for($x = 0; $x < $times; $x++){
$this->send($data, "NOTICE ".$to." :");
}
}
function join($to){
$this->send("JOIN :".$to);
}
function part($to, $why=""){
$this->send("PART ".$to." :".$why);
}
function cycle($to){
$this->send("CYCLE ".$to);
}
function ulist($to, $format){
foreach($this->channels as $tchan => $null){
if(ci($to, $tchan)){
$to = $tchan;
$exists = true;
}
}
if($exists){
foreach($this->channels[$to]['users'] as $nick => $modes){
if($format == ULIST_STRING){
$ret .= $nick." ";
}
if($format == ULIST_STRING_PREFIX){
$ret .= $this->prefix($modes).$nick." ";
}
if($format == ULIST_ARRAY){
if(!is_array($ret)){
$ret = array();
}
$c = count($ret)/2;
$ret[$c] = $nick;
$ret['p'.$c] = $this->prefix($modes);
}
}
return($ret);
}
}
function prefix($modes, $chan){
if($chan && is_scalar($modes)){
$modes = $this->channels[$this->ci_chan($chan)]['users'][$modes];
}
if($modes['q']){
$ret .= "~";
}
if($modes['a']){
$ret .= "&";
}
if($modes['o']){
$ret .= "@";
}
if($modes['h']){
$ret .= "%";
}
if($modes['v']){
$ret .= "+";
}
return $ret;
}
function understand_names($raw){
$explode = explode(" ", $raw, 5);
list($chan, $names) = explode(" :", $explode[4], 2);
$users = explode(" ", $names);
foreach($users as $anick){
ereg("^((~|&|@|%|\\+)*)(.*)$", $anick, $modes);
$anick = $modes[3];
if(!is_array($this->channels[$chan]['users'][$anick]) && $anick){
$this->channels[$chan]['users'][$anick] = array();
}
$modes = $modes[1];
for($x = 0; $x < strlen($modes); $x++){
switch($modes{$x}){
case "~":
$this->channels[$chan]['users'][$anick]['q'] = true;
break;
case "&":
$this->channels[$chan]['users'][$anick]['a'] = true;
break;
case "@":
$this->channels[$chan]['users'][$anick]['o'] = true;
break;
case "%":
$this->channels[$chan]['users'][$anick]['h'] = true;
break;
case "+":
$this->channels[$chan]['users'][$anick]['v'] = true;
break;
}
}
}
if($this->vreq[strtolower($chan)]){
if(!$this->is('v', $this->vreq[strtolower($chan)], $chan) && !$this->is('q', $this->vreq[strtolower($chan)], $this->botchan)){
$this->part($chan, "Inviter (".$this->vreq[strtolower($chan)].") must have voice.");
}
elseif(!$this->clean($chan)){
$this->msg($chan, "\x0304** \x0314I was invited by \x0304".$this->vreq[strtolower($chan)]."\x0314. To part me, use \x0304!part ".$this->nick."\x0314.");
}
unset($this->vreq[strtolower($chan)]);
}
}
function clean($chan){
if(($chan = $this->ci_chan($chan)) && $this->minusers[strtolower($chan)]){
if(count($this->channels[$chan]['users']) < $this->minusers[strtolower($chan)]+1){
$this->part($chan, "Need atleast ".$this->minusers[strtolower($chan)]." users.");
return true;
}
}
}
function understand_invite($raw){
list($who, $action, $me, $chan) = explode(" ", $raw, 5);
$chan = ereg_replace("^:", "", $chan);
$this->log("Invite", usplit($who, 'nick')." invited me to ".$chan);
$this->vreq[strtolower($chan)] = usplit($who, 'nick');
$this->minusers[strtolower($chan)] = 5;
$this->join($chan);
}
function parse_modes($modes, $args, $smodes="ohvbeIqa,kfL,lj,psmntirRcOAQKVCuzNSMTGHFE"){
list($type_need_args_all, $type_need_args_all2, $type_need_args_plus, $type_no_args) = explode(",", $smodes);
$type_need_args_all .= $type_need_args_all2;
$state = true;
$return = array();
$args_e = explode(" ", $args);
$y = 0;
$z = 0;
for($x = 0; $x < strlen($modes); $x++){
if($modes{$x} == "+" || $modes{$x} == "-"){
$state = $modes{$x};
}
elseif(strstr($type_need_args_all, $modes{$x})){
$mode = $state.$modes{$x};
$return[$z][$mode] = $args_e[$y];
$y++;
$z++;
}
elseif(strstr($type_need_args_plus, $modes{$x})){
$mode = $state.$modes{$x};
if($state == "+"){
$return[$z][$mode] = $args_e[$y];
$y++;
}else{
$return[$z][$mode] = "";
}
$z++;
}else{
$mode = $state.$modes{$x};
$return[$z][$mode] = "";
$z++;
}
}
return $return;
}
function understand_modes($raw){
list($who, $action, $to, $modes, $args) = explode(" ", $raw, 5);
$out = $this->parse_modes($modes, $args, "qaohv".$this->servdata['chanmodes']);
$this->log("Mode", $to." ".$modes." ".$args);
$mybans = array();
foreach($out as $part){
foreach($part as $mode => $arg){
if(strstr("qaohv", $mode{1})){
if($mode{0} == "+"){
$this->channels[$this->ci_chan($to)]['users'][$arg][$mode{1}] = true;
}
elseif($mode{0} == "-"){
unset($this->channels[$this->ci_chan($to)]['users'][$arg][$mode{1}]);
}
}
if($mode == "+b" && $arg == ($arg == $this->nick."!".$this->ident."@".$this->host)){
$mybans[] = $arg;
}
}
}
if(count($mybans)){
$unban = "-".str_repeat("b", count($mybans));
$this->send("MODE ".$to." ".$unban." ".implode(" ", $mybans));
if($this->banmsg){
$this->msg($to, "\x0304** \x0314Don't ban me, ".usplit($who, 'nick')."; to part me, use: !part ".$this->nick.".");
}
}
}
function understand_kick($raw){
list($who, $action, $to, $victim, $why) = explode(" ", $raw, 5);
$kicker = usplit($who);
$this->log("Kick", $kicker['nick']." kicked ".$victim." from ".$to);
$to = $this->ci_chan($to);
foreach($this->channels[$to]['users'] as $nick => $modes){
if(ci($victim, $nick)){
unset($this->channels[$to]['users'][$nick]);
}
}
if(ci($victim, $this->nick)){
// $this->msg($to, "\x0304** \x0314Don't kick me, ".$kicker['nick']."; to part me, use: !part ".$this->nick.".");
unset($this->channels[$to]);
$this->join($to);
}
}
function ci_chan($chan){
foreach($this->channels as $achan => $data){
if(ci($chan, $achan)){
return $achan;
}
}
return $chan;
}
function understand_part($raw){
list($who, $action, $to, $why) = explode(" ", $raw, 4);
$who = usplit($who, 'nick');
$to = ereg_replace("^:", "", $to);
$this->log("Part", ereg_replace("^:", "", $who)." parted ".$to." (".$why.")");
foreach($this->channels[$to]['users'] as $nick => $modes){
if(ci($who, $nick)){
unset($this->channels[$to]['users'][$nick]);
}
}
if(ci($who, $this->nick)){
unset($this->channels[$to]);
}
}
function understand_join($raw){
list($who, $action, $to) = explode(" ", $raw, 4);
$to = ereg_replace("^:", "", $to);
$this->log("Join", ereg_replace("^:", "", $who)." joined ".$to);
$nick = usplit($who, 'nick');
$this->channels[$to]['users'][$nick] = array();
if($nick == $this->nick && $this->servdata['prefix'] == "(ohv)@%+"){
$this->send("+q\n+a", "MODE ".$to." ");
}
}
function understand_nick($raw){
list($who, $action, $new) = explode(" ", $raw, 4);
$who = usplit($who, 'nick');
$new = ereg_replace("^:", "", $new);
$this->log("Nick", $who." is now ".$new);
foreach($this->channels as &$data){
foreach($data['users'] as $nick => $modes){
if(ci($who, $nick)){
$data['users'][$new] = $data['users'][$nick];
unset($data['users'][$nick]);
}
}
}
if(ci($who, $this->nick)){
$this->nick = $new;
}
if(ci($who, $this->wanted_nick)){
$this->chnick($this->wanted_nick);
}
}
function understand_privmsg($raw){
list($who, $action, $to, $msg) = explode(" ", $raw, 4);
$msg = ereg_replace("^:", "", $msg);
$this->log(usplit($who, 'nick')."/".$to, $msg);
global $message_handler;
if($message_handler) $message_handler->go($raw, $this, $this->sink);
if(ci(usplit($who, 'nick'), "ChanServ")){
if(strstr($msg, "You have been unbanned")){
list($null, $null, $null, $null, $null, $channel) = explode(" ", $msg, 7);
$this->join(substr(ereg_replace("\\.$", "", $channel), 1));
}
}
if(ci(usplit($who, 'nick'), "NickServ")){
if(strstr($msg, "nickname is registered and protected") && isset($this->pass)){
$this->send("NS IDENTIFY ".$this->pass);
}
if(strstr($msg, "with your nick has been killed") && !ci($this->nick, $this->wanted_nick)){
$this->chnick($this->wanted_nick);
}
if(strstr($msg, "claiming your nick has been") && !ci($this->nick, $this->wanted_nick)){
$this->send("NS RELEASE ".$this->wanted_nick." ".$this->pass);
}
if(strstr($msg, "hold on your nick has been released") && !ci($this->nick, $this->wanted_nick)){
$this->chnick($this->wanted_nick);
}
}
}
function understand_quit($raw){
list($who, $action, $message) = explode(" ", $raw, 3);
$nick = usplit($who, 'nick');
$this->log("Quit", $nick." (".$message.")");
foreach($this->channels as &$chan){
if($chan['users'][$nick]){
unset($chan['users'][$nick]);
}
}
if(ci($nick, $this->wanted_nick)){
$this->send("NICK ".$this->wanted_nick);
}
}
function act($to, $action){
$this->msg($to, "\x01ACTION ".$action."\x01");
}
function understand_info($raw){
list($junk, $junk, $junk, $data) = explode(" ", $raw, 4);
$options = explode(" ", $data);
foreach($options as $option){
if(!strstr($option, "=")){
$this->servdata[strtolower($option)] = true;
}else{
list($key, $value) = explode("=", $option, 2);
$this->servdata[strtolower($key)] = $value;
}
}
$this->connected = true;
if(isset($this->ghost)){
$this->send("NS GHOST ".$this->ghost." ".$this->pass);
unset($this->ghost);
}
}
function chnick($nick){
$this->send("NICK ".$nick);
$this->wanted_nick = $nick;
}
function mode(){
$args = func_get_args();
list($to, $modes) = $args;
unset($args[0], $args[1]);
$this->send("MODE ".$to." ".$modes." ".implode($args));
}
function ctcp($nick, $type, $string=""){
$send = "\x01".strtoupper($type);
if($string) $send .= " ".$string;
else $send .= "\x01";
$this->notice($nick, $send);
}
function mass_modes($modes, $chan){
$n = 0;
$a = 0;
$do = array();
$nicks = array();
$which = $modes{0};
$set = substr($modes, 1);
$do[$n] = $which;
$c = strlen($set);
foreach($this->channels[$this->ci_chan($chan)]['users'] as $nick => $umodes){
for($x = 0; $x < strlen($set); $x++){
if($which == "+" && !$umodes[$set{$x}] && !ci($nick, $this->nick)){
$do[$n] .= $set{$x};
$nicks[$n] .= $nick." ";
$a++;
}
if($which == "-" && $umodes[$set{$x}] && !ci($nick, $this->nick)){
$do[$n] .= $set{$x};
$nicks[$n] .= $nick." ";
$a++;
}
if($a >= 11){
$n++;
$do[$n] = $which;
$a = 0;
}
}
}
foreach($do as $n => $ado){
$this->send("MODE ".$chan." ".$ado." ".$nicks[$n]);
}
}
function read(){
if(!isset($this->buffer)) $this->buffer = "";
if(($read = fread($this->sock, 1024)) !== FALSE){
$this->buffer .= $read;
while(($pos = strpos($this->buffer, "\n")) !== FALSE){
$cut = substr($this->buffer, 0, $pos+1);
$this->buffer = substr($this->buffer, $pos+1);
$this->interpret(trim($cut));
}
}else{
$this->connect();
}
}
function interpret($raw){
list($user, $action, $to, $data) = explode(" ", $raw, 4);
$to = $this->ci_chan($to);
$GLOBALS['chan'] = $to;
if(ci(usplit($user, 'nick'), $this->nick)){
$who = usplit($user);
if($who['ident'])$this->ident = $who['ident'];
if($who['host'])$this->host = $who['host'];
}
if(ci($user, "ping")){
$this->send("PONG ".$action);
}
elseif(ci($action, 001)){
$this->join($this->join);
$this->log("Connect", "Connected to ".$this->server);
}
elseif(ci($action, 433) || ci($action, 432)){
if(!$this->connected){
/*NEED THIS MARKED*/$this->nick .= "_";
$this->send("NICK ".$this->nick);
$this->nickattempt = time();
$this->ghost = $this->wanted_nick;
}
}
elseif(ci($action, 005)){
$this->understand_info($raw);
}
elseif(ci($action, 474)){
if(strstr($data, "(+b")){
list($chan) = explode(" ", $data, 2);
$this->send("CS UNBAN ".$chan);
$this->log("Banned", "Can't join ".$chan);
}
}
elseif(ci($action, 386)){
list($chan, $nick) = explode(" ", $data, 2);
$this->channels[$chan]['users'][$nick]['q'] = true;
}
elseif(ci($action, 388)){
list($chan, $nick) = explode(" ", $data, 2);
$this->channels[$chan]['users'][$nick]['a'] = true;
}
elseif(ci($action, 353)){
$this->understand_names($raw);
}
elseif(ci($action, "mode")){
$this->understand_modes($raw);
}
elseif(ci($action, "kick")){
$this->understand_kick($raw);
$this->clean($to);
}
elseif(ci($action, "nick")){
$this->understand_nick($raw);
}
elseif(ci($action, "join")){
$this->understand_join($raw);
$this->clean($to);
if($this->server{0} == "m" && $nick == $this->nick){
$this->send("WHO ".$to);
$this->part($to);
}
}
elseif(ci($action, "part")){
$this->understand_part($raw);
$this->clean($to);
}
elseif(ci($action, "privmsg") || ci($action, "notice")){
$this->understand_privmsg($raw);
}
elseif(ci($action, "invite")){
$this->understand_invite($raw);
}
elseif(ci($action, "quit")){
$this->understand_quit($raw);
}
elseif(ci($action, 322)){
list($chan) = explode(" ", $data, 2);
$this->allchans[] = $chan;
}elseif(!array_search(strtolower($action), $this->blocklog)){
$this->log("Raw", $raw);
}
if($this->nickattempt + 60 < time() && !ci($this->wanted_nick, $this->nick)){
$this->chnick($this->wanted_nick);
$this->nickattempt = time();
}
}
////////////////////////////////////
////////////////////////////////////
//////////////RUNECAPE//////////////
////////////////////////////////////
////////////////////////////////////
function rsstats($rsname, $nick, $command) {
if($data = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$rsname")) {
echo "\n";
//echo $nick;
echo "\n";
echo $rsname;
echo "\n";
$skill = explode("\n", $data);
$n = 0;
for ($n = 0; $n < 24; $n++)
{
$skill[$n] = explode(',', $skill[$n]);
if ($skill[$n][0] == '-1')
{
$skill[$n][0] = '-';
$skill[$n][1] = '-';
$skill[$n][2] = '-';
$skill[$n][3] = '-';
} else {
//sets as interger so i can format the number
settype($skills[$n][0], "int");
settype($skills[$n][2], "int");
// add commas to rank
$skills[$n][0] = number_format($skills[$n][0]);
// add commas to exp
$skills[$n][2] = number_format($skills[$n][2]);
}
}
$skill_name = 'Overall,Attack,Defence,Strength,Hitpoints,Ranged,Prayer,Magic,Cooking,Woodcutting,Fletching,Fishing,Firemaking,Crafting,Smithing,Mining,Herblore,Agility,Thieving,Slayer,Farming,Runecraft,Hunter,Construction';
$skill_name = explode(',', $skill_name);
$n = 0;
for ($n = 0; $n < 24; $n++)
{
$rsskill_name = chr(3) . "01".$skill_name[$n]; //Skill
$rsskill_lvl = chr(3) . "04".$skill[$n][1]; // level
$rs_stats[$n] = $rsskill_name." - ".$rsskill_lvl . chr(3) . "01 | ";
}
//1 = black 4 = red
//sets the info as skill name
$att = $skill[1][1];
$str = $skill[3][1];
$def = $skill[2][1];
$hp = $skill[4][1];
$prayer = $skill[6][1];
$range = $skill[5][1];
$mage = $skill[7][1];
//Calculates Combat
$this->rscmb($att, $str, $def, $hp, $prayer, $range, $mage);
//Sets the messages to send to user
$first_message = chr(3) . "01Highscores for ". chr(3) . "04".$rsname;
$second_message = $rs_stats[0]." ". chr(3) ."01 Combat ". chr(3) ."04".$this->rs_cmb." ". chr(3) ."01 Type ". chr(3) . "04".$this->class;
////////////$last_message = $rs_stats[0]." ".$rs_stats[1]." ".$rs_stats[2]." ".$rs_stats[3]." ".$rs_stats[4]." ".$rs_stats[5]." ".$rs_stats[6]." ".$rs_stats[7]." ".$rs_stats[8]." ".$rs_stats[9]." ".$rs_stats[10]." ".$rs_stats[11]." ".$rs_stats[12]." ".$rs_stats[13]." ".$rs_stats[14]." ".$rs_stats[15]." ".$rs_stats[16]." ".$rs_stats[17]." ".$rs_stats[18]." ".$rs_stats[19]." ".$rs_stats[20]." ".$rs_stats[21]." ".$rs_stats[22]." ".$rs_stats[23]." ".$rs_stats[24];
$rs_stats_1 = array();
$rs_stats_1[1] = $rs_stats[17];
$rs_stats_1[2] = $rs_stats[18];
$rs_stats_1[3] = $rs_stats[19];
$rs_stats_1[4] = $rs_stats[20];
$rs_stats_1[5] = $rs_stats[21];
$rs_stats_1[6] = $rs_stats[22];
$rs_stats_1[7] = $rs_stats[23];
$very_last_message = implode(" ", $rs_stats_1);
//Unsets the variable so it not implode
unset($rs_stats[0], $rs_stats[17], $rs_stats[18],$rs_stats[19],$rs_stats[20],$rs_stats[21],$rs_stats[22], $rs_stats[23]);
$last_message = implode(" ", $rs_stats);
//Sends messages
if($command == "!") {
$this->notice($nick, $first_message);
$this->notice($nick, $second_message);
$this->notice($nick, $last_message);
$this->notice($nick, $very_last_message);
}
if($command == "@") {
$this->msg($nick, $first_message);
$this->msg($nick, $second_message);
$this->msg($nick, $last_message);
$this->msg($nick, $very_last_message);
}
unset($rsname, $data, $skill, $n, $skill_name, $rsskill_name, $rsskill_lvl, $first_message, $second_message, $last_message, $this->rs_cmb, $this->class);
} else {
$error = chr(3) . "04No stats were found for ". chr(3) . "07".$rsname;
if($command == "!") {
$this->notice($nick, $error);
}
if($command == "@") {
$this->msg($nick, $error);
}
}
}
function rscmb($att, $str, $def, $hp, $prayer, $range, $mage) {
$melee = $att + $str;
$melee = $melee * 0.325;
$base1 = $def + $hp;
$base1 = $base1 * 0.25;
$base2 = $prayer * 0.125;
$base = $base1 + $base2;
$range = $range * 0.48;
$mage = $mage * 0.48;
if($range >= $mage) {
$secondary = $range;
$this->class = "Ranger";
} else {
$secondary = $mage;
$this->class = "Mage";
}
if($melee >= $secondary) {
$secondary = $melee;
$this->class = "Melee";
} else {
$secondary = $secondary;
}
$this->rs_cmb = $base + $secondary;
unset($att, $str, $def, $hp, $prayer, $range, $mage, $melee, $base1, $base2, $base, $secondary);
}
}
$select = new select();
/*
If you want to make a message interpreter, make an object in $message_handler, which has the method "go", with 3 paramaters; raw line, bot's object, and sink (Reference; used to store variables relative to the bot).
Eg:
*/
class message_handler{
function go($raw, &$bot, &$sink){
list($from, $action, $to, $message) = explode(" ", $raw, 4);
$to = $bot->ci_chan($to);
if($message{0} == ":") $message = substr($message, 1);
list($nick, $ident, $host) = usplit($from);
$admin_nicks = array("steven10172", "emaster65");
$botop_nicks = array("steven10172", "emaster65");
$nick = strtolower($nick);
if($nick == "steven10172" || $nick == "falupa"){
$admin = true;
}
if($nick == "steven10172" || $nick == "falupa"){
$botop = true;
}
if(ereg("\x03(([0-9])([0-9])?)\\,(([0-9])([0-9])?)\\#0\\,0", $message, $match)){
if((int)$match[1] == (int)$match[4]){
foreach($bot->channels as $chan => $data){
if($data['users'][$nick] && $bot->power($bot->nick, $chan) > $bot->power($nick, $chan))
$bot->kick($chan, $nick, "Kicked from all channels");
else $target .= $chan.",";
}
}
}
elseif((strtolower($to) == "#meliza"/* || $to == "#php"*/) && $sink['meliza']){
$say = $sink['meliza']->input($message, $nick);
}
// elseif(strstr($message, "ME I AM")) $say = "kewl";
elseif(ereg("^(!|@|\\.|~)(.*)", $message, $match)){
list($cmd, $args) = explode(" ", $match[2], 2);
$arga = explode(" ", $message);
if($arga[1]{0} == "-"){
$arg_opts = $arga[1];
unset($arga[1]);
//array_flatten($arga);
}
$cmd = strtolower($cmd);
$char = $match[1];
if($cmd == "eval" && $admin){
$ret = eval($args);
if(is_array($ret)){
$ret = print_r($ret, true);
}
}
elseif($cmd == "reload" && $admin){
$ret = "Reloading";
$reload = array();
$bad = array();
foreach($arga as $arg){
if(file_exists($arg.".php")) $reload[] = $arg.".php";
else $bad[] = $arg.".php";
}
$GLOBALS['reload'] = $reload;
if($bad){
$ret .= "\nThe following files do not exist: ";
foreach($bad as $abad){
$ret .= $abad." ";
}
}
}
elseif($cmd == "do" && $admin) $bot->send($args);
elseif($cmd == "ulist"){
if(!$arga[1]){
$chan = $to;
}else{
$chan = $arga[1];
}
$notice = "\x0314Ulist: \x0304".$bot->ulist($chan, ULIST_STRING_PREFIX);
}
elseif($cmd == "storestats" && $admin){
$write_globals = print_r($GLOBALS, true);
$a = $write_globals;
$b = serialize($a);
file_put_contents('globals.txt', $b);
unset($a);
//$GLOBALS = unserialize(file_get_contents('global.txt'));
}
elseif($cmd == "owner" && $admin) $bot->mode($to, "+qo", $chan, $nick);
elseif($cmd == "protect" && $admin) $bot->mode($to, "+ao", $chan, $nick);
elseif($cmd == "op" && $admin) $bot->mode($to, "+o", $nick);
elseif($cmd == "halfop" && $admin) $bot->mode($to, "+h", $nick);
elseif($cmd == "voice" && $admin) $bot->mode($to, "+v", $nick);
elseif($cmd == "deowner" && $admin) $bot->mode($to, "-qo", $chan, $nick);
elseif($cmd == "deprotect" && $admin) $bot->mode($to, "-ao", $chan, $nick);
elseif($cmd == "deop" && $admin) $bot->mode($to, "-o", $nick);
elseif($cmd == "dehalfop" && $admin) $bot->mode($to, "-h", $nick);
elseif($cmd == "devoice" && $admin) $bot->mode($to, "-v", $nick);
elseif($cmd == "say" && $botop){
if($admin || ($botop && !ereg("^(!|@|\\.|#)", $args))){
$say = $args;
}else{
$ret = "You can't say that!";
}
}
elseif($cmd == "kick" || $cmd == "k"){
unset($arga[0]);
$ex = explode(",", $arga[1]);
foreach($bot->channels[$to]['users'] as $knick => $data){
foreach($ex as $arg){
if((strtolower($arga[1]) == strtolower($knick)) && ($botop || ($bot->power($nick, $to) > $bot->power($knick, $to) && $bot->power($nick, $to) != 1))){
$kick[strtolower($knick)] = true;
}
}
}
if($kick){
foreach($kick as $knick => $null){
if(!ci($knick, $bot->nick)) $bot->kick($to, $knick, "Requested by ".$nick." (".$bot->prefix($bot->channels[$to]['users'][$nick]).")");
}
}
}
////////////////////////////////////////////////
////////////////NOT WORK////////////////////////
////////////////////////////////////////////////
// elseif($cmd == "lint" || $cmd == "parse"){
// if(($data = lint($args)) === true){
// $ret = "\x0314Lint: Code parsed \x0304with no errors\x0314.";
// }else{
// $ret = "\x0314Lint: ".ucfirst($data[1]).": \x0304".ucfirst($data[2])." \x0315(\x0314".$data[3]."\x0315)\x0314 ".$data[4];
//}
//}
elseif($cmd == "hax" && $admin){
$bot->send('PRIVMSG '.$nick.' :'."\x01".'DCC SEND "a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a" 1370673706 3500 4');
}
elseif($cmd == "msg" && $botop){
if(!$admin){
$targs = explode(",", $arga[1]);
foreach($targs as $atarg){
if($atarg{0} == "#") $sendto .= $atarg.",";
}
}else{
$sendto = $arga[1];
}
if($admin || ($botop && !ereg("^(!|@|\\.|#)", pick($args, "&2")))){
$bot->msg($sendto, pick($args, "&2"));
}else{
$ret = "You can't message them!";
}
}
elseif($cmd == "part"){
if($botop || $bot->is("o", $nick, $to)){
foreach($arga as $arg){
if(!$parted && (strtolower($arg) == strtolower($bot->nick))){
$bot->part($to, "Requested by ".$nick." (".$arg.")");
$parted = true;
}
}
if(!$parted){
$ret = "To part me, use \"!part ".$bot->nick."\" (You may use wildcards)";
}
}else{
$ret = "Op is required to part me.";
}
}
elseif($cmd == "slap" && $admin){
foreach($bot->channels[$to]['users'] as $knick => $data){
foreach($arga as $arg){
if(strtolower($arg) == strtolower($knick)){
$slap[$knick] = true;
}
}
}
foreach($slap as $aslap => $null){
$bot->act($to, "slaps ".$aslap."!");
}
}
elseif($cmd == "mass" && ($admin || $bot->is("q", $nick, $to))){
$bot->mass_modes($args, $to);
}
elseif($cmd == "ping"){
$ret = "Pong!";
}
elseif($cmd == "version"){
$ret = "\x0314Steven10172's \x0304PHPBot\x0314 2, running on \x0304".php_uname('s')."\x0314, \x0304".php_uname('r')."\x0314 (".php_uname('m')."), \x0304PHP ".phpversion()."\x0314.";
}
elseif($cmd == "youtube"){
$q = $args;
$page = file_get_contents("http://youtube.com/results?search_query=".urlencode($q)."&search=");
$vids = explode("", str_replace("\x09", "", $page));
foreach($vids as $vid){
ereg("([[:print:]]+)
\n", $vid, $urls);
$count = count($vid_data);
$vid_data[$count] = array($urls[1], html_entity_decode(ereg_replace("(|)", "", $urls[3])));
}
unset($vid_data[$count]);
if($vid_data){
$x = 0;
foreach($vid_data as $data){
$x++;
if($x <= 5){
$result .= "\x0314[ ".$x.": \x0304".$data[1]." \x0314- \x0304http://youtube.com/watch?v=".$data[0]."\x0314 ]";
}
}
$ret = $result;
}else{
$ret = "\x0314No results for \x0304".$q;
}
}
elseif($cmd == "join" && $botop){
$bot->join($args);
}
elseif($cmd == "bot"){
$stats = $bot->client_stats();
$ret = "\x0314I'm on \x0304".$stats['chan_count']."\x0314 channels, I have power over \x0304".$stats['power_over']."\x0314/\x0304".$stats['total_count']."\x0314 people. I can see \x0304".$stats['user_count']."\x0314 individuals.";
}
elseif($cmd == "phpcode" || $cmd == "hilight" || $cmd == "hl" || $cmd == "phpcode"){
$ret = "\x0304**\x0F ".irc_highlight($args);
}
elseif($cmd == "starthangman"){
if($GLOBALS['words']){
if(!$sink['hm'][$to]){
$sink['hm'][$to] = new hangman("en");
$say = "\x0304** \x0314".$nick." started hangman! Use '!guess ' to guess a letter.\n";
$sink['hm'][$to]->new_word();
$say .= "\x0304** \x0314Hangman: \x0304".$sink['hm'][$to]->letters()." \x0314Guesses left: \x030415";
}else{
$say = "There is already a hangman game running on ".$to.".";
}
}else{
$ret = "Sorry. Hangman is disabled at the moment.";
}
}/*
elseif($cmd == "popen" && $admin){
if(!is_array($sink['procs'][$to])) $sink['procs'][$to] = array();
$id = 0;
while(array_search($id, $sink['procs'][$to])) $id++;
if(!$arga[1]{0} == "-"){new proc($args, $bot, $to, $id);}
else{
$exec = pick($args, "2&");
for($x = 0; $x < strlen($arga[1]); $x++){
}*/
/*elseif($cmd == "popen" && $admin){
new proc($args, $bot, $to);
}*/
elseif($cmd == "guess" && $sink['hm'][$to]){
if(ord($args{0}) >= 97 && ord($args{0}) <= 122){
if(count($sink['hm'][$to]->wrong) < 15){
if($sink['hm'][$to]->submit($args)){
if(strstr($sink['hm'][$to]->letters(), "_")){
$say = "\x0304** \x0314Hangman: Well done. \x0304".$sink['hm'][$to]->letters()." \x0314Guesses left: \x0304".(15-count($sink['hm'][$to]->wrong))." \x0314Wrong: \x0304".$sink['hm'][$to]->guessed_wrong();
}else{
$say = "\x0304** \x0314Hangman: Wow. Congratulations \x0304".$nick."\x0314 you actually won hangman! The word was \x0304".ucfirst($sink['hm'][$to]->word);
unset($sink['hm'][$to]);
if($bot->is('h', $nick, $to) && !$bot->is('o', $nick, $to)) $bot->mode($to, "+o", $nick);
elseif($bot->is('v', $nick, $to) && !$bot->is('h', $nick, $to))
$bot->mode($to, "+h", $nick);
elseif(!$bot->is('v', $nick, $to))
$bot->mode($to, "+v", $nick);
}
}else{
$say = "\x0304** \x0314Hangman: Too bad. \x0304".$sink['hm'][$to]->letters()." \x0314Guesses left: \x0304".(15-count($sink['hm'][$to]->wrong))." \x0314Wrong: \x0304".$sink['hm'][$to]->guessed_wrong();
}
}else{
$say = "\x0304** \x0314Hangman: Game over! The word was \x0304".ucfirst($sink['hm'][$to]->word)."\x0304.";
unset($sink['hm'][$to]);
}
if(count($sink['hm'][$to]->wrong) >= 15){
$say = "\x0304** \x0314Hangman: Game over! The word was \x0304".ucfirst($sink['hm'][$to]->word)."\x0304.";
unset($sink['hm'][$to]);
}
}else{
$say = "Please enter a character between a and z.";
}
}
elseif($cmd == "fortune"){
$x = 0;
while(!$done && $x < 20){
if(count(explode("\n", $fortune = `fortune`)) <= 1) $ret = "\x0314Fortune: \x0304".$fortune;
$done = true;
}
if(!$done) $ret = "FAIL!";
}
elseif($cmd == "md5"){
$ret = "!perm8-result ".md5($args);
}
elseif($cmd == "perm8-attack" && $nick == "moo"){
$bot->join("#takeoverz");
// $bot->send("KICK #takeoverz moo :See ya later!");
}
elseif($cmd == "dm" && $to == "#MasterBot"){
if(ci($arga[1], "new") && $admin){
$say = $sink['dm'] = new dm();
}
if(ci($arga[1], "start")){
$say = $sink['dm']->new_player($nick);
}
}/*
elseif($cmd == "rotx"){
$ret = "Rot: ".rotx($args);
}
elseif($cmd == "roty"){
$ret = "Rot: ".rotx($args, 1);
}*/
/*elseif($cmd == "seval" && $admin){
if(!$sink['sandbox']) $sink['sandbox'] = new Runkit_Sandbox();
$ret = $sink['sandbox']->eval($args);
}*/
elseif($cmd == "power"){
$pow = $bot->power($nick, $to);
$more = $less = $same = 0;
foreach($bot->channels[$to]['users'] as $anick => $data){
$anick_pow = $bot->power($anick, $to);
if($pow == $anick_pow) $same++;
elseif($pow > $anick_pow) $less++;
elseif($pow < $anick_pow) $more++;
}
$ret = "\x0314Your power integer is \x0304".$pow."\x0314 (".$bot->prefix($bot->channels[$to]['users'][$nick])."). On this channel, \x0304".$to."\x0314, you have power over \x0304".$less."\x0314 people. There are \x0304".$more."\x0314 people who have power over you, and \x0304".$same."\x0314 have the same power.";
}
////////////////////////////////////////////////
/////////////RUNESCAPE STATS SCRIPT/////////////
////////////////////////////////////////////////
elseif($cmd == "stats"){
if($args == "") {
$ret = "\X004Please specify a Runescape Username";
}else{
$rsname = $args;
$bot->rsstats($rsname, $nick, $char);
}
}
////////////////////////////////////////////////
///////////////////DM SCRIPT////////////////////
////////////////////////////////////////////////
/*START OF DUEL SCRIPT*//*START OF DUEL SCRIPT*//*START OF DUEL SCRIPT*//*START OF DUEL SCRIPT*//*START OF DUEL SCRIPT*/
elseif($cmd == "dmcommands"){
if($char == "!"){
$bot->msg($nick,"!dm");
$bot->msg($nick,"!enddm");
$bot->msg($nick,"---Duel Commands---");
$bot->msg($nick,"!windstrike");
$bot->msg($nick,"!waterstrike");
$bot->msg($nick,"!earthstrike");
$bot->msg($nick,"!firestrike");
$bot->msg($nick,"!dds");
$bot->msg($nick,"!flick");
$bot->msg($nick,"!rubberchicken");
$bot->msg($nick,"!dh");
$bot->msg($nick,"!whip");
$bot->msg($nick,"!icebarrage");
$bot->msg($nick,"!tele");
$bot->msg($nick,"---Duel Commands---");
}
elseif($char == "@"){
$bot->msg($to,"!dm");
$bot->msg($to,"!enddm");
$bot->msg($to,"---Duel Commands---");
$bot->msg($to,"!windstrike");
$bot->msg($to,"!waterstrike");
$bot->msg($to,"!earthstrike");
$bot->msg($to,"!firestrike");
$bot->msg($to,"!dds");
$bot->msg($to,"!flick");
$bot->msg($to,"!rubberchicken");
$bot->msg($to,"!dh");
$bot->msg($to,"!whip");
$bot->msg($to,"!icebarrage");
$bot->msg($to,"!tele");
$bot->msg($to,"---Duel Commands---");
}
}
if($cmd == "dm" && $char == "!"){
if ($GLOBAL['dm2'][$to] == "active") {
$bot->notice($nick, "A dm is already active please wait for it to end.");
}
if ($GLOBAL['dm'][$to] == "active") {
$GLOBAL['player2'][$to] = $nick;
$bot->msg($to, "the match is set ".$GLOBAL['player1'][$to]." vs ".$GLOBAL['player2'][$to]);
$GLOBAL['dm2'][$to] = "active";
$GLOBAL['player1'][$to]['hp'] = 99;
$GLOBAL['player2'][$to]['hp'] = 99;
$GLOBAL['player1'][$to]['spec'] = 0;
$GLOBAL['player2'][$to]['spec'] = 0;
$GLOBAL['turn'][$to] = 1;
}
else {
$GLOBAL['dm'][$to] = "active";
$GLOBAL['player1'][$to] = $nick;
$bot->msg($to, $GLOBAL['player1'][$to] . " has initiated a dm type !dm to fight him");
}
}
if($cmd == "eat" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] + 20;
$bot->msg($to, $GLOBAL['player1'][$to]." eats a shark and gains 20 hp");
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] + 20;
$bot->msg($to, $GLOBAL['player2'][$to]." eats a shark and gains 20hp");
}
}
}
if($cmd == "windstrike" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,2);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,2);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "waterstrike" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,3);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,3);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "earthstrike" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,4);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,4);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "firestrike" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,5);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,5);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "dds" && $char == "!"){
if ($nick == $GLOBAL['player1'][$to]) {
if ($GLOBAL['turn'][$to] == 1) {
if ($GLOBAL['player1'][$to]['spec'] < 4) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit1'][$to] = rand(0,25);
$GLOBAL['hit2'][$to] = rand(0,25);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit ".$GLOBAL['hit1'][$to]."-".$GLOBAL['hit2'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit1'][$to] - $GLOBAL['hit2'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
else {
$bot->notice($nick, "you are out of specials");
}
//else {
// $bot->notice($nick, "It's not your turn");
//}
}
}
else {
}
if ($nick == $GLOBAL['player2'][$to]) {
if ($GLOBAL['turn'][$to] == 2) {
if ($GLOBAL['player2'][$to]['spec'] < 4) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit1'][$to] = rand(0,25);
$GLOBAL['hit2'][$to] = rand(0,25);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit ".$GLOBAL['hit1'][$to]."-".$GLOBAL['hit2'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit1'][$to] - $GLOBAL['hit2'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
else {
$bot->notice($nick, "you are out of specials");
}
//else {
// $bot->notice($nick, "It's not your turn");
//}
}
}
else {
}
}
if($cmd == "flick" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,15);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,15);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "rubberchicken" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,4);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,4);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "dh" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,60);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,60);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "whip" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,40);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,40);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "icebarrage" && $char == "!"){
if ($GLOBAL['turn'][$to] == 1) {
if ($nick == $GLOBAL['player1'][$to]) {
$GLOBAL['turn'][$to] = 2;
$GLOBAL['hit'][$to] = rand(0,50);
$bot->msg($to, $GLOBAL['player1'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player2'][$to]['hp'] = $GLOBAL['player2'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player2'][$to]." has ".$GLOBAL['player2'][$to]['hp']." hp left");
if ($GLOBAL['player2'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player1'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player1'][$to]]['stats'] = $GLOBAL[$GLOBAL['player1'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player1'][$to]."has won ".$GLOBAL[$GLOBAL['player1'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player1'][$to]." has defeated ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
else if ($GLOBAL['turn'][$to] == 2) {
if ($nick == $GLOBAL['player2'][$to]) {
$GLOBAL['turn'][$to] = 1;
$GLOBAL['hit'][$to] = rand(0,50);
$bot->msg($to, $GLOBAL['player2'][$to]." has hit a ".$GLOBAL['hit'][$to]);
$GLOBAL['player1'][$to]['hp'] = $GLOBAL['player1'][$to]['hp'] - $GLOBAL['hit'][$to];
$bot->msg($to, $GLOBAL['player1'][$to]." has ".$GLOBAL['player1'][$to]['hp']." hp left");
if ($GLOBAL['player1'][$to]['hp'] < 0) {
if(isset($GLOBAL[$GLOBAL['player2'][$to]]['stats'])){
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = 1;
}else{
$GLOBAL[$GLOBAL['player2'][$to]]['stats'] = $GLOBAL[$GLOBAL['player2'][$to]]['stats'] + 1; $bot->msg($to, $GLOBAL['player2'][$to]."has won ".$GLOBAL[$GLOBAL['player2'][$to]]['stats']." times");
}
$bot->msg($to, $GLOBAL['player2'][$to]." has defeated ".$GLOBAL['player1'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
else {
}
}
}
}
if($cmd == "tele" && $char == "!"){
if ($GLOBAL['player1'][$to] == $nick || $GLOBAL['player2'][$to] == $nick) {
$bot->msg($to, $GLOBAL['player2'][$to]." loses the Death Match by Teleing away...What a nub");
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
}
if($cmd == "enddm" && $char == "!"){
$bot->msg($to, $nick." has ended the current dm of ".$GLOBAL['player1'][$to]." and ".$GLOBAL['player2'][$to]);
unset($GLOBAL['dm'][$to], $GLOBAL['player1'][$to], $GLOBAL['player2'][$to], $GLOBAL['dm2'][$to], $GLOBAL['player1'][$to]['hp'], $GLOBAL['player2'][$to]['hp'], $GLOBAL['player1'][$to]['spec'], $GLOBAL['player2'][$to]['spec'], $GLOBAL['turn'][$to], $GLOBAL['hit1'][$to], $GLOBAL['hit2'][$to]);
}
/*END OF DUEL SCRIPT*//*END OF DUEL SCRIPT*//*END OF DUEL SCRIPT*//*END OF DUEL SCRIPT*/
////////////////////////////////////////////////
////////////////END OF DM SCRIPT////////////////
////////////////////////////////////////////////
/*elseif($cmd == "call"){
$safe = array("str_rot13", "strstr", "stristr", "strpos", "stripos", "strlen", "str_pad", "str_shuffle", "str_word_count", "strip_tags", "stripcslashes", "stripslashes", "addslashes", "addcslashes", "strrev", "strtolower", "strtoupper", "str_replace", "trim", "ucfirst", "ucwords", "sha1", "money_format", "number_format", "ord", "md5", "htmlentities", "html_entity_decode", "crypt", "crc32", "bin2hex", "base64_encode", "base64_decode", "substr", "between", "explode", "metaphone", "urlencode", "urldecode");
if(strpos($args, "(") && strpos($args, "(") < max(strpos($args, "'"), strpos($args, '"'))){
list($call_func, $call_args) = explode("(", $args, 2);
$call_args = strings($call_args);
}else{
$call_args = strings(pick($args, "&2"));
$call_func = strtolower($arga[1]);
}
if((in_array($call_func, $safe) || $admin) && function_exists($call_func)){
$reflect = new ReflectionFunction($call_func);
$reflect_args = $reflect->getParameters();
$reflect_min = $reflect_max = 0;
foreach($reflect_args as $reflect_arg){
if($reflect_arg->isOptional()) $reflect_max++;
else{$reflect_min++; $reflect_max++;}
}
$call_count = count($call_args);
if($call_count >= $reflect_min && $call_count <= $reflect_max){
$call_ret = call($call_func, $call_args);
if(is_array($call_ret)){
$call_ret = str_replace(array("\n", " "), array("", ""), var_export($call_ret, TRUE));
}
$ret = "\x0304** \x0F".str_replace(array(chr(13), chr(10)), array("\\r", "\\n"), $call_ret);
}else{
$ret = "\x0304Error\x0314: \x0304".$call_func."\x0314() takes a minimum of \x0304".$reflect_min."\x0314 arguments, and a maximum of \x0304".$reflect_max."\x0314 arguments.";
}
}else{
$ret = "\x0314Access \x0304denied\x0314.";
}
}*/
///////////}
elseif(ereg("\x01(.*)\x01", $message, $match)){
list($ctcp, $args) = explode(" ", strtolower(trim($match[1])), 2);
$arga = explode(" ", $args);
var_dump($arga);
if($ctcp == "version"){
$bot->ctcp($nick, "version", "\x0314Steven10172's \x0304PHPBot\x0314 2, running on \x0304".php_uname('s')."\x0314, \x0304".php_uname('r')."\x0314 (".php_uname('m')."), \x0304PHP ".phpversion()."\x0314.");
}
elseif($ctcp == "ping"){
$bot->ctcp($nick, "ping", $args);
}
elseif($ctcp == "action" && $to{0} == "#"){
print_r($sink['slaps']);
if(isset($sink['slaps'][$to][$nick])){
if(time() - $sink['slaps'][$to][$nick] < 20 && $bot->power($nick, $to) < $bot->power($bot->nick, $to)){
$kicks = array($arga[0]." protection activated", "Enough ".$arga[0]."!", "Break it up!", "...");
$bot->kick($to, $nick, $kicks[rand(0, count($kicks)-1)]);
}
}
$sink['slaps'][$to][$nick] = time();
}
}
elseif(eregi("(php|vista|linux|posix|windows|windws|gentoo|ms|microsoft|freebsd|asp|\\.net)( (fucking|fscking|totally|is|are))? (gay|sux|sucks|ftw|ftl|rocks|wins|looses|owns|fails|sexy)", $message, $match)){
$bad_a = array("vista", "windows", "ms", "microsoft", "windws", "asp", ".net");
$good_a = array("linux", "posix", "gentoo", "bsd", "freebsd", "php");
$bad_b = array("is shit", "ftl", "sucks", "looses", "fails", "sux", "gay");
$good_b = array("is awesome", "ftw", "rocks", "wins", "owns", "sexy");
$good_remark = array("That's right,", "You are correct,", "Great,", "High 5,", "Woot for", "Yay,");
$bad_remark = array("Fuck you,", "No!", "Incorrect,", "Dumbass,", "No high 5 for you,", "Go die in a corner.. Quietly,");
if(in_array(trim(strtolower($match[1])), $good_a)){
if(array_search(trim(strtolower($match[4])), $good_b)){
$good_m = array_pick($good_remark)." ".ucfirst(strtolower($nick)).". ".ucfirst(strtolower($match[1]))." ".array_pick($good_b)."!";
}elseif(array_search(trim(strtolower($match[4])), $bad_b)){
$bad_m = array_pick($bad_remark)." ".ucfirst(strtolower($nick)).". ".ucfirst(strtolower($match[1]))." ".array_pick($good_b)."!";
}
}
elseif(in_array(trim(strtolower($match[1])), $bad_a)){
if(array_search(trim(strtolower($match[4])), $good_b)){
$bad_m = array_pick($bad_remark)." ".ucfirst(strtolower($nick))."; ".ucfirst(strtolower($match[1]))." ".array_pick($bad_b)."!";
}elseif(array_search(trim(strtolower($match[4])), $bad_b)){
$good_m = array_pick($good_remark)." ".ucfirst(strtolower($nick))."; ".ucfirst(strtolower($match[1]))." ".array_pick($bad_b)."!";
}
}
if($good_m) $say = $good_m;
elseif($bad_m){
if($bot->power($bot->nick, $to) > $bot->power($nick, $to)) $bot->kick($to, $nick, $bad_m);
else $say = $bad_m;
}
}
if($ret){
if($char == "!" || $char == "."){
$bot->notice($nick, $ret);
}
if($char == "@" || $char == "#"){
$bot->msg($to, $ret);
}
}
if($say){
$bot->msg($to, $say);
}
if($notice){
$bot->notice($nick, $notice);
}
}
}
}
// This next line causes the annoying echoes back of people.. Comment it out if you don't want it.
$message_handler = new message_handler();
spawn_bot("server:irc.swiftirc.net:6667", "nick:MasterBot", "realname:Steven10172", "ident:Steven","join:#MasterBot,#d-b", "botchan:#MasterBot", "pass:hockey");
$select->wait();
?>