]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_saquit.cpp
there were two.. yes, you're right Special
[user/henk/code/inspircd.git] / src / modules / m_saquit.cpp
index 4900a3db80af9e7dfc16aa05b32181990260a283..d2fa8e89b086010c0eb2402ed0ca48e2af5860b3 100644 (file)
@@ -2,71 +2,57 @@
  *       | 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;
-
-/*
- * SAQUIT module for InspIRCd
- *  Author: w00t
- *  Version: 1.0.0.0
- *
- *  Syntax: /SAQUIT <user> [reason]
- *  Makes it appear as though <user> has /quit with [reason]
- *  
- */
-
-#include <stdio.h>
-#include <string>
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "inspircd.h"
 
 /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
 
-static Server *Srv;
-extern InspIRCd* ServerInstance;
-
+/** Handle /SAQUIT
+ */
 class cmd_saquit : public command_t
 {
  public:
      cmd_saquit () : command_t("SAQUIT",'o',2)
cmd_saquit (InspIRCd* Instance) : command_t(Instance,"SAQUIT",'o',2)
        {
                this->source = "m_saquit.so";
                syntax = "<nick> <reason>";
        }
 
-       void Handle (const char** parameters, int pcnt, userrec *user)
+       CmdResult Handle (const char** parameters, int pcnt, userrec *user)
        {
                userrec* dest = ServerInstance->FindNick(parameters[0]);
                if (dest)
                {
-                       if (Srv->IsUlined(dest->server))
+                       if (ServerInstance->ULine(dest->server))
                        {
                                user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
-                               return;
+                               return CMD_FAILURE;
                        }
-                       std::string line = "";
-                       for (int i = 1; i < pcnt - 1; i++)
-                       {
-                               line = line + std::string(parameters[i]) + " ";
-                       }
-                       line = line + std::string(parameters[pcnt-1]);
-               
-                       ServerInstance->WriteOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
+                       irc::stringjoiner reason_join(" ", parameters, 1, pcnt - 1);
+                       std::string line = reason_join.GetJoined();
+
+                       ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
                        userrec::QuitUser(ServerInstance, dest, line);
+
+                       return CMD_SUCCESS;
                }
+               else
+               {
+                       user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick, parameters[0]);
+               }
+
+               return CMD_FAILURE;
        }
 };
 
@@ -74,12 +60,12 @@ class ModuleSaquit : public Module
 {
        cmd_saquit*     mycommand;
  public:
-       ModuleSaquit(Server* Me)
-               : Module::Module(Me)
+       ModuleSaquit(InspIRCd* Me)
+               : Module(Me)
        {
-               Srv = Me;
-               mycommand = new cmd_saquit();
-               Srv->AddCommand(mycommand);
+               
+               mycommand = new cmd_saquit(ServerInstance);
+               ServerInstance->AddCommand(mycommand);
        }
        
        virtual ~ModuleSaquit()
@@ -88,34 +74,9 @@ class ModuleSaquit : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,1,VF_VENDOR);
+               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
        }
        
 };
 
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleSaquitFactory : public ModuleFactory
-{
- public:
-       ModuleSaquitFactory()
-       {
-       }
-       
-       ~ModuleSaquitFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(Server* Me)
-       {
-               return new ModuleSaquit(Me);
-       }
-       
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModuleSaquitFactory;
-}
-
+MODULE_INIT(ModuleSaquit)