]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sapart.cpp
This will royally fuck 1.2's linking right now, but..
[user/henk/code/inspircd.git] / src / modules / m_sapart.cpp
index 6db3661b519a6eef03b3e4538442a1cd8ca34600..1713e07c0cba3fa041314283e8e48a8d634689ee 100644 (file)
@@ -2,26 +2,19 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                    E-mail:
- *             <brain@chatspike.net>
- *               <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
  * This program is free but copyrighted software; see
- *         the file COPYING for details.
+ *            the file COPYING for details.
  *
  * ---------------------------------------------------
  */
 
-using namespace std;
-
-#include <stdio.h>
-#include <string>
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "inspircd.h"
 
 /* $ModDesc: Provides support for unreal-style SAPART command */
 
@@ -48,30 +41,45 @@ class cmd_sapart : public command_t
                                return CMD_FAILURE;
                        }
 
-                       if (!channel->PartUser(dest, dest->nick))
-                               delete channel;
-                       chanrec* n = ServerInstance->FindChan(parameters[1]);
-                       if (!n)
-                       {
-                               ServerInstance->WriteOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
-                               return CMD_SUCCESS;
-                       }
-                       else
+                       /* For local clients, directly part them generating a PART message. For remote clients,
+                        * just return CMD_SUCCESS knowing the protocol module will route the SAPART to the users
+                        * local server and that will generate the PART instead
+                        */
+                       if (IS_LOCAL(dest))
                        {
-                               if (!n->HasUser(dest))
+                               if (!channel->PartUser(dest, dest->nick))
+                                       delete channel;
+                               chanrec* n = ServerInstance->FindChan(parameters[1]);
+                               if (!n)
                                {
-                                       ServerInstance->WriteOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
+                                       ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
                                        return CMD_SUCCESS;
                                }
                                else
                                {
-                                       user->WriteServ("NOTICE %s :*** Unable to make %s part %s",user->nick, dest->nick, parameters[1]);
-                                       return CMD_FAILURE;
+                                       if (!n->HasUser(dest))
+                                       {
+                                               ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
+                                               return CMD_SUCCESS;
+                                       }
+                                       else
+                                       {
+                                               user->WriteServ("NOTICE %s :*** Unable to make %s part %s",user->nick, dest->nick, parameters[1]);
+                                               return CMD_FAILURE;
+                                       }
                                }
                        }
+                       else
+                       {
+                               ServerInstance->WriteOpers("*** "+std::string(user->nick)+" sent remote SAPART to make "+dest->nick+" part "+parameters[1]);
+                       }
 
                        return CMD_SUCCESS;
                }
+               else
+               {
+                       user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick);
+               }
 
                return CMD_FAILURE;
        }
@@ -83,7 +91,7 @@ class ModuleSapart : public Module
        cmd_sapart*     mycommand;
  public:
        ModuleSapart(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                
                mycommand = new cmd_sapart(ServerInstance);
@@ -96,34 +104,10 @@ class ModuleSapart : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,1,VF_VENDOR,API_VERSION);
-       }
-       
-};
-
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleSapartFactory : public ModuleFactory
-{
- public:
-       ModuleSapartFactory()
-       {
-       }
-       
-       ~ModuleSapartFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleSapart(Me);
+               return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
        }
        
 };
 
-
-extern "C" void * init_module( void )
-{
-       return new ModuleSapartFactory;
-}
+MODULE_INIT(ModuleSapart)