"; } // Respond to !hello if ($command == ":!hello") { fputs($socket, "PRIVMSG ".$ex['2']." :Hello ".$username."!\n"); echo "Said hello to ".$username." in ".$ex['2'].".
"; } //Notice a username or channel if ($command == ":!notice" && $username == "Spudchat") { //split $data into an array seperated by : $noticex = explode(':', $data); //remove !notice from the second part of the array created above //print_r($noticex); $noticex['2'] = substr($noticex['2'],8); //$noticercvr = characters up to the first space $noticercvr = substr($noticex['2'], 0, strpos($noticex['2'], " ")); $noticercvrlen = strlen($noticercvr); $notice = substr($noticex['2'],$noticercvrlen); $notice = trim($notice); fputs($socket, "NOTICE ".$noticercvr." :".$notice."\n"); echo "NOTICE sent to ".$noticercvr." : ".$notice."
"; } //Msg a username or channel if ($command == ":!msg" && $username == "Spudchat") { //split $data into an array seperated by : $msgex = explode(':', $data); //remove !msg from the second part of the array created above //print_r($msgex); $msgex['2'] = substr($msgex['2'],5); //$msgrcvr = characters up to the first space $msgrcvr = substr($msgex['2'], 0, strpos($msgex['2'], " ")); $msgrcvrlen = strlen($msgrcvr); $msg = substr($msgex['2'],$msgrcvrlen); $msg = trim($msg); fputs($socket, "PRIVMSG ".$msgrcvr." :".$msg."\n"); echo "MSG sent to ".$msgrcvr." : ".$msg."
"; } //Join A Channel if($command == ":!join" && $username == "Spudchat"){ fputs($socket,":".$botnick." JOIN ".$ex['4']."\n"); echo "JOINing ".$ex['4']."
"; } //Part A Channel if($command == ":!part" && $username == "Spudchat"){ fputs($socket,":".$botnick." PART ".$ex['4']."\n"); echo "PARTing ".$ex['4']."
"; } //Change Nicks if($command == ":!nick" && $username == "Spudchat"){ fputs($socket,":".$botnick." NICK ".$ex['4']."\n"); echo "NICK changed to ".$ex['4']." by ".$username.".
"; } //Display Load Average if($command == ":!load"){ $load=sys_getloadavg(); fputs($socket, "PRIVMSG ".$ex['2']." :\x0312Load Averages [ 1M \x0315".$load['0']."\x0312 ] [ 5M \x0315".$load['1']."\x0312 ] [ 15M \x0315".$load['2']."\x0312 ]\n"); echo "Load Averages [ 1M ".$load['0']." ] [ 5M ".$load['1']." ] [ 15M ".$load['2']." ] sent to ".$ex['2']."
"; } //Display Uptime if($command == ":!uptime"){ $uptime=`uptime`; $uptime= preg_split( '/,/', $uptime, -1, PREG_SPLIT_NO_EMPTY ); $uptime['0'] = substr_replace($uptime['0'], '', 0, 12); $uptime['0'] = substr($uptime['0'], 0, strpos($uptime['0'], " days")); $uptime2= preg_split( '/:/', $uptime['1'], -1, PREG_SPLIT_NO_EMPTY ); fputs($socket, "PRIVMSG ".$ex['2']." :\x0312Uptime [\x0315".$uptime['0']."d ".trim($uptime2['0'])."h ".$uptime2['1']."m \x0312]\n"); echo "Uptime sent to ".$username." ( ".$uptime['0']."d ".$uptime2['0']."h ".$uptime2['1']."m )
"; } //Display Some Help if($command == ":!help"){ fputs($socket, "NOTICE $username :Available Commands and Their Usage\n"); usleep(100000); fputs($socket, "NOTICE $username :!die - Kill the bot (restricted to admin)\n"); usleep(100000); fputs($socket, "NOTICE $username :!hello - Say hello\n"); usleep(100000); fputs($socket, "NOTICE $username :!join #channel - Join #channel (restricted to admin)\n"); usleep(100000); fputs($socket, "NOTICE $username :!load - Displays load averages for the last 1, 5, and 15 minutes\n"); usleep(100000); fputs($socket, "NOTICE $username :!msg nick|channel message - Msg nick|channel message (restricted to admin)\n"); usleep(100000); fputs($socket, "NOTICE $username :!nick newnick - Changes bot nick to newnick (restricted to admin)\n"); usleep(100000); fputs($socket, "NOTICE $username :!notice nick|channel message - Notice nick|channel message (restricted to admin)\n"); usleep(100000); fputs($socket, "NOTICE $username :!part #channel - Part #channel (restricted to admin)\n"); usleep(100000); fputs($socket, "NOTICE $username :!uptime - Display bot's shell uptime\n"); echo "HELPing ".$ex['0']."
"; } // Close the connection if($command == ":!die" && $username == "Spudchat"){ fputs($socket, "QUIT :Terminated with extreme prejudice.\n"); echo "Killed by ".$username."
"; die(); } usleep(100000); } } ?>