]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_channel/core_channel.h
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / coremods / core_channel / core_channel.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2017-2020 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         ERR_KEYSET = 467
59 };
60
61 /** Handle /INVITE.
62  */
63 class CommandInvite : public Command
64 {
65         Invite::APIImpl& invapi;
66
67  public:
68         Invite::AnnounceState announceinvites;
69
70         /** Constructor for invite.
71          */
72         CommandInvite(Module* parent, Invite::APIImpl& invapiimpl);
73
74         /** Handle command.
75          * @param parameters The parameters to the command
76          * @param user The user issuing the command
77          * @return A value from CmdResult to indicate command success or failure.
78          */
79         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
80         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
81 };
82
83 /** Handle /JOIN.
84  */
85 class CommandJoin : public SplitCommand
86 {
87  public:
88         /** Constructor for join.
89          */
90         CommandJoin(Module* parent);
91
92         /** Handle command.
93          * @param parameters The parameters to the command
94          * @param user The user issuing the command
95          * @return A value from CmdResult to indicate command success or failure.
96          */
97         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
98 };
99
100 /** Handle /TOPIC.
101  */
102 class CommandTopic : public SplitCommand
103 {
104         CheckExemption::EventProvider exemptionprov;
105         ChanModeReference secretmode;
106         ChanModeReference topiclockmode;
107
108  public:
109         /** Constructor for topic.
110          */
111         CommandTopic(Module* parent);
112
113         /** Handle command.
114          * @param parameters The parameters to the command
115          * @param user The user issuing the command
116          * @return A value from CmdResult to indicate command success or failure.
117          */
118         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
119 };
120
121 /** Handle /NAMES.
122  */
123 class CommandNames : public SplitCommand
124 {
125  private:
126         ChanModeReference secretmode;
127         ChanModeReference privatemode;
128         UserModeReference invisiblemode;
129         Events::ModuleEventProvider namesevprov;
130
131  public:
132         /** Constructor for names.
133          */
134         CommandNames(Module* parent);
135
136         /** Handle command.
137          * @param parameters The parameters to the command
138          * @param user The user issuing the command
139          * @return A value from CmdResult to indicate command success or failure.
140          */
141         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
142
143         /** Spool the NAMES list for a given channel to the given user
144          * @param user User to spool the NAMES list to
145          * @param chan Channel whose nicklist to send
146          * @param show_invisible True to show invisible (+i) members to the user, false to omit them from the list
147          */
148         void SendNames(LocalUser* user, Channel* chan, bool show_invisible);
149 };
150
151 /** Handle /KICK.
152  */
153 class CommandKick : public Command
154 {
155  public:
156         /** Constructor for kick.
157          */
158         CommandKick(Module* parent);
159
160         /** Handle command.
161          * @param parameters The parameters to the command
162          * @param user The user issuing the command
163          * @return A value from CmdResult to indicate command success or failure.
164          */
165         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
166         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
167 };
168
169 /** Channel mode +b
170  */
171 class ModeChannelBan : public ListModeBase
172 {
173  public:
174         ModeChannelBan(Module* Creator)
175                 : ListModeBase(Creator, "ban", 'b', "End of channel ban list", RPL_BANLIST, RPL_ENDOFBANLIST, true)
176         {
177                 syntax = "<mask>";
178         }
179 };
180
181 /** Channel mode +k
182  */
183 class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
184 {
185  public:
186         static const std::string::size_type maxkeylen;
187         ModeChannelKey(Module* Creator);
188         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE;
189         void SerializeParam(Channel* chan, const std::string* key, std::string& out)    ;
190         ModeAction OnSet(User* source, Channel* chan, std::string& param) CXX11_OVERRIDE;
191         bool IsParameterSecret() CXX11_OVERRIDE;
192 };
193
194 /** Channel mode +l
195  */
196 class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
197 {
198  public:
199         size_t minlimit;
200         ModeChannelLimit(Module* Creator);
201         bool ResolveModeConflict(std::string& their_param, const std::string& our_param, Channel* channel) CXX11_OVERRIDE;
202         void SerializeParam(Channel* chan, intptr_t n, std::string& out);
203         ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE;
204 };
205
206 /** Channel mode +o
207  */
208 class ModeChannelOp : public PrefixMode
209 {
210  public:
211         ModeChannelOp(Module* Creator)
212                 : PrefixMode(Creator, "op", 'o', OP_VALUE, '@')
213         {
214                 ranktoset = ranktounset = OP_VALUE;
215         }
216 };
217
218 /** Channel mode +v
219  */
220 class ModeChannelVoice : public PrefixMode
221 {
222  public:
223         ModeChannelVoice(Module* Creator)
224                 : PrefixMode(Creator, "voice", 'v', VOICE_VALUE, '+')
225         {
226                 selfremove = false;
227                 ranktoset = ranktounset = HALFOP_VALUE;
228         }
229 };