• Welcome to Valhalla Legends Archive.
 

Greet bot Anti idles

Started by AC_Drkan, April 20, 2004, 04:02 PM

Previous topic - Next topic

AC_Drkan

hey i have an anti idle set but the bot times out after like 3 minutes.
here is my code for the message loop

//============================================================================
int BnBot::MsgLoop() {
 int nBufLen=0;
 int nBufPos=0;
 char stageBuf[BUFSIZE];

 if (s == INVALID_SOCKET)
   return 0;

 for (;;) {


   // Handle timer functions
   DWORD dwCurrentTick = GetTickCount();
   TimerProc(dwCurrentTick);

   fd_set fds;
   FD_ZERO(&fds);
   FD_SET(s, &fds);
   struct timeval tv;
   tv.tv_sec = 1;
   tv.tv_usec = 0;

   int n = select(s+1, &fds, 0, 0, &tv);
   if (n) {
     int nNumToRead = BUFSIZE-nBufLen-nBufPos;

     if (nNumToRead == 0) {
       memmove(stageBuf, stageBuf+nBufPos, nBufLen);
       nBufPos = 0;
       nNumToRead = BUFSIZE-nBufLen;
     }

     n = recv(s, stageBuf+nBufPos+nBufLen, nNumToRead, 0);
     if (n <= 0) {
       LogWrite("recv() returned %d, error code %u", n, GetLastError());
       return 0;
     }

     nBufLen += n;

     // dispatch all complete messages in the staging buffer
     while (nBufLen > 0) {
       char *m = stageBuf+nBufPos;
       int nMsgLen=0;
       while (nMsgLen < nBufLen) {
         if (m[nMsgLen] == '\n')
           break;
         nMsgLen++;
       }

       nMsgLen++;
       if (nMsgLen > nBufLen)
         break;

       m[nMsgLen-1] = '\0';

       if (isdigit(*m))
         Dispatch(m);

       nBufLen -= nMsgLen;
       nBufPos += nMsgLen;
     }

     if (!nBufLen)
       nBufPos = 0;
   }
   IdleHook();
 }
 return 1;
}



- Added code tags by popular demand.
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

AC_Drkan

#1
Also my anti idle code
//=============================================================================
void BnBot::TimerProc(DWORD currentTick) { /* added 04/16/04 */

   // Anti-idles here - Every minute
   if ((currentTick - lastIdle) / 1000 > 60)
      IdleProc();
}
//=============================================================================
void BnBot::IdleProc() {


   Send(" / w AC_Drkan Total Users Joined  %s  Since Log On\ r \ n ",  y ) ;
   lastIdle = GetTickCount();
}
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

Eli_1

Please put that in [ code ] [ /code ] tags. Also, don't post two consecutive messages, instead either put them both in one post, or use the modify feature.

Eric

Failure to send anti-idle messages shouldn't result in your connection being terminated.
Are you responding to 0x25 when you receive it?

UserLoser.

Quote from: LoRd[nK] on April 20, 2004, 06:08 PM
Failure to send anti-idle messages shouldn't result in your connection being terminated.
Are you responding to 0x25 when you receive it?

That looks like a Chat bot, due to the fact of no handling of messages that start with 0xff, and packet sizes, ect.  Along with "Greet bot"

AC_Drkan

Do you guys see anything wrong with it?

It runs then gets the "The program must be Terminated"
after 1 user joins the channel
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

Falcon[anti-yL]

The anti-idle shouldn't be affected by people joining the channel.