• Welcome to Valhalla Legends Archive.
 

Question Referring to CHAT Bots

Started by Minor, April 13, 2004, 01:36 AM

Previous topic - Next topic

Minor

Using Microsoft Visual C++ Compiler.

Is there an easy way to check if a person is in a game or not by using a specific Idle. For Example: If you type to bot "info Username"
and bot goes through the whois and then
Send("/msg %s %s is Currently in Game: %s\r\n",Master,User,Game);
or
Send("/msg %s %s is Not in a Game.\r\n",Master,User);
**Not in specific indentifiers but you get the point, i hope***

Can someone help me on this subject please.

Eric

/whois <user> and/or if the user is on your friends list, /friends list.

Minor

I ment, not from the command line... When making the bot... How do i get the bot to recieve the "%s is using Broodwar in game %s" and off of that say "%s is in a Game: %s"?

How do i get to say, Example:
"Bot: /whois Username"
"Server: Username is using Brood war In game 3on3"
"Bot: /msg Master Username is in game: 3on3"

How do i get it to Reply to the Server message to get it to message me saying its in a game...
And...

"Bot: /whois Username"
"Server: Username is using Broodwar in a Private channel."
"Bot: /msg Master Username is not in a game"

Is there like a special way in C++ to use the If-then-else statement with Wildcards so i could say something like:

if(serverreply == *in game*) {
 Send("/msg %s %s is in Game: %s\r\n",Master,Name,Game);
}
if(serverreply != *in game*) {
 Send("/msg %s %s is not in a Game\r\n",Master,Name);
}

Like that? Can someone please help me im very lost in this situation  :-\

iago

look up sprintf and vprintf/vfprintf/vsprintf/vsnprintf - I forget which of those is the most useful.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Moonshine

#4
char *pszUsername = strtok(szPacket, " ");

char * pszGameName, *p;

for (;;) {
p = strtok(NULL, " ");
if (p != NULL)
  pszGameName = p;
else
  break;
}

Edit:  pszGameName might not refer to the whole game name if the game name has a space in it (e.g. Warcraft III : The frozen throne).  So you might have to use a counter inside the for loop to detect exactly how many tokens you've taken, then use the appropriate token# as the game name.

iago

The cool way to get all tokens out of a string, if you want to use strtok, is:

for(char *p = strtok(str, " "); p; p = strtok(NULL, " "))
{
...
}


Adron showed me that a long time ago when I was complaining I didn't understand strtok(), and I've never forgotten it :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Moonshine

lol the cool way...

that's a neat "shortcut" :)

Minor

#7
So if i wanted an Idle (saying i have the settings for the idle already inputed) to check if a user in a list "Stalklist" and check if hes in a game it would look something like this:

void Bot::StalkProc() {

   User tmpUser;
   for (int i = 0; i < stalkList.GetElements(); i++) {
      stalkList.GetUser(i,tmpUser);
      Send("/whois %s\r\n",tmpUser.Name);
      }
   for(char *p = strtok(str, " "); p; p = strtok(NULL, " "))
   {
   char *pszUsername = strtok(szPacket, " ");
   char * pszGameName, *p;
   for (;;) {
   p = strtok(NULL, " ");
   if (p != NULL)
     pszGameName = p;
   Send("/w %s Stalked.\r\n",tmpUser.Name);
   else
     break;
   }
}

If not please assist me because now i have 28 errors and before compiling the code i never had any... So obviously its wrong can u tell me what im doing wrong?