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.
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();
}
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.
Failure to send anti-idle messages shouldn't result in your connection being terminated.
Are you responding to 0x25 when you receive it?
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"
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 anti-idle shouldn't be affected by people joining the channel.