+ floodsettings(bool a, int b, int c) : ban(a), secs(b), lines(c)
+ {
+ reset = time(NULL) + secs;
+ log(DEBUG,"Create new floodsettings: %lu %lu",time(NULL),reset);
+ };
+
+ void addmessage(userrec* who)
+ {
+ std::map<userrec*,int>::iterator iter = counters.find(who);
+ if (iter != counters.end())
+ {
+ iter->second++;
+ log(DEBUG,"Count for %s is now %d",who->nick,iter->second);
+ }
+ else
+ {
+ counters[who] = 1;
+ log(DEBUG,"Count for %s is now *1*",who->nick);
+ }
+ if (time(NULL) > reset)
+ {
+ log(DEBUG,"floodsettings timer Resetting.");
+ counters.clear();
+ reset = time(NULL) + secs;
+ }
+ }
+
+ bool shouldkick(userrec* who)
+ {
+ std::map<userrec*,int>::iterator iter = counters.find(who);
+ if (iter != counters.end())
+ {
+ log(DEBUG,"should kick? %d, %d",iter->second,this->lines);
+ return (iter->second >= this->lines);
+ }
+ else return false;
+ }
+
+ void clear(userrec* who)
+ {
+ std::map<userrec*,int>::iterator iter = counters.find(who);
+ if (iter != counters.end())
+ {
+ counters.erase(iter);
+ }
+ }