]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_remove.cpp
m_spanningtree Remove unneeded #includes
[user/henk/code/inspircd.git] / src / modules / m_remove.cpp
index 460004d1b33fd04eb5bef4625708df30f777d2b7..6f7c1c3695de65e3173eb59cb36c7abdf791e7ac 100644 (file)
@@ -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 */
@@ -194,7 +197,6 @@ class ModuleRemove : public Module
        CommandFpart cmd2;
        bool supportnokicks;
 
-
  public:
        ModuleRemove() : cmd1(this, supportnokicks), cmd2(this, supportnokicks)
        {
@@ -202,16 +204,16 @@ class ModuleRemove : public Module
 
        void init()
        {
-               ServerInstance->AddCommand(&cmd1);
-               ServerInstance->AddCommand(&cmd2);
+               ServerInstance->Modules->AddService(cmd1);
+               ServerInstance->Modules->AddService(cmd2);
                OnRehash(NULL);
                Implementation eventlist[] = { I_On005Numeric, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-       virtual void On005Numeric(std::string &output)
+       virtual void On005Numeric(std::map<std::string, std::string>& tokens)
        {
-               output.append(" REMOVE");
+               tokens["REMOVE"];
        }
 
        virtual void OnRehash(User* user)
@@ -219,15 +221,10 @@ class ModuleRemove : public Module
                supportnokicks = ServerInstance->Config->ConfValue("remove")->getBool("supportnokicks");
        }
 
-       virtual ~ModuleRemove()
-       {
-       }
-
        virtual Version GetVersion()
        {
                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)