Author | Message | Time |
---|---|---|
Adron | I'm still adding things to NBBot. It's ugly and patched, but it works! This code may be of use to those visiting Clan [vL] lately. Insert code equivalent to tryhandlecombined between your original code that parses out packets and the function that handles type 0x0f. The result will be that you no longer see much of those annoying spam bots that come, spam, and leave before they can be banned. [code] struct entry { std::string user; std::string txt; unsigned a, b, c, d, e, f; DWORD tick; entry(unsigned aa, unsigned bb, unsigned cc, unsigned dd, unsigned ee, unsigned ff, char *uu, char *tt) : a(aa), b(bb), c(cc), d(dd), e(ee), f(ff), user(uu), txt(tt) { tick = GetTickCount(); } }; threaded void *tryhandledata; threaded int tryhandlepend; threaded void *tryhandleignored; void tryhandlecombined(bool message, unsigned f, unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, char *user, char *txt) { using namespace std; typedef list<entry> entrylist; typedef set<string> stringset; if(!tryhandledata) { tryhandledata = new entrylist; tryhandleignored = new stringset; tryhandlepend = 0; } entrylist& el = *(entrylist*)tryhandledata; stringset& ignored = *(stringset*)tryhandleignored; entrylist::iterator it; #define SVLIMIT 350 if(message) { if(f == 2) { tryhandlepend++; el.push_back(entry(a, b, c, d, e, f, user, txt)); } else if(tryhandlepend) { if(f == 3) { bool ignore = false; entrylist::reverse_iterator rit; for(rit = el.rbegin(); rit != el.rend(); rit++) { if(rit->f == 2 && !strcmp(rit->user.c_str(), user) && int(GetTickCount() - rit->tick) <= SVLIMIT) { ignore = true; if(ignored.find(user) == ignored.end()) { plog("Ignored %s\n", rit->user.c_str()); ignored.insert(user); } break; } } if(ignore) { for(it = el.begin(); it != el.end();) { if(!strcmp(it->user.c_str(), user)) { if(it->f == 2) tryhandlepend--; // plog("Drop message %d %s %s\n", it->f, it->user.c_str(), it->txt.c_str()); it = el.erase(it); } else { it++; } } } } else { el.push_back(entry(a, b, c, d, e, f, user, txt)); } } else { handlecombined(f, a, b, c, d, e, user, txt); } } // plog("Check queue\n"); while(!el.empty()) { it = el.begin(); if(it->f == 2) { if(int(GetTickCount() - it->tick) < SVLIMIT) break; tryhandlepend--; } handlecombined(it->f, it->a, it->b, it->c, it->d, it->e, it->user.c_str(), it->txt.c_str()); el.pop_front(); } } [/code] | February 9, 2003, 3:57 PM |