]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_channel/core_channel.h
Improve the logging of the httpd module.
[user/henk/code/inspircd.git] / src / coremods / core_channel / core_channel.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2014-2015 Attila Molnar <attilamolnar@hush.com>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #pragma once
22
23 #include "inspircd.h"
24 #include "listmode.h"
25 #include "modules/exemption.h"
26
27 namespace Topic
28 {
29         void ShowTopic(LocalUser* user, Channel* chan);
30 }
31
32 namespace Invite
33 {
34         class APIImpl;
35
36         /** Used to indicate who we announce invites to on a channel. */
37         enum AnnounceState
38         {
39                 /** Don't send invite announcements. */
40                 ANNOUNCE_NONE,
41
42                 /** Send invite announcements to all users. */
43                 ANNOUNCE_ALL,
44
45                 /** Send invite announcements to channel operators and higher. */
46                 ANNOUNCE_OPS,
47
48                 /** Send invite announcements to channel half-operators (if available) and higher. */
49                 ANNOUNCE_DYNAMIC
50         };
51 }
52
53 enum
54 {
55         // From RFC 1459.
56         RPL_BANLIST = 367,
57         RPL_ENDOFBANLIST = 368
58 };
59
60 /** Handle /INVITE.
61  */
62 class CommandInvite : public Command
63 {
64         Invite::APIImpl& invapi;
65
66  public:
67         Invite::AnnounceState announceinvites;
68
69         /** Constructor for invite.
70          */
71         CommandInvite(Module* parent, Invite::APIImpl& invapiimpl);
72
73         /** Handle command.
74          * @param parameters The parameters to the command
75          * @param user The user issuing the command
76          * @return A value from CmdResult to indicate command success or failure.
77          */
78         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
79         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
80 };
81
82 /** Handle /JOIN.
83  */
84 class CommandJoin : public SplitCommand
85 {
86  public:
87         /** Constructor for join.
88          */
89         CommandJoin(Module* parent);
90
91         /** Handle command.
92          * @param parameters The parameters to the command
93          * @param user The user issuing the command
94          * @return A value from CmdResult to indicate command success or failure.
95          */
96         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
97 };
98
99 /** Handle /TOPIC.
100  */
101 class CommandTopic : public SplitCommand
102 {
103         CheckExemption::EventProvider exemptionprov;
104         ChanModeReference secretmode;
105         ChanModeReference topiclockmode;
106
107  public:
108         /** Constructor for topic.
109          */
110         CommandTopic(Module* parent);
111
112         /** Handle command.
113          * @param parameters The parameters to the command
114          * @param user The user issuing the command
115          * @return A value from CmdResult to indicate command success or failure.
116          */
117         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
118 };
119
120 /** Handle /NAMES.
121  */
122 class CommandNames : public SplitCommand
123 {
124  private:
125         ChanModeReference secretmode;
126         ChanModeReference privatemode;
127         UserModeReference invisiblemode;
128         Events::ModuleEventProvider namesevprov;
129
130  public:
131         /** Constructor for names.
132          */
133         CommandNames(Module* parent);
134
135         /** Handle command.
136          * @param parameters The parameters to the command
137          * @param user The user issuing the command
138          * @return A value from CmdResult to indicate command success or failure.
139          */
140         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
141
142         /** Spool the NAMES list for a given channel to the given user
143          * @param user User to spool the NAMES list to
144          * @param chan Channel whose nicklist to send
145          * @param show_invisible True to show invisible (+i) members to the user, false to omit them from the list
146          */
147         void SendNames(LocalUser* user, Channel* chan, bool show_invisible);
148 };
149
150 /** Handle /KICK.
151  */
152 class CommandKick : public Command
153 {
154  public:
155         /** Constructor for kick.
156          */
157         CommandKick(Module* parent);
158
159         /** Handle command.
160          * @param parameters The parameters to the command
161          * @param user The user issuing the command
162          * @return A value from CmdResult to indicate command success or failure.
163          */
164         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
165         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
166 };
167
168 /** Channel mode +b
169  */
170 class ModeChannelBan : public ListModeBase
171 {
172  public:
173         ModeChannelBan(Module* Creator)
174                 : ListModeBase(Creator, "ban", 'b', "End of channel ban list", RPL_BANLIST, RPL_ENDOFBANLIST, true)
175         {
176                 syntax = "<mask>";
177         }
178 };
179
180 /** Channel mode +k
181  */
182 class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
183 {
184  public:
185         static const std::string::size_type maxkeylen;
186         ModeChannelKey(Module* Creator);
187         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE;
188         void SerializeParam(Channel* chan, const std::string* key, std::string& out)    ;
189         ModeAction OnSet(User* source, Channel* chan, std::string& param) CXX11_OVERRIDE;
190         bool IsParameterSecret() CXX11_OVERRIDE;
191 };
192
193 /** Channel mode +l
194  */
195 class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
196 {
197  public:
198         size_t minlimit;
199         ModeChannelLimit(Module* Creator);
200         bool ResolveModeConflict(std::string& their_param, const std::string& our_param, Channel* channel) CXX11_OVERRIDE;
201         void SerializeParam(Channel* chan, intptr_t n, std::string& out);
202         ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE;
203 };
204
205 /** Channel mode +o
206  */
207 class ModeChannelOp : public PrefixMode
208 {
209  public:
210         ModeChannelOp(Module* Creator)
211                 : PrefixMode(Creator, "op", 'o', OP_VALUE, '@')
212         {
213                 ranktoset = ranktounset = OP_VALUE;
214         }
215 };
216
217 /** Channel mode +v
218  */
219 class ModeChannelVoice : public PrefixMode
220 {
221  public:
222         ModeChannelVoice(Module* Creator)
223                 : PrefixMode(Creator, "voice", 'v', VOICE_VALUE, '+')
224         {
225                 selfremove = false;
226                 ranktoset = ranktounset = HALFOP_VALUE;
227         }
228 };