]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_servprotect.cpp
m_namesx, m_uhnames Don't convert the command name to irc::string in OnPreCommand()
[user/henk/code/inspircd.git] / src / modules / m_servprotect.cpp
index b38f18cc97744d4330e08caad4aaea7fb45f2fe8..c98eebec36ecd04975fe682b74408585e7f05778 100644 (file)
@@ -1,26 +1,34 @@
-/*       +------------------------------------+
- *       | 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 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
  *
- * 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 support for Austhex style +k / UnrealIRCD +S services mode */
+/* $ModDesc: Provides usermode +k to protect services from kicks, kills and mode changes. */
 
 /** Handles user mode +k
  */
 class ServProtectMode : public ModeHandler
 {
  public:
-       ServProtectMode(Module* Creator) : ModeHandler(Creator, 'k', PARAM_NONE, MODETYPE_USER) { oper = true; }
+       ServProtectMode(Module* Creator) : ModeHandler(Creator, "servprotect", 'k', PARAM_NONE, MODETYPE_USER) { oper = true; }
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
@@ -56,7 +64,7 @@ class ModuleServProtectMode : public Module
 
        Version GetVersion()
        {
-               return Version("Provides support for Austhex style +k / UnrealIRCD +S services mode", VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("Provides usermode +k to protect services from kicks, kills, and mode changes.", VF_VENDOR);
        }
 
        void OnWhois(User* src, User* dst)
@@ -79,11 +87,12 @@ class ModuleServProtectMode : public Module
                        User *u = ServerInstance->FindNick(param);
                        if (u)
                        {
+                               Membership* memb = chan->GetUser(u);
                                /* The target user has +k set on themselves, and you are trying to remove a privilege mode the user has set on themselves.
                                 * This includes any prefix permission mode, even those registered in other modules, e.g. +qaohv. Using ::ModeString()
                                 * here means that the number of modes is restricted to only modes the user has, limiting it to as short a loop as possible.
                                 */
-                               if (u->IsModeSet('k') && ServerInstance->Modes->ModeString(u, chan, false).find(mode) != std::string::npos)
+                               if (u->IsModeSet('k') && memb && memb->modes.find(mode) != std::string::npos)
                                {
                                        /* BZZZT, Denied! */
                                        user->WriteNumeric(482, "%s %s :You are not permitted to remove privileges from %s services", user->nick.c_str(), chan->name.c_str(), ServerInstance->Config->Network.c_str());