X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nonicks.cpp;h=998662c3c7e23822e4d0a240e1a7d1c44f88c79a;hb=1041cb9329027ea2b3855836e2bb68ab7411730f;hp=b9010d3302770c1a918b8294409ba56e67be9c7f;hpb=c202dea024542b9c6c6b771bb9a3a081d9eacdc5;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index b9010d330..998662c3c 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -20,27 +20,19 @@ #include "inspircd.h" - -class NoNicks : public SimpleChannelModeHandler -{ - public: - NoNicks(Module* Creator) : SimpleChannelModeHandler(Creator, "nonick", 'N') { } -}; +#include "modules/exemption.h" class ModuleNoNickChange : public Module { - NoNicks nn; - bool override; + CheckExemption::EventProvider exemptionprov; + SimpleChannelModeHandler nn; public: - ModuleNoNickChange() : nn(this) + ModuleNoNickChange() + : exemptionprov(this) + , nn(this, "nonick", 'N') { } - void init() CXX11_OVERRIDE - { - ServerInstance->Modules->AddService(nn); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Provides support for channel mode +N & extban +b N: which prevents nick changes on channel", VF_VENDOR); @@ -51,38 +43,30 @@ class ModuleNoNickChange : public Module tokens["EXTBAN"].push_back('N'); } - ModResult OnUserPreNick(User* user, const std::string &newnick) CXX11_OVERRIDE + ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE { - if (!IS_LOCAL(user)) - return MOD_RES_PASSTHRU; - - for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) + for (User::ChanList::iterator i = user->chans.begin(); i != user->chans.end(); i++) { - Channel* curr = *i; + Channel* curr = (*i)->chan; - ModResult res = ServerInstance->OnCheckExemption(user,curr,"nonick"); + ModResult res = CheckExemption::Call(exemptionprov, user, curr, "nonick"); if (res == MOD_RES_ALLOW) continue; - if (override && user->IsOper()) + if (user->HasPrivPermission("channels/ignore-nonicks")) continue; if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet(nn))) { - user->WriteNumeric(ERR_CANTCHANGENICK, "%s :Can't change nickname while on %s (+N is set)", - user->nick.c_str(), curr->name.c_str()); + user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("Cannot change nickname while on %s (+N is set)", + curr->name.c_str())); return MOD_RES_DENY; } } return MOD_RES_PASSTHRU; } - - void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE - { - override = ServerInstance->Config->ConfValue("nonicks")->getBool("operoverride", false); - } }; MODULE_INIT(ModuleNoNickChange)