]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/modules/server.h
Use IsCTCP in blockcolor for ignoring CTCPs.
[user/henk/code/inspircd.git] / include / modules / server.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
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>
9  *
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.
13  *
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
17  * details.
18  *
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/>.
21  */
22
23
24 #pragma once
25
26 #ifdef __GNUC__
27 # pragma GCC diagnostic push
28 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
29 #endif
30
31 #include "event.h"
32
33 namespace ServerProtocol
34 {
35         class BroadcastEventListener;
36         class LinkEventListener;
37         class MessageEventListener;
38         class SyncEventListener;
39 }
40
41 class ServerProtocol::BroadcastEventListener
42         : public Events::ModuleEventListener
43 {
44  public:
45         BroadcastEventListener(Module* mod)
46                 : ModuleEventListener(mod, "event/server-broadcast")
47         {
48         }
49
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.
55          */
56         virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; }
57 };
58
59 class ServerProtocol::LinkEventListener
60         : public Events::ModuleEventListener
61 {
62  public:
63         LinkEventListener(Module* mod)
64                 : ModuleEventListener(mod, "event/server-link")
65         {
66         }
67
68         /** Fired when a server has linked to the network.
69          * @param server Server that recently linked.
70          */
71         virtual void OnServerLink(const Server* server) { }
72
73         /** Fired when a server has finished bursting.
74          * @param server Server that recently finished bursting.
75          */
76         virtual void OnServerBurst(const Server* server) { }
77
78         /** Fired when a server splits
79          * @param server Server that split
80          * @param error Whether the server split because of an error.
81          */
82         virtual void OnServerSplit(const Server* server, bool error) { OnServerSplit(server); }
83
84         /** Fired when a server splits
85          * @param server Server that split
86          */
87         DEPRECATED_METHOD(virtual void OnServerSplit(const Server* server)) { }
88 };
89
90 class ServerProtocol::MessageEventListener
91         : public Events::ModuleEventListener
92 {
93  public:
94         MessageEventListener(Module* mod)
95                 : ModuleEventListener(mod, "event/server-message")
96         {
97         }
98
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.
103          */
104         virtual void OnBuildMessage(User* source, const char* name, ClientProtocol::TagMap& tags) { }
105
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.
110          */
111         virtual void OnBuildMessage(Server* source, const char* name, ClientProtocol::TagMap& tags) { }
112 };
113
114 class ServerProtocol::SyncEventListener
115         : public Events::ModuleEventListener
116 {
117  public:
118         SyncEventListener(Module* mod)
119                 : ModuleEventListener(mod, "event/server-sync")
120         {
121         }
122
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.
127          */
128         virtual void OnSyncUser(User* user, ProtocolServer& server) { }
129
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.
134          */
135         virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
136
137         /** Allows modules to synchronize network metadata during a netburst.
138          * @param server The target of the burst.
139          */
140         virtual void OnSyncNetwork(ProtocolServer& server) { }
141 };
142
143 /** Compatibility struct for <3.3.0 modules. */
144 class ServerEventListener
145         : public ServerProtocol::BroadcastEventListener
146         , public ServerProtocol::LinkEventListener
147         , public ServerProtocol::SyncEventListener
148 {
149  public:
150         ServerEventListener(Module* mod)
151                 : ServerProtocol::BroadcastEventListener(mod)
152                 , ServerProtocol::LinkEventListener(mod)
153                 , ServerProtocol::SyncEventListener(mod)
154         {
155         }
156 };
157
158 #ifdef __GNUC__
159 # pragma GCC diagnostic pop
160 #endif
161