2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018 Attila Molnar <attilamolnar@hush.com>
5 * Copyright (C) 2017-2018, 2020 Sadie Powell <sadie@witchery.services>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /** Whether message was a PRIVMSG or a NOTICE. */
26 /** The message is a PRIVMSG. */
29 /** The message is a NOTICE. */
33 class CoreExport MessageDetails
36 /** Whether to echo the message at all. */
39 /* Whether to send the original message back to clients with echo-message support. */
42 /** Whether to update the source user's idle time. */
45 /** The users who are exempted from receiving this message. */
48 /* The original message as sent by the user. */
49 const std::string original_text;
51 /** IRCv3 message tags sent to the server by the user. */
52 const ClientProtocol::TagMap tags_in;
54 /** IRCv3 message tags sent out to users who get this message. */
55 ClientProtocol::TagMap tags_out;
57 /** The message which will be sent to clients. */
60 /** The type of message. */
63 /** Determines whether the specified message is a CTCP. If the specified message
64 * is a CTCP then the CTCP name and CTCP body are extracted and stored in the
65 * name and body references.
66 * @param name The location to store the parsed CTCP name.
67 * @param body The location to store the parsed CTCP body.
69 virtual bool IsCTCP(std::string& name, std::string& body) const = 0;
71 /** Determines whether the specified message is a CTCP. If the specified message
72 * is a CTCP then the CTCP name is extracted and stored in the name reference.
73 * @param name The location to store the parsed CTCP name.
75 virtual bool IsCTCP(std::string& name) const = 0;
77 /** Determines whether the specified message is a CTCP. */
78 virtual bool IsCTCP() const = 0;
81 MessageDetails(MessageType mt, const std::string& msg, const ClientProtocol::TagMap& tags)
83 , echo_original(false)
93 /** Represents the target of a message (NOTICE, PRIVMSG, etc). */
94 class CoreExport MessageTarget
97 /** An enumeration of possible message target types. */
100 /** The target of the message is a user. */
103 /** The target of the message is a channel. */
106 /** The target of the message is a server. */
111 /** The target of the message. */
115 /** If type is TYPE_CHANNEL and the user specified a status rank. */
118 /** The type of the target of the message. If this is TYPE_CHANNEL then dest
119 * is a Channel*, TYPE_USER then dest is a User*, and TYPE_SERVER then dest is
120 * a std::string* containing a server glob.
122 MessageTarget::TargetType type;
124 /** Initialises a new channel message target.
125 * @param channel The channel which is the target of the message.
126 * @param statuschar The lowest status rank that the message is being sent to.
128 MessageTarget(Channel* channel, char statuschar)
135 /** Initialises a new user message target.
136 * @param user The user which is the target of the message.
138 MessageTarget(User* user)
145 /** Initialises a new server message target.
146 * @param server The server glob which is the target of the message.
148 MessageTarget(std::string* server)
155 /** Retrieves the target of this message. */
159 return static_cast<T*>(dest);
162 /** Retrieves the name of the target of this message. */
163 const std::string& GetName() const
168 return Get<Channel>()->name;
170 return Get<User>()->nick;
172 return *Get<std::string>();
175 // We should never reach this point during a normal execution but
176 // handle it just in case.
177 static const std::string target = "*";