2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2017-2018 Attila Molnar <attilamolnar@hush.com>
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 /** The users who are exempted from receiving this message. */
45 /* The original message as sent by the user. */
46 const std::string original_text;
48 /** IRCv3 message tags sent to the server by the user. */
49 const ClientProtocol::TagMap tags_in;
51 /** IRCv3 message tags sent out to users who get this message. */
52 ClientProtocol::TagMap tags_out;
54 /** The message which will be sent to clients. */
57 /** The type of message. */
58 const MessageType type;
60 /** Determines whether the specified message is a CTCP. If the specified message
61 * is a CTCP then the CTCP name and CTCP body are extracted and stored in the
62 * name and body references.
63 * @param name The location to store the parsed CTCP name.
64 * @param body The location to store the parsed CTCP body.
66 virtual bool IsCTCP(std::string& name, std::string& body) const = 0;
68 /** Determines whether the specified message is a CTCP. If the specified message
69 * is a CTCP then the CTCP name is extracted and stored in the name reference.
70 * @param name The location to store the parsed CTCP name.
72 virtual bool IsCTCP(std::string& name) const = 0;
74 /** Determines whether the specified message is a CTCP. */
75 virtual bool IsCTCP() const = 0;
78 MessageDetails(MessageType mt, const std::string& msg, const ClientProtocol::TagMap& tags)
80 , echo_original(false)
89 /** Represents the target of a message (NOTICE, PRIVMSG, etc). */
90 class CoreExport MessageTarget
93 /** An enumeration of possible message target types. */
96 /** The target of the message is a user. */
99 /** The target of the message is a channel. */
102 /** The target of the message is a server. */
107 /** The target of the message. */
111 /** If type is TYPE_CHANNEL and the user specified a status rank. */
114 /** The type of the target of the message. If this is TYPE_CHANNEL then dest
115 * is a Channel*, TYPE_USER then dest is a User*, and TYPE_SERVER then dest is
116 * a std::string* containing a server glob.
118 MessageTarget::TargetType type;
120 /** Initialises a new channel message target.
121 * @param channel The channel which is the target of the message.
122 * @param statuschar The lowest status rank that the message is being sent to.
124 MessageTarget(Channel* channel, char statuschar)
131 /** Initialises a new user message target.
132 * @param user The user which is the target of the message.
134 MessageTarget(User* user)
141 /** Initialises a new server message target.
142 * @param server The server glob which is the target of the message.
144 MessageTarget(std::string* server)
151 /** Retrieves the target of this message. */
155 return static_cast<T*>(dest);
158 /** Retrieves the name of the target of this message. */
159 const std::string& GetName() const
164 return Get<Channel>()->name;
166 return Get<User>()->nick;
168 return *Get<std::string>();
171 // We should never reach this point during a normal execution but
172 // handle it just in case.
173 static const std::string target = "*";