2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
5 * Copyright (C) 2013, 2017-2019 Sadie Powell <sadie@witchery.services>
6 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
8 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10 * This file is part of InspIRCd. InspIRCd is free software: you can
11 * redistribute it and/or modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation, version 2.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # pragma GCC diagnostic push
28 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
33 namespace ServerProtocol
35 class BroadcastEventListener;
36 class LinkEventListener;
37 class MessageEventListener;
38 class SyncEventListener;
41 class ServerProtocol::BroadcastEventListener
42 : public Events::ModuleEventListener
45 BroadcastEventListener(Module* mod)
46 : ModuleEventListener(mod, "event/server-broadcast")
50 /** Fired when a channel message is being broadcast across the network.
51 * @param channel The channel which is having a message sent to it.
52 * @param server The server which might have a message broadcast to it.
53 * @return Either MOD_RES_ALLOW to always send the message to the server, MOD_RES_DENY to never
54 * send the message to the server or MOD_RES_PASSTHRU if no module handled the event.
56 virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; }
59 class ServerProtocol::LinkEventListener
60 : public Events::ModuleEventListener
63 LinkEventListener(Module* mod)
64 : ModuleEventListener(mod, "event/server-link")
68 /** Fired when a server has linked to the network.
69 * @param server Server that recently linked.
71 virtual void OnServerLink(const Server* server) { }
73 /** Fired when a server has finished bursting.
74 * @param server Server that recently finished bursting.
76 virtual void OnServerBurst(const Server* server) { }
78 /** Fired when a server splits
79 * @param server Server that split
80 * @param error Whether the server split because of an error.
82 virtual void OnServerSplit(const Server* server, bool error) { OnServerSplit(server); }
84 /** Fired when a server splits
85 * @param server Server that split
87 DEPRECATED_METHOD(virtual void OnServerSplit(const Server* server)) { }
90 class ServerProtocol::MessageEventListener
91 : public Events::ModuleEventListener
94 MessageEventListener(Module* mod)
95 : ModuleEventListener(mod, "event/server-message")
99 /** Fired when a server message is being sent by a user.
100 * @param source The user who sent the message.
101 * @param name The name of the command which was sent.
102 * @param tags The tags which will be sent with the message.
104 virtual void OnBuildMessage(User* source, const char* name, ClientProtocol::TagMap& tags) { }
106 /** Fired when a server message is being sent by a server.
107 * @param source The server who sent the message.
108 * @param name The name of the command which was sent.
109 * @param tags The tags which will be sent with the message.
111 virtual void OnBuildMessage(Server* source, const char* name, ClientProtocol::TagMap& tags) { }
114 class ServerProtocol::SyncEventListener
115 : public Events::ModuleEventListener
118 SyncEventListener(Module* mod)
119 : ModuleEventListener(mod, "event/server-sync")
123 /** Allows modules to synchronize user metadata during a netburst. This will
124 * be called for every user visible on your side of the burst.
125 * @param user The user being synchronized.
126 * @param server The target of the burst.
128 virtual void OnSyncUser(User* user, ProtocolServer& server) { }
130 /** Allows modules to synchronize channel metadata during a netburst. This will
131 * be called for every channel visible on your side of the burst.
132 * @param chan The channel being synchronized.
133 * @param server The target of the burst.
135 virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
137 /** Allows modules to synchronize network metadata during a netburst.
138 * @param server The target of the burst.
140 virtual void OnSyncNetwork(ProtocolServer& server) { }
143 /** Compatibility struct for <3.3.0 modules. */
144 class ServerEventListener
145 : public ServerProtocol::BroadcastEventListener
146 , public ServerProtocol::LinkEventListener
147 , public ServerProtocol::SyncEventListener
150 ServerEventListener(Module* mod)
151 : ServerProtocol::BroadcastEventListener(mod)
152 , ServerProtocol::LinkEventListener(mod)
153 , ServerProtocol::SyncEventListener(mod)
159 # pragma GCC diagnostic pop