X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_samode.cpp;h=e0e751e7b83dc7a7876ce4510311e30837a01a60;hb=6d57bbe05c31c79eaad02fe81cfb9c1ed6b79c58;hp=932ed88b65c2215f76813ab6dad8d8b9a329fec7;hpb=b6dbd6caab62bc2c0d11ce5a45d511611eb9c2ef;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index 932ed88b6..e0e751e7b 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -20,48 +20,33 @@ class CommandSamode : public Command { public: - CommandSamode (InspIRCd* Instance) : Command(Instance,"SAMODE", "o", 2, false, 0) + bool active; + CommandSamode (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"SAMODE", "o", 2, false, 0) { - this->source = "m_samode.so"; syntax = " {}"; + active = false; } CmdResult Handle (const std::vector& parameters, User *user) { - /* - * Handles an SAMODE request. Notifies all +s users. - */ - ServerInstance->SendMode(parameters, ServerInstance->FakeClient); - + this->active = true; + ServerInstance->Parser->CallHandler("MODE", parameters, user); if (ServerInstance->Modes->GetLastParse().length()) - { - ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse()); - - std::string channel = parameters[0]; - ServerInstance->PI->SendMode(channel, ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate()); - - return CMD_LOCALONLY; - } - else - { - user->WriteServ("NOTICE %s :*** Invalid SAMODE sequence.", user->nick.c_str()); - } - - return CMD_FAILURE; + ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " used SAMODE: " +ServerInstance->Modes->GetLastParse()); + this->active = false; + return CMD_SUCCESS; } }; class ModuleSaMode : public Module { - CommandSamode* mycommand; + CommandSamode cmd; public: ModuleSaMode(InspIRCd* Me) - : Module(Me) + : Module(Me), cmd(Me, this) { - - mycommand = new CommandSamode(ServerInstance); - ServerInstance->AddCommand(mycommand); - + ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->Attach(I_OnAccessCheck, this); } virtual ~ModuleSaMode() @@ -70,7 +55,20 @@ class ModuleSaMode : public Module virtual Version GetVersion() { - return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION); + return Version("$Id$", VF_VENDOR, API_VERSION); + } + + virtual ModResult OnAccessCheck(User* source,User* dest,Channel* channel,int access_type) + { + if (cmd.active) + return MOD_RES_ALLOW; + return MOD_RES_PASSTHRU; + } + + void Prioritize() + { + Module *override = ServerInstance->Modules->Find("m_override.so"); + ServerInstance->Modules->SetPriority(this, I_OnAccessCheck, PRIORITY_BEFORE, &override); } };