2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Sadie Powell <sadie@witchery.services>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 class TagMessageDetails;
31 class CTCTags::TagMessage : public ClientProtocol::Message
34 TagMessage(User* source, const Channel* targetchan, const ClientProtocol::TagMap& Tags)
35 : ClientProtocol::Message("TAGMSG", source)
37 PushParamRef(targetchan->name);
41 TagMessage(User* source, const User* targetuser, const ClientProtocol::TagMap& Tags)
42 : ClientProtocol::Message("TAGMSG", source)
44 if (targetuser->registered & REG_NICK)
45 PushParamRef(targetuser->nick);
51 TagMessage(User* source, const char* targetstr, const ClientProtocol::TagMap& Tags)
52 : ClientProtocol::Message("TAGMSG", source)
59 class CTCTags::TagMessageDetails
62 /** Whether to echo the tags at all. */
65 /* Whether to send the original tags back to clients with echo-message support. */
68 /** The users who are exempted from receiving this message. */
71 /** IRCv3 message tags sent to the server by the user. */
72 const ClientProtocol::TagMap tags_in;
74 /** IRCv3 message tags sent out to users who get this message. */
75 ClientProtocol::TagMap tags_out;
77 TagMessageDetails(const ClientProtocol::TagMap& tags)
79 , echo_original(false)
85 class CTCTags::EventListener
86 : public Events::ModuleEventListener
89 EventListener(Module* mod, unsigned int eventprio = DefaultPriority)
90 : ModuleEventListener(mod, "event/tagmsg", eventprio)
95 /** Called before a user sends a tag message to a channel, a user, or a server glob mask.
96 * @param user The user sending the message.
97 * @param target The target of the message. This can either be a channel, a user, or a server
99 * @param details Details about the message such as the message tags or whether to echo. See the
100 * TagMessageDetails class for more information.
101 * @return MOD_RES_ALLOW to explicitly allow the message, MOD_RES_DENY to explicitly deny the
102 * message, or MOD_RES_PASSTHRU to let another module handle the event.
104 virtual ModResult OnUserPreTagMessage(User* user, const MessageTarget& target, TagMessageDetails& details) { return MOD_RES_PASSTHRU; }
106 /** Called immediately after a user sends a tag message to a channel, a user, or a server glob mask.
107 * @param user The user sending the message.
108 * @param target The target of the message. This can either be a channel, a user, or a server
110 * @param details Details about the message such as the message tags or whether to echo. See the
111 * TagMessageDetails class for more information.
113 virtual void OnUserPostTagMessage(User* user, const MessageTarget& target, const TagMessageDetails& details) { }
115 /** Called immediately before a user sends a tag message to a channel, a user, or a server glob mask.
116 * @param user The user sending the message.
117 * @param target The target of the message. This can either be a channel, a user, or a server
119 * @param details Details about the message such as the message tags or whether to echo. See the
120 * TagMessageDetails class for more information.
122 virtual void OnUserTagMessage(User* user, const MessageTarget& target, const TagMessageDetails& details) { }
124 /** Called when a tag message sent by a user to a channel, a user, or a server glob mask is blocked.
125 * @param user The user sending the message.
126 * @param target The target of the message. This can either be a channel, a user, or a server
128 * @param details Details about the message such as the message tags or whether to echo. See the
129 * TagMessageDetails class for more information.
131 virtual void OnUserTagMessageBlocked(User* user, const MessageTarget& target, const TagMessageDetails& details) { }