diff options
| author | 2026-06-17 15:03:07 +0100 | |
|---|---|---|
| committer | 2026-06-17 15:03:50 +0100 | |
| commit | ef88adc36d5c5214a15e653a6cfe827660bdfb0a (patch) | |
| tree | fdea308b8f27b441aeee3645359aa3ff8a6f9645 | |
| parent | Allow modules to control which clients receive an ISupport diff. (diff) | |
Allow an event hook for after messages are sent to a client.
| -rw-r--r-- | include/clientprotocol.h | 15 | ||||
| -rw-r--r-- | src/clientprotocol.cpp | 6 | ||||
| -rw-r--r-- | src/users.cpp | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/include/clientprotocol.h b/include/clientprotocol.h index a68aa0541..61db79037 100644 --- a/include/clientprotocol.h +++ b/include/clientprotocol.h @@ -543,6 +543,12 @@ public: * @param messagelist List to fill in with messages to send to the user for the event */ void GetMessagesForUser(LocalUser* user, MessageList& messagelist); + + /** Called after a list of messages was sent to a user. + * @param user User that messages were sent to. + * @param messagelist List containing messages that were sent to the user for the event. + */ + void PostSendMessagesToUser(LocalUser* user, const MessageList& messagelist); }; class CoreExport ClientProtocol::MessageTagEvent @@ -648,6 +654,15 @@ public: * MOD_RES_ALLOW to send the messages in messagelist to the user and to not run other hooks. */ virtual ModResult OnPreEventSend(LocalUser* user, const ClientProtocol::Event& ev, ClientProtocol::MessageList& messagelist) = 0; + + /** Called for each user that received the event. + * @param user User the message list was sent to. + * @param ev Event associated with the messages. + * @param messagelist List of messages that were sent to the user. + */ + virtual void OnPostEventSend(LocalUser* user, const ClientProtocol::Event& ev, const ClientProtocol::MessageList& messagelist) + { + } }; /** Event provider for client protocol events. diff --git a/src/clientprotocol.cpp b/src/clientprotocol.cpp index 519c6b21b..de3516707 100644 --- a/src/clientprotocol.cpp +++ b/src/clientprotocol.cpp @@ -175,3 +175,9 @@ void ClientProtocol::Event::GetMessagesForUser(LocalUser* user, MessageList& mes if (res == MOD_RES_DENY) messagelist.clear(); } + +void ClientProtocol::Event::PostSendMessagesToUser(LocalUser* user, const MessageList& messagelist) +{ + if (this->event) + this->event->Call(&EventHook::OnPostEventSend, user, *this, messagelist); +} diff --git a/src/users.cpp b/src/users.cpp index b366ed951..a1df507c4 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -764,6 +764,7 @@ void LocalUser::Send(ClientProtocol::Event& protoev, ClientProtocol::MessageList if (res != MOD_RES_DENY) Write(serializer->SerializeForUser(this, curr)); } + protoev.PostSendMessagesToUser(this, msglist); } void User::WriteNumeric(const Numeric::Numeric& numeric) |
