yeah i added a lot of it in
heres the top half of mine
[php]<?php
/**
-
@author 3nvisi0n
-
@copyright 2011
-
- This is just a basic version of my Xat Bot you can build upon to add the feature you want.
-
*/
set_time_limit(0);//No time out
$bot = new BasicXatBot();
$botowner = array(‘320467393’);
$roomID = 150355757;//Don’t know how to get this ID? goto xat.com/ROOM_YOU_WANT_BOT_IN and View Source(Firefox: Ctrl+U, Internet Explorer: View>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);
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 = "DuBot"; //The display name the bot will use
private $avatar = "http://www.instablogsimages.com/images/2009/01/08/joe-bot-inflatable-robot_NBz64_6648.jpg"; //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...
$this->sendPrivateMessage("Welcome to the chat! Please follow the rules and enjoy your stay. :)",$data['id']);
if("$info[rank]"=="guest" && "$automem"=="on")
$this->member($data['id']);
if($info['name']=='')
$this->kick("NULL",$data['id']);
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]) {
}
}
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 '!unbanme':
if(($data['id'])==$botowner)
$this->unban($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 '!commands':
$this->sendPrivateMessage("!guestme | !memberme | !kickme | !banme [seconds] | !info",$data['id']);
break;
case '!say':
if(($data['id'])==$botowner)
$this->sendMessage($command[1]);
else
$this->sendMessage("Don't tell me what to say (D)",$data['id']);
break;
case '!automember':
if($data['id']==$botowner && $command[1]=="on") {
$automem = "on";
$this->sendMessage("Auto Membering is ".$automem.".");
}
elseif($data['id']==$botowner && $command[1]=="off") {
$automem = "off";
$this->sendMessage("Auto Membering is ".$automem.".");
}
continue;
case '!ams':
$this->sendMessage("Auto membering is currently ".$automem);
break;
case '!guest':
if(($data['id'])==$botowner)
$this->guest($command[1]);
break;
case '!member':
if(($data['id'])==$botowner)
$this->member($command[1]);
break;
case '!mod':
if(($data['id'])==$botowner)
$this->mod($command[1]);
break;
case '!kick':
if(($data['id'])==$botowner)
$this->kick("Dubz told me to... (WARY)",$command[1]);
break;
case '!ban':
if(($data['id'])==$botowner)
$this->ban("Dubz told me to... (WARY)",$command[1],600);
break;
case '!unban':
if(($data['id'])==$botowner)
$this->unban($command[1]);
break;
case '!guestme':
$this->guest($data['id']);
break;
case '!memberme':
$this->member($data['id']);
break;
case '!modme':
if(($data['id'])==$botowner)
$this->mod($data['id']);
else
$this->sendMessage("Yeah, right. (SMIRK)",$data['id']);
break;
case '!moderatorme':
if(($data['id'])==$botowner)
$this->mod($data['id']);
else
$this->sendMessage("Yeah, right. (SMIRK)",$data['id']);
break;
case '!ownerme':
if(($data['id'])==$botowner)
$this->owner($data['id']);
else
$this->sendMessage("You gotta be kidding me! (XD)",$data['id']);
break;
case '!mainownerme':
$this->sendMessage("What on Earth are you smoking? (O_O)",$data['id']);
break;
case '!kickme':
$this->kick("You asked for it...",$data['id']);
break;
case '!banme':
$this->ban("You asked for it...",$data['id'],$command[1]);
break;
case '!protect':
if(($data['id'])==$botowner)
$this->sendMessage("/p");
break;
case '!define':
if(($data['id'])==$botowner)
$this->sendMessage("http://www.urbandictionary.com/define.php?term=".$command[1],$data['id']);
break;
case '!info':
$this->sendMessage("Dubz is my master.",$data['id']);
break;
case '!killbot':
if(($data['id'])==$botowner)
$this->die();
else
$this->sendMessage("Yeah? YOU AND WHAT ARMY! (SMIRK)",$data['id']);
break;
}
}
break;
}
}
/* ****************************************************** */
/* *YOU SHOULD NOT NEED TO EDIT ANYTHING AFTER TH
IS LINE* */
/* ****************************************************** */[/php]
I couldn’t post all of it because of the character limit but the rest is the same as the one on pastebin except for the guest command that was added since it wasn’t on the pastebin script