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