]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/clientprotocolmsg.h
Fix the 'w' extban not being added to the EXTBAN 005 numeric.
[user/henk/code/inspircd.git] / include / clientprotocolmsg.h
index d1562d7d10207663cb36b5c578e3ab28957ed236..53122cff9965ca9652f696230b521d9f2c38e5a9 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2018, 2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2018 Attila Molnar <attilamolnar@hush.com>
  *
  * 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
@@ -67,7 +68,7 @@ class ClientProtocol::Messages::Numeric : public ClientProtocol::Message
         * @param user User to send the numeric to. May be unregistered, must remain valid as long as this object is alive.
         */
        Numeric(const ::Numeric::Numeric& num, User* user)
-               : ClientProtocol::Message(NULL, (num.GetServer() ? num.GetServer()->GetName() : ServerInstance->Config->ServerName))
+               : ClientProtocol::Message(NULL, (num.GetServer() ? num.GetServer() : ServerInstance->FakeClient->server)->GetName())
        {
                if (user->registered & REG_NICK)
                        PushParamRef(user->nick);
@@ -81,7 +82,7 @@ class ClientProtocol::Messages::Numeric : public ClientProtocol::Message
         * @param target Target string, must stay valid as long as this object is alive.
         */
        Numeric(const ::Numeric::Numeric& num, const std::string& target)
-               : ClientProtocol::Message(NULL, (num.GetServer() ? num.GetServer()->GetName() : ServerInstance->Config->ServerName))
+               : ClientProtocol::Message(NULL, (num.GetServer() ? num.GetServer() : ServerInstance->FakeClient->server)->GetName())
        {
                PushParamRef(target);
                InitFromNumeric(num);
@@ -91,7 +92,7 @@ class ClientProtocol::Messages::Numeric : public ClientProtocol::Message
         * @param num Numeric number.
         */
        Numeric(unsigned int num)
-               : ClientProtocol::Message(NULL, ServerInstance->Config->ServerName)
+               : ClientProtocol::Message(NULL, ServerInstance->Config->GetServerName())
        {
                InitCommand(num);
                PushParam("*");
@@ -484,14 +485,24 @@ class ClientProtocol::Messages::Privmsg : public ClientProtocol::Message
 
        /** Constructor, string source, string target, copies text.
         * @param source Source user.
-        * @param targetuser Target user.
+        * @param target Target string.
         * @param text Privmsg text, will be copied.
         * @param mt Message type.
+        * @param status Prefix character for status messages. If non-zero the message is a status message. Optional, defaults to 0.
         */
-       Privmsg(const std::string& source, const std::string& target, const std::string& text, MessageType mt = MSG_PRIVMSG)
+       Privmsg(const std::string& source, const std::string& target, const std::string& text, MessageType mt = MSG_PRIVMSG, char status = 0)
                : ClientProtocol::Message(CommandStrFromMsgType(mt), source)
        {
-               PushParam(target);
+               if (status)
+               {
+                       std::string rawtarget(1, status);
+                       rawtarget.append(target);
+                       PushParam(rawtarget);
+               }
+               else
+               {
+                       PushParam(target);
+               }
                PushParam(text);
        }
 
@@ -524,7 +535,7 @@ class ClientProtocol::Messages::Privmsg : public ClientProtocol::Message
 
        /** Constructor, user source, string target, copies text.
         * @param source Source user.
-        * @param targetuser Target string.
+        * @param target Target string.
         * @param text Privmsg text, will not be copied.
         * @param mt Message type.
         */
@@ -564,7 +575,7 @@ class ClientProtocol::Messages::Privmsg : public ClientProtocol::Message
 
        /** Constructor, string source, string target, does not copy text.
         * @param source Source string.
-        * @param targetuser Target string.
+        * @param target Target string.
         * @param text Privmsg text, will not be copied.
         * @param mt Message type.
         */
@@ -591,7 +602,7 @@ class ClientProtocol::Messages::Privmsg : public ClientProtocol::Message
 
        /** Constructor, string source, user target, does not copy text.
         * @param source Source string.
-        * @param targetchan Target user.
+        * @param targetuser Target user.
         * @param text Privmsg text, will not be copied.
         * @param mt Message type.
         */
@@ -632,7 +643,7 @@ struct ClientProtocol::Messages::Ping : public ClientProtocol::Message
        Ping()
                : ClientProtocol::Message("PING")
        {
-               PushParamRef(ServerInstance->Config->ServerName);
+               PushParamRef(ServerInstance->Config->GetServerName());
        }
 
        /** Constructor.
@@ -652,11 +663,14 @@ struct ClientProtocol::Messages::Pong : public ClientProtocol::Message
 {
        /** Constructor.
         * @param cookie Ping cookie. Must remain valid as long as this object is alive.
+        * @param server Pinged server. Must remain valid as long as this object is alive if non-empty.
         */
-       Pong(const std::string& cookie)
-               : ClientProtocol::Message("PONG", ServerInstance->Config->ServerName)
+       Pong(const std::string& cookie, const std::string& server = "")
+               : ClientProtocol::Message("PONG", ServerInstance->Config->GetServerName())
        {
-               PushParamRef(ServerInstance->Config->ServerName);
+               PushParamRef(ServerInstance->Config->GetServerName());
+               if (!server.empty())
+                       PushParamRef(server);
                PushParamRef(cookie);
        }
 };