X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_messageflood.cpp;h=9ff17924d1c38bbb154c4a959fa151824894a221;hb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;hp=e0b30163c28c5af598e895c69973167ad4ff8e08;hpb=21c3232b8e0bb41727f2d65a0b2d5304587cf6be;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index e0b30163c..9ff17924d 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -75,8 +75,6 @@ class MsgFlood : public ModeHandler ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { - floodsettings *f = ext.get(channel); - if (adding) { std::string::size_type colon = parameter.find(':'); @@ -97,6 +95,7 @@ class MsgFlood : public ModeHandler return MODEACTION_DENY; } + floodsettings* f = ext.get(channel); if ((f) && (nlines == f->lines) && (nsecs == f->secs) && (ban == f->ban)) // mode params match return MODEACTION_DENY; @@ -108,15 +107,13 @@ class MsgFlood : public ModeHandler } else { - if (f) - { - ext.unset(channel); - channel->SetModeParam('f', ""); - return MODEACTION_ALLOW; - } - } + if (!channel->IsModeSet('f')) + return MODEACTION_DENY; - return MODEACTION_DENY; + ext.unset(channel); + channel->SetModeParam('f', ""); + return MODEACTION_ALLOW; + } } }; @@ -129,11 +126,14 @@ class ModuleMsgFlood : public Module ModuleMsgFlood() : mf(this) { - if (!ServerInstance->Modes->AddMode(&mf)) - throw ModuleException("Could not add new modes!"); - ServerInstance->Extensions.Register(&mf.ext); + } + + void init() + { + ServerInstance->Modules->AddService(mf); + ServerInstance->Modules->AddService(mf.ext); Implementation eventlist[] = { I_OnUserPreNotice, I_OnUserPreMessage }; - ServerInstance->Modules->Attach(eventlist, this, 2); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } ModResult ProcessMessages(User* user,Channel* dest, const std::string &text) @@ -188,8 +188,11 @@ class ModuleMsgFlood : public Module return MOD_RES_PASSTHRU; } - ~ModuleMsgFlood() + void Prioritize() { + // we want to be after all modules that might deny the message (e.g. m_muteban, m_noctcp, m_blockcolor, etc.) + ServerInstance->Modules->SetPriority(this, I_OnUserPreMessage, PRIORITY_LAST); + ServerInstance->Modules->SetPriority(this, I_OnUserPreNotice, PRIORITY_LAST); } Version GetVersion()