]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_user/core_user.h
7cc3d1e05dba0dccf4c7bd333b642c43b6870f1b
[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  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #pragma once
21
22 #include "inspircd.h"
23
24 class MessageWrapper
25 {
26         std::string prefix;
27         std::string suffix;
28         bool fixed;
29
30  public:
31         /**
32          * Wrap the given message according to the config rules
33          * @param message The message to wrap
34          * @param out String where the result is placed
35          */
36         void Wrap(const std::string& message, std::string& out);
37
38         /**
39          * Read the settings from the given config keys (options block)
40          * @param prefixname Name of the config key to read the prefix from
41          * @param suffixname Name of the config key to read the suffix from
42          * @param fixedname Name of the config key to read the fixed string string from.
43          * If this key has a non-empty value, all messages will be replaced with it.
44          */
45         void ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname);
46 };
47
48 /** Handle /AWAY.
49  */
50 class CommandAway : public Command
51 {
52  public:
53         /** Constructor for away.
54          */
55         CommandAway(Module* parent);
56         /** Handle command.
57          * @param parameters The parameters to the command
58          * @param user The user issuing the command
59          * @return A value from CmdResult to indicate command success or failure.
60          */
61         CmdResult Handle(const std::vector<std::string>& parameters, User *user);
62         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
63 };
64
65 class CommandMode : public Command
66 {
67  public:
68         /** Constructor for mode.
69          */
70         CommandMode(Module* parent);
71
72         /** Handle command.
73          * @param parameters The parameters to the command
74          * @param user The user issuing the command
75          * @return A value from CmdResult to indicate command success or failure.
76          */
77         CmdResult Handle(const std::vector<std::string>& parameters, User* user);
78
79         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
80 };
81
82 /** Handle /NICK.
83  */
84 class CommandNick : public SplitCommand
85 {
86  public:
87         /** Constructor for nick.
88          */
89         CommandNick(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(const std::vector<std::string>& parameters, LocalUser* user);
97 };
98
99 /** Handle /PART.
100  */
101 class CommandPart : public Command
102 {
103  public:
104         MessageWrapper msgwrap;
105
106         /** Constructor for part.
107          */
108         CommandPart(Module* parent);
109
110         /** Handle command.
111          * @param parameters The parameters to the command
112          * @param user The user issuing the command
113          * @return A value from CmdResult to indicate command success or failure.
114          */
115         CmdResult Handle(const std::vector<std::string>& parameters, User *user);
116         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
117 };
118
119 /** Handle /QUIT.
120  */
121 class CommandQuit : public Command
122 {
123  public:
124         MessageWrapper msgwrap;
125
126         /** Constructor for quit.
127          */
128         CommandQuit(Module* parent);
129
130         /** Handle command.
131          * @param parameters The parameters to the command
132          * @param user The user issuing the command
133          * @return A value from CmdResult to indicate command success or failure.
134          */
135         CmdResult Handle(const std::vector<std::string>& parameters, User*user);
136
137         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
138 };
139
140 /** Handle /USER.
141  */
142 class CommandUser : public SplitCommand
143 {
144  public:
145         /** Constructor for user.
146          */
147         CommandUser(Module* parent);
148
149         /** Handle command.
150          * @param parameters The parameters to the command
151          * @param user The user issuing the command
152          * @return A value from CmdResult to indicate command success or failure.
153          */
154         CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser *user);
155
156         /** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
157          * successfully executes the USER or the NICK command.
158          * @param user User to inspect and possibly pass to the OnUserRegister hook
159          * @return CMD_FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CMD_SUCCESS in every other case
160          * (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
161          * a non-MOD_RES_DENY result).
162          */
163         static CmdResult CheckRegister(LocalUser* user);
164 };