2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
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.
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
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/>.
25 #include "modules/away.h"
35 * Wrap the given message according to the config rules
36 * @param message The message to wrap
37 * @param out String where the result is placed
39 void Wrap(const std::string& message, std::string& out);
42 * Read the settings from the given config keys (options block)
43 * @param prefixname Name of the config key to read the prefix from
44 * @param suffixname Name of the config key to read the suffix from
45 * @param fixedname Name of the config key to read the fixed string string from.
46 * If this key has a non-empty value, all messages will be replaced with it.
48 void ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname);
53 class CommandAway : public Command
56 Away::EventProvider awayevprov;
59 /** Constructor for away.
61 CommandAway(Module* parent);
63 * @param parameters The parameters to the command
64 * @param user The user issuing the command
65 * @return A value from CmdResult to indicate command success or failure.
67 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
68 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
73 class CommandIson : public SplitCommand
76 /** Constructor for ison.
78 CommandIson(Module* parent)
79 : SplitCommand(parent, "ISON", 1)
81 allow_empty_last_param = false;
82 syntax = "<nick> [<nick>]+";
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.
89 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
95 class CommandNick : public SplitCommand
98 /** Constructor for nick.
100 CommandNick(Module* parent);
103 * @param parameters The parameters to the command
104 * @param user The user issuing the command
105 * @return A value from CmdResult to indicate command success or failure.
107 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
112 class CommandPart : public Command
115 MessageWrapper msgwrap;
117 /** Constructor for part.
119 CommandPart(Module* parent);
122 * @param parameters The parameters to the command
123 * @param user The user issuing the command
124 * @return A value from CmdResult to indicate command success or failure.
126 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
127 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
132 class CommandQuit : public Command
135 StringExtItem operquit;
138 MessageWrapper msgwrap;
140 /** Constructor for quit.
142 CommandQuit(Module* parent);
145 * @param parameters The parameters to the command
146 * @param user The user issuing the command
147 * @return A value from CmdResult to indicate command success or failure.
149 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
151 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
156 class CommandUser : public SplitCommand
159 /** Constructor for user.
161 CommandUser(Module* parent);
164 * @param parameters The parameters to the command
165 * @param user The user issuing the command
166 * @return A value from CmdResult to indicate command success or failure.
168 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
170 /** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
171 * successfully executes the USER or the NICK command.
172 * @param user User to inspect and possibly pass to the OnUserRegister hook
173 * @return CMD_FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CMD_SUCCESS in every other case
174 * (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
175 * a non-MOD_RES_DENY result).
177 static CmdResult CheckRegister(LocalUser* user);
180 /** Handle /USERHOST.
182 class CommandUserhost : public Command
184 UserModeReference hideopermode;
187 /** Constructor for userhost.
189 CommandUserhost(Module* parent)
190 : Command(parent,"USERHOST", 1)
191 , hideopermode(parent, "hideoper")
193 allow_empty_last_param = false;
194 syntax = "<nick> [<nick>]+";
197 * @param parameters The parameters to the command
198 * @param user The user issuing the command
199 * @return A value from CmdResult to indicate command success or failure.
201 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
206 class ModeUserServerNoticeMask : public ModeHandler
208 /** Process a snomask modifier string, e.g. +abc-de
209 * @param user The target user
210 * @param input A sequence of notice mask characters
211 * @return The cleaned mode sequence which can be output,
212 * e.g. in the above example if masks c and e are not
213 * valid, this function will return +ab-d
215 std::string ProcessNoticeMasks(User* user, const std::string& input);
218 ModeUserServerNoticeMask(Module* Creator);
219 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;
221 /** Create a displayable mode string of the snomasks set on a given user
222 * @param user The user whose notice masks to format
223 * @return The notice mask character sequence
225 std::string GetUserParameter(const User* user) const CXX11_OVERRIDE;
230 class ModeUserOperator : public ModeHandler
233 ModeUserOperator(Module* Creator);
234 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;