]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sakick.cpp
Get rid of the OnRemoteKill hook, make use of GetRouting() and TR_CUSTOM to route...
[user/henk/code/inspircd.git] / src / modules / m_sakick.cpp
index 8b94c934cce9433d6f856c2e5ee4c54f9122a008..0d36ca8aeb309c45ea6ade6be6d5db1b48fb5a3f 100644 (file)
@@ -1,16 +1,23 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2009 John Brooks <john.brooks@dereferenced.net>
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd.h"
 
 /* $ModDesc: Provides a SAKICK command */
@@ -20,9 +27,9 @@
 class CommandSakick : public Command
 {
  public:
-       CommandSakick (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"SAKICK", "o", 2, 3, false, 0)
+       CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3)
        {
-               syntax = "<channel> <nick> [reason]";
+               flags_needed = 'o'; Penalty = 0; syntax = "<channel> <nick> [reason]";
                TRANSLATE4(TR_TEXT, TR_NICK, TR_TEXT, TR_END);
        }
 
@@ -31,9 +38,8 @@ class CommandSakick : public Command
                User* dest = ServerInstance->FindNick(parameters[1]);
                Channel* channel = ServerInstance->FindChan(parameters[0]);
                const char* reason = "";
-               const char* servername = NULL;
 
-               if (dest && channel)
+               if ((dest) && (dest->registered == REG_ALL) && (channel))
                {
                        if (parameters.size() > 2)
                        {
@@ -56,14 +62,13 @@ class CommandSakick : public Command
                         */
                        if (IS_LOCAL(dest))
                        {
-                               if (!channel->ServerKickUser(dest, reason, servername))
-                                       delete channel;
+                               channel->KickUser(ServerInstance->FakeClient, dest, reason);
 
                                Channel *n = ServerInstance->FindChan(parameters[1]);
                                if (n && n->HasUser(dest))
                                {
                                        /* Sort-of-bug: If the command was issued remotely, this message won't be sent */
-                                       user->WriteServ("NOTICE %s :*** Unable to kick %s from %s", user->nick.c_str(), dest->nick.c_str(), parameters[0].c_str());
+                                       user->WriteNotice("*** Unable to kick " + dest->nick + " from " + parameters[0]);
                                        return CMD_FAILURE;
                                }
                        }
@@ -71,14 +76,14 @@ class CommandSakick : public Command
                        if (IS_LOCAL(user))
                        {
                                /* Locally issued command; send the snomasks */
-                               ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " SAKICKed " + dest->nick + " on " + parameters[0]);
+                               ServerInstance->SNO->WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + parameters[0]);
                        }
 
                        return CMD_SUCCESS;
                }
                else
                {
-                       user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str());
+                       user->WriteNotice("*** Invalid nickname or channel");
                }
 
                return CMD_FAILURE;
@@ -97,22 +102,20 @@ class ModuleSakick : public Module
 {
        CommandSakick cmd;
  public:
-       ModuleSakick(InspIRCd* Me)
-               : Module(Me), cmd(Me, this)
+       ModuleSakick()
+               : cmd(this)
        {
-               ServerInstance->AddCommand(&cmd);
        }
 
-       virtual ~ModuleSakick()
+       void init() CXX11_OVERRIDE
        {
+               ServerInstance->Modules->AddService(cmd);
        }
 
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("$Id$", VF_OPTCOMMON|VF_VENDOR, API_VERSION);
+               return Version("Provides a SAKICK command", VF_OPTCOMMON|VF_VENDOR);
        }
-
 };
 
 MODULE_INIT(ModuleSakick)
-