]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_user/core_user.h
Add the msgid tag to all outgoing messages.
[user/henk/code/inspircd.git] / src / coremods / core_user / core_user.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
5  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7  *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
8  *
9  * This file is part of InspIRCd.  InspIRCd is free software: you can
10  * redistribute it and/or modify it under the terms of the GNU General Public
11  * License as published by the Free Software Foundation, version 2.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22
23 #pragma once
24
25 #include "inspircd.h"
26 #include "listmode.h"
27 #include "modules/away.h"
28
29 class MessageWrapper
30 {
31         std::string prefix;
32         std::string suffix;
33         bool fixed;
34
35  public:
36         /**
37          * Wrap the given message according to the config rules
38          * @param message The message to wrap
39          * @param out String where the result is placed
40          */
41         void Wrap(const std::string& message, std::string& out);
42
43         /**
44          * Read the settings from the given config keys (options block)
45          * @param prefixname Name of the config key to read the prefix from
46          * @param suffixname Name of the config key to read the suffix from
47          * @param fixedname Name of the config key to read the fixed string string from.
48          * If this key has a non-empty value, all messages will be replaced with it.
49          */
50         void ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname);
51 };
52
53 /** Handle /AWAY.
54  */
55 class CommandAway : public Command
56 {
57  private:
58         Away::EventProvider awayevprov;
59
60  public:
61         /** Constructor for away.
62          */
63         CommandAway(Module* parent);
64         /** Handle command.
65          * @param parameters The parameters to the command
66          * @param user The user issuing the command
67          * @return A value from CmdResult to indicate command success or failure.
68          */
69         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
70         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
71 };
72
73 /** Handle /ISON.
74  */
75 class CommandIson : public SplitCommand
76 {
77  public:
78         /** Constructor for ison.
79          */
80         CommandIson(Module* parent)
81                 : SplitCommand(parent, "ISON", 1)
82         {
83                 allow_empty_last_param = false;
84                 syntax = "<nick> [<nick>]+";
85         }
86         /** Handle command.
87          * @param parameters The parameters to the command
88          * @param user The user issuing the command
89          * @return A value from CmdResult to indicate command success or failure.
90          */
91         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
92 };
93
94
95 /** Handle /NICK.
96  */
97 class CommandNick : public SplitCommand
98 {
99  public:
100         /** Constructor for nick.
101          */
102         CommandNick(Module* parent);
103
104         /** Handle command.
105          * @param parameters The parameters to the command
106          * @param user The user issuing the command
107          * @return A value from CmdResult to indicate command success or failure.
108          */
109         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
110 };
111
112 /** Handle /PART.
113  */
114 class CommandPart : public Command
115 {
116  public:
117         MessageWrapper msgwrap;
118
119         /** Constructor for part.
120          */
121         CommandPart(Module* parent);
122
123         /** Handle command.
124          * @param parameters The parameters to the command
125          * @param user The user issuing the command
126          * @return A value from CmdResult to indicate command success or failure.
127          */
128         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
129         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
130 };
131
132 /** Handle /QUIT.
133  */
134 class CommandQuit : public Command
135 {
136  private:
137         StringExtItem operquit;
138
139  public:
140         MessageWrapper msgwrap;
141
142         /** Constructor for quit.
143          */
144         CommandQuit(Module* parent);
145
146         /** Handle command.
147          * @param parameters The parameters to the command
148          * @param user The user issuing the command
149          * @return A value from CmdResult to indicate command success or failure.
150          */
151         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
152
153         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
154 };
155
156 /** Handle /USER.
157  */
158 class CommandUser : public SplitCommand
159 {
160  public:
161         /** Constructor for user.
162          */
163         CommandUser(Module* parent);
164
165         /** Handle command.
166          * @param parameters The parameters to the command
167          * @param user The user issuing the command
168          * @return A value from CmdResult to indicate command success or failure.
169          */
170         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
171
172         /** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
173          * successfully executes the USER or the NICK command.
174          * @param user User to inspect and possibly pass to the OnUserRegister hook
175          * @return CMD_FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CMD_SUCCESS in every other case
176          * (i.e. if the hook wasn't fired because the user still needs to send NICK/USER or if it was fired and finished with
177          * a non-MOD_RES_DENY result).
178          */
179         static CmdResult CheckRegister(LocalUser* user);
180 };
181
182 /** Handle /USERHOST.
183  */
184 class CommandUserhost : public Command
185 {
186         UserModeReference hideopermode;
187
188  public:
189         /** Constructor for userhost.
190          */
191         CommandUserhost(Module* parent)
192                 : Command(parent,"USERHOST", 1)
193                 , hideopermode(parent, "hideoper")
194         {
195                 allow_empty_last_param = false;
196                 syntax = "<nick> [<nick>]+";
197         }
198         /** Handle command.
199          * @param parameters The parameters to the command
200          * @param user The user issuing the command
201          * @return A value from CmdResult to indicate command success or failure.
202          */
203         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
204 };
205
206 /** User mode +s
207  */
208 class ModeUserServerNoticeMask : public ModeHandler
209 {
210         /** Process a snomask modifier string, e.g. +abc-de
211          * @param user The target user
212          * @param input A sequence of notice mask characters
213          * @return The cleaned mode sequence which can be output,
214          * e.g. in the above example if masks c and e are not
215          * valid, this function will return +ab-d
216          */
217         std::string ProcessNoticeMasks(User* user, const std::string& input);
218
219  public:
220         ModeUserServerNoticeMask(Module* Creator);
221         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding) CXX11_OVERRIDE;
222         void OnParameterMissing(User* user, User* dest, Channel* channel) CXX11_OVERRIDE;
223
224         /** Create a displayable mode string of the snomasks set on a given user
225          * @param user The user whose notice masks to format
226          * @return The notice mask character sequence
227          */
228         std::string GetUserParameter(const User* user) const CXX11_OVERRIDE;
229 };
230
231 /** User mode +o
232  */
233 class ModeUserOperator : public ModeHandler
234 {
235  public:
236         ModeUserOperator(Module* Creator);
237         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding) CXX11_OVERRIDE;
238 };