std::map<userrec*,int> counters;
floodsettings() : ban(0), secs(0), lines(0) {};
- floodsettings(bool a, int b, int c) : ban(a), secs(b), lines(c) { reset = time(NULL) + secs; };
+ 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)
{
iter->second++;
log(DEBUG,"Count for %s is now %d",who->nick,iter->second);
}
- if (reset > time(NULL))
+ 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;
}
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;
return 0;
}
- int ProcessMessages(userrec* user,chanrec* dest,std::string &text)
+ void ProcessMessages(userrec* user,chanrec* dest,std::string &text)
{
floodsettings *f = (floodsettings*)dest->GetExt("flood");
if (f)
{
/* Youre outttta here! */
f->clear(user);
+ if (f->ban)
+ {
+ char* parameters[3];
+ parameters[0] = dest->name;
+ parameters[1] = "+b";
+ parameters[2] = user->MakeWildHost();
+ Srv->SendMode(parameters,3,user);
+ }
Srv->KickUser(NULL, user, dest, "Channel flood triggered (mode +f)");
- return 1;
}
}
- return 0;
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
- {
+ virtual void OnUserMessage(userrec* user, void* dest, int target_type, std::string text)
+ {
if (target_type == TYPE_CHANNEL)
{
- return ProcessMessages(user,(chanrec*)dest,text);
+ ProcessMessages(user,(chanrec*)dest,text);
}
- else return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual void OnUserNotice(userrec* user, void* dest, int target_type, std::string text)
{
if (target_type == TYPE_CHANNEL)
{
- return ProcessMessages(user,(chanrec*)dest,text);
+ ProcessMessages(user,(chanrec*)dest,text);
}
- else return 0;
}
void OnChannelDelete(chanrec* chan)
void Implements(char* List)
{
- List[I_On005Numeric] = List[I_OnExtendedMode] = List[I_OnChannelDelete] = 1;
+ List[I_On005Numeric] = List[I_OnExtendedMode] = List[I_OnChannelDelete] = List[I_OnUserNotice] = List[I_OnUserMessage] = 1;
}
virtual void On005Numeric(std::string &output)