]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ircv3_ctctags.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / modules / m_ircv3_ctctags.cpp
index 3815b025d3900c5002bddc82fcbb7b6cb4ca3901..8dd83bd7f525777cdf0c089ee32c9c33f107584a 100644 (file)
@@ -2,7 +2,7 @@
  * InspIRCd -- Internet Relay Chat Daemon
  *
  *   Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
- *   Copyright (C) 2018-2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2018-2021 Sadie Powell <sadie@witchery.services>
  *
  * 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
@@ -109,7 +109,10 @@ class CommandTagMsg : public Command
                // If the source isn't allowed to mass message users then reject
                // the attempt to mass-message users.
                if (!source->HasPrivPermission("users/mass-message"))
+               {
+                       source->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
                        return CMD_FAILURE;
+               }
 
                // Extract the server glob match from the target parameter.
                std::string servername(parameters[0], 1);
@@ -231,15 +234,26 @@ class CommandTagMsg : public Command
                if (parameters[0][0] == '$')
                        return HandleServerTarget(user, parameters);
 
-               // If the message begins with a status character then look it up.
+               // If the message begins with one or more status characters then look them up.
                const char* target = parameters[0].c_str();
-               PrefixMode* pmh = ServerInstance->Modes->FindPrefix(target[0]);
-               if (pmh)
-                       target++;
+               PrefixMode* targetpfx = NULL;
+               for (PrefixMode* pfx; (pfx = ServerInstance->Modes->FindPrefix(target[0])); ++target)
+               {
+                       // We want the lowest ranked prefix specified.
+                       if (!targetpfx || pfx->GetPrefixRank() < targetpfx->GetPrefixRank())
+                               targetpfx = pfx;
+               }
+
+               if (!target[0])
+               {
+                       // The target consisted solely of prefix modes.
+                       user->WriteNumeric(ERR_NORECIPIENT, "No recipient given");
+                       return CMD_FAILURE;
+               }
 
                // The target is a channel name.
                if (*target == '#')
-                       return HandleChannelTarget(user, parameters, target, pmh);
+                       return HandleChannelTarget(user, parameters, target, targetpfx);
 
                // The target is a nickname.
                return HandleUserTarget(user, parameters);