]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_user/core_user.h
Merge insp20
[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 /** Handle /NICK.
66  */
67 class CommandNick : public SplitCommand
68 {
69  public:
70         /** Constructor for nick.
71          */
72         CommandNick(Module* parent);
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 HandleLocal(const std::vector<std::string>& parameters, LocalUser* user);
80 };
81
82 /** Handle /PART.
83  */
84 class CommandPart : public Command
85 {
86  public:
87         MessageWrapper msgwrap;
88
89         /** Constructor for part.
90          */
91         CommandPart(Module* parent);
92
93         /** Handle command.
94          * @param parameters The parameters to the command
95          * @param user The user issuing the command
96          * @return A value from CmdResult to indicate command success or failure.
97          */
98         CmdResult Handle(const std::vector<std::string>& parameters, User *user);
99         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
100 };
101
102 /** Handle /QUIT.
103  */
104 class CommandQuit : public Command
105 {
106  public:
107         MessageWrapper msgwrap;
108
109         /** Constructor for quit.
110          */
111         CommandQuit(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 Handle(const std::vector<std::string>& parameters, User*user);
119
120         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
121 };
122
123 /** Handle /USER.
124  */
125 class CommandUser : public SplitCommand
126 {
127  public:
128         /** Constructor for user.
129          */
130         CommandUser(Module* parent);
131
132         /** Handle command.
133          * @param parameters The parameters to the command
134          * @param user The user issuing the command
135          * @return A value from CmdResult to indicate command success or failure.
136          */
137         CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser *user);
138
139         /** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
140          * successfully executes the USER or the NICK command.
141          * @param user User to inspect and possibly pass to the OnUserRegister hook
142          * @return CMD_FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CMD_SUCCESS in every other case
143          * (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
144          * a non-MOD_RES_DENY result).
145          */
146         static CmdResult CheckRegister(LocalUser* user);
147 };