2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
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);
42 TagMessage(User* source, const User* targetuser, const ClientProtocol::TagMap& Tags)
43 : ClientProtocol::Message("TAGMSG", source)
45 if (targetuser->registered & REG_NICK)
46 PushParamRef(targetuser->nick);
53 TagMessage(User* source, const char* targetstr, const ClientProtocol::TagMap& Tags)
54 : ClientProtocol::Message("TAGMSG", source)
62 class CTCTags::TagMessageDetails
65 /** Whether to echo the tags at all. */
68 /* Whether to send the original tags back to clients with echo-message support. */
71 /** The users who are exempted from receiving this message. */
74 /** IRCv3 message tags sent to the server by the user. */
75 const ClientProtocol::TagMap tags_in;
77 /** IRCv3 message tags sent out to users who get this message. */
78 ClientProtocol::TagMap tags_out;
80 TagMessageDetails(const ClientProtocol::TagMap& tags)
82 , echo_original(false)
88 class CTCTags::EventListener
89 : public Events::ModuleEventListener
92 EventListener(Module* mod, unsigned int eventprio = DefaultPriority)
93 : ModuleEventListener(mod, "event/tagmsg", eventprio)
98 /** Called before a user sends a tag message to a channel, a user, or a server glob mask.
99 * @param user The user sending the message.
100 * @param target The target of the message. This can either be a channel, a user, or a server
102 * @param details Details about the message such as the message tags or whether to echo. See the
103 * TagMessageDetails class for more information.
104 * @return MOD_RES_ALLOW to explicitly allow the message, MOD_RES_DENY to explicitly deny the
105 * message, or MOD_RES_PASSTHRU to let another module handle the event.
107 virtual ModResult OnUserPreTagMessage(User* user, const MessageTarget& target, TagMessageDetails& details) { return MOD_RES_PASSTHRU; }
109 /** Called immediately after a user sends a tag message to a channel, a user, or a server glob mask.
110 * @param user The user sending the message.
111 * @param target The target of the message. This can either be a channel, a user, or a server
113 * @param details Details about the message such as the message tags or whether to echo. See the
114 * TagMessageDetails class for more information.
116 virtual void OnUserPostTagMessage(User* user, const MessageTarget& target, const TagMessageDetails& details) { }
118 /** Called immediately before a user sends a tag message to a channel, a user, or a server glob mask.
119 * @param user The user sending the message.
120 * @param target The target of the message. This can either be a channel, a user, or a server
122 * @param details Details about the message such as the message tags or whether to echo. See the
123 * TagMessageDetails class for more information.
125 virtual void OnUserTagMessage(User* user, const MessageTarget& target, const TagMessageDetails& details) { }
127 /** Called when a tag message sent by a user to a channel, a user, or a server glob mask is blocked.
128 * @param user The user sending the message.
129 * @param target The target of the message. This can either be a channel, a user, or a server
131 * @param details Details about the message such as the message tags or whether to echo. See the
132 * TagMessageDetails class for more information.
134 virtual void OnUserTagMessageBlocked(User* user, const MessageTarget& target, const TagMessageDetails& details) { }