X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nickflood.cpp;h=708d30e6beee622155de397b8c964a2f2f6def2b;hb=cbd32e195f5f574653550a3ed4954168ace30c55;hp=d4b07b0c4dfaa1bc8950048c4a98933844e94327;hpb=de25d946733f774e3a5b53a58438a9c92af0acbe;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index d4b07b0c4..708d30e6b 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -17,7 +17,7 @@ /** Holds settings and state associated with channel mode +F */ -class nickfloodsettings : public classbase +class nickfloodsettings { public: int secs; @@ -89,18 +89,9 @@ class NickFlood : public ModeHandler { public: SimpleExtItem ext; - NickFlood(Module* Creator) : ModeHandler(Creator, 'F', PARAM_SETONLY, MODETYPE_CHANNEL), + NickFlood(Module* Creator) : ModeHandler(Creator, "nickflood", 'F', PARAM_SETONLY, MODETYPE_CHANNEL), ext("nickflood", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - nickfloodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, ConvToStr(x->nicks)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { nickfloodsettings *f = ext.get(channel); @@ -200,24 +191,26 @@ class ModuleNickFlood : public Module { if (!ServerInstance->Modes->AddMode(&nf)) throw ModuleException("Could not add new modes!"); - Extensible::Register(&nf.ext); + ServerInstance->Extensions.Register(&nf.ext); Implementation eventlist[] = { I_OnUserPreNick, I_OnUserPostNick }; ServerInstance->Modules->Attach(eventlist, this, 2); } ModResult OnUserPreNick(User* user, const std::string &newnick) { - if (isdigit(newnick[0])) /* allow switches to UID */ + if (ServerInstance->NICKForced.get(user)) /* Allow forced nick changes */ return MOD_RES_PASSTHRU; for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { Channel *channel = *i; + ModResult res; nickfloodsettings *f = nf.ext.get(channel); if (f) { - if (CHANOPS_EXEMPT('F') && channel->GetPrefixValue(user) == OP_VALUE) + res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + if (res == MOD_RES_ALLOW) continue; if (f->islocked()) @@ -250,11 +243,13 @@ class ModuleNickFlood : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); ++i) { Channel *channel = *i; + ModResult res; nickfloodsettings *f = nf.ext.get(channel); if (f) { - if (CHANOPS_EXEMPT('F') && channel->GetPrefixValue(user) == OP_VALUE) + res = ServerInstance->OnCheckExemption(user,channel,"nickflood"); + if (res == MOD_RES_ALLOW) return; /* moved this here to avoid incrementing the counter for nick @@ -269,12 +264,11 @@ class ModuleNickFlood : public Module ~ModuleNickFlood() { - ServerInstance->Modes->DelMode(&nf); } Version GetVersion() { - return Version("Channel mode F - nick flood protection", VF_COMMON | VF_VENDOR); + return Version("Channel mode F - nick flood protection", VF_VENDOR); } };