]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Allow a statusmsg to have multiple statuses and pick the lowest.
authorSadie Powell <sadie@witchery.services>
Thu, 25 Feb 2021 06:47:34 +0000 (06:47 +0000)
committerSadie Powell <sadie@witchery.services>
Thu, 25 Feb 2021 06:47:34 +0000 (06:47 +0000)
This is pretty much useless but other implementations support it
so we have to also support it for compatibility.

include/numerics.h
src/coremods/core_message.cpp
src/modules/m_ircv3_ctctags.cpp

index 98abf2bbedbf4dd3915a7ec6cd293e7efd52586c..a50b7c518dfce348e564f0ff730705106b0dffd5 100644 (file)
@@ -114,6 +114,7 @@ enum
        ERR_TOOMANYCHANNELS             = 405,
        ERR_WASNOSUCHNICK               = 406,
        ERR_NOSUCHSERVICE               = 408, // From RFC 2812.
+       ERR_NORECIPIENT                 = 411,
        ERR_NOTEXTTOSEND                = 412,
        ERR_UNKNOWNCOMMAND              = 421,
        ERR_NOMOTD                      = 422,
index 75abd69005966db91c05634429b644b4582da21d..94eefee2271095b245a41e115f723443db37f8ca 100644 (file)
@@ -298,15 +298,26 @@ class CommandMessage : 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);
index 2856579870839a2441b0f2a0b9e9b466ce932ad3..6ef1ed30d45fb05c5dd703982718e6eaae3dda99 100644 (file)
@@ -234,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);