X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_remove.cpp;h=d4b7ca42fcefa22579cd6536b93644f63bff603c;hb=3a01b55a118d4937b75541fbf385180f7106fa12;hp=51cbf335af43d58d1eeb1ca2c107cb72619630e0;hpb=349106f3f9f75d7f957fc5d1e71ca650f4807bb9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 51cbf335a..d4b7ca42f 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -36,7 +36,6 @@ */ class RemoveBase : public Command { - private: bool& supportnokicks; public: @@ -69,9 +68,9 @@ class RemoveBase : public Command channel = ServerInstance->FindChan(channame); /* Fix by brain - someone needs to learn to validate their input! */ - if (!target || !channel) + if ((!target) || (target->registered != REG_ALL) || (!channel)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), !target ? username.c_str() : channame.c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), !channel ? channame.c_str() : username.c_str()); return CMD_FAILURE; } @@ -102,6 +101,10 @@ class RemoveBase : public Command */ if ((!IS_LOCAL(user)) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && (tlevel != 50000))) { + // REMOVE/FPART will be sent to the target's server and it will reply with a PART (or do nothing if it doesn't understand the command) + if (!IS_LOCAL(target)) + return CMD_SUCCESS; + std::string reasonparam; /* If a reason is given, use it */ @@ -114,7 +117,7 @@ class RemoveBase : public Command reason = "Removed by " + user->nick + ": " + reasonparam; channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s removed %s from the channel", channel->name.c_str(), user->nick.c_str(), target->nick.c_str()); - target->WriteServ("NOTICE %s :*** %s removed you from %s with the message: %s", target->nick.c_str(), user->nick.c_str(), channel->name.c_str(), reasonparam.c_str()); + target->WriteNotice("*** " + user->nick + " removed you from " + channel->name + " with the message: " + reasonparam); channel->PartUser(target, reason); } @@ -133,7 +136,7 @@ class RemoveBase : public Command return CMD_SUCCESS; } - virtual RouteDescriptor GetRouting(User* user, const std::vector& parameters) = 0; + RouteDescriptor GetRouting(User* user, const std::vector& parameters) = 0; }; /** Handle /REMOVE @@ -194,13 +197,12 @@ class ModuleRemove : public Module CommandFpart cmd2; bool supportnokicks; - public: ModuleRemove() : cmd1(this, supportnokicks), cmd2(this, supportnokicks) { } - void init() + void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(cmd1); ServerInstance->Modules->AddService(cmd2); @@ -209,25 +211,20 @@ class ModuleRemove : public Module ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - virtual void On005Numeric(std::string &output) + void On005Numeric(std::map& tokens) CXX11_OVERRIDE { - output.append(" REMOVE"); + tokens["REMOVE"]; } - virtual void OnRehash(User* user) + void OnRehash(User* user) CXX11_OVERRIDE { supportnokicks = ServerInstance->Config->ConfValue("remove")->getBool("supportnokicks"); } - virtual ~ModuleRemove() - { - } - - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Provides a /remove command, this is mostly an alternative to /kick, except makes users appear to have parted the channel", VF_OPTCOMMON | VF_VENDOR); } - }; MODULE_INIT(ModuleRemove)