Source) Look for "flashvars="id=#########&..." the ID is the number you want $bot->connect("174.36.242.26","10024"); //Connect to XAT...this IP will change as necessary automatically depending on the room you want to join. $bot->join($roomID); while(true){ if($bot->read()=='DIED') { $bot->connect("174.36.242.26","10024"); $bot->join($roomID); } } class BasicXatBot { private $soc; //Socket for bot private $debug = false; //Used to toggle debugging output. private $packet; //Stores information about the last recieved packet of each kind private $userInfo; //Stores User information //If you don't know where to get these you should probably not be trying to make your own bot. //Go download WPE Pro and check out the packets XAT sends and learn about how XAT works. //The UserID and K Value are the source or the 'old falsh' error(if you get it) make sure you get these values from a REGISTERED account private $userID = "351599155"; //The Bot's UserID private $k = "3607438505"; //The Bot's K value //Bot Account Settings private $name = "XBot"; //The display name the bot will use private $avatar = -1; //The Avatar value for the bot, this can be an id number or an image url. private $homepage = ""; //The bot's homepage link. private $roomID; //This gets set in code, don't touch it here. just used ->join(ID) /** * This is where everything the bot does needs to happen, this is the only default function you should need to edit * @param $event The event that just occured(and thus needs to be handled) * @param $data Any data relating to this event. */ function handleEvent($event,$data) { $info = $this->getUserArray($data['id']); switch($event) { case 'userJoined': /* $data['id'] Has the ID of the user who just joined $data['old'] Sometimes XAT sends packets that are not current(for example when you join a room, old ==true for all users who are already in the room when you join, but still this event is handled as thought they just joined */ //Do whever you want with users joining here... echo ((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) has just joined.\n"; break; case 'userLeft': /* $data['id'] The ID of the user that just left. */ echo ((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) has just left.\n"; break; case 'privateMessage': /* $data['id'] The ID of the user that just left. $data['message'] The message sent to you as a PM */ echo "[PM] ".((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) -> $data[message]\n"; //Example of a private message command $command = explode(' ',$data['message'],2); //First parse the first word out see if it is a command... //[0] has first word [1] has everything else if($command[0]{0}=='!'){//I am use ! as the character to signify a command, so check if the first character is right. switch($command[0]) { case '!say': case '!speak': case '!talk': $this->sendPrivateMessage($command[1],$data['id']); break; case '!info': $this->sendPrivateMessage('I am a bot ^_^',$data['id']); break; } } break; case 'privateChat': /* $data['id'] The ID of the user that just left. $data['message'] The message sent to you as a PC */ echo "[PC] ".((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) -> $data[message]\n"; //Example of a private chat command $command = explode(' ',$data['message'],2); //First parse the first word out see if it is a command... //[0] has first word [1] has everything else if($command[0]{0}=='!'){//I am use ! as the character to signify a command, so check if the first character is right. switch($command[0]) { case '!info': $this->sendPrivateChat('I am a bot ^_^',$data['id']); break; } } break; case 'message': /* $data['id'] The ID of the user $data['old'] See $data['old'] under userJoined $data['message'] The message sent to main chat */ echo ((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) -> $data[message]\n"; //How to do main chat commands: if($data['old']) return; //Old message $command = explode(' ',trim($data['message']),2); //First parse the first word out see if it is a command... //[0] has first word [1] has everything else if($command[0]{0}=='!'){//I am use ! as the character to signify a command, so check if the first character is right. switch($command[0]) { case '!say': case '!speak': case '!talk': //Multiple cases lead to the same code being run... $this->sendMessage($command[1]); break; case '!slap': case '!slaps': case '!hit': $this->sendMessage(((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])." slaps $command[1] around a bit with a large trout."); break; case '!avatar'://steal an avatar via !avatar USER_ID $user = $this->getUserArray($command[1]); $this->sendMessage(str_replace('(','( ',$user['avatar'])); break; case '!info': $this->sendMessage('I am a bot ^_^',$data['id']); break; case '!yt': case '!youtube': case '!y': if(trim($command[1])=='') $this->sendMessage("Usage: $command[0] SEARCH TERMS HERE"); else { //Yeah I know I don't really need urlencode() i could just replace spaces with + but this is a bit more secure. $res = $this->get('http://www.youtube.com/results?search_query='.urlencode(preg_replace("/[^A-Za-z0-9 !.,:[]\s\s+]/",'',$command[1]))); for($i=0;$i<3;$i++) { $msg=$this->getBetween($res, '