2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2020 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"
41 * Wrap the given message according to the config rules
42 * @param message The message to wrap
43 * @param out String where the result is placed
45 void Wrap(const std::string& message, std::string& out);
48 * Read the settings from the given config keys (options block)
49 * @param prefixname Name of the config key to read the prefix from
50 * @param suffixname Name of the config key to read the suffix from
51 * @param fixedname Name of the config key to read the fixed string string from.
52 * If this key has a non-empty value, all messages will be replaced with it.
54 void ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname);
59 class CommandAway : public Command
62 Away::EventProvider awayevprov;
65 /** Constructor for away.
67 CommandAway(Module* parent);
69 * @param parameters The parameters to the command
70 * @param user The user issuing the command
71 * @return A value from CmdResult to indicate command success or failure.
73 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
74 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
79 class CommandIson : public SplitCommand
82 /** Constructor for ison.
84 CommandIson(Module* parent)
85 : SplitCommand(parent, "ISON", 1)
87 allow_empty_last_param = false;
88 syntax = "<nick> [<nick>]+";
91 * @param parameters The parameters to the command
92 * @param user The user issuing the command
93 * @return A value from CmdResult to indicate command success or failure.
95 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
101 class CommandNick : public SplitCommand
104 /** Constructor for nick.
106 CommandNick(Module* parent);
109 * @param parameters The parameters to the command
110 * @param user The user issuing the command
111 * @return A value from CmdResult to indicate command success or failure.
113 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
118 class CommandPart : public Command
121 MessageWrapper msgwrap;
123 /** Constructor for part.
125 CommandPart(Module* parent);
128 * @param parameters The parameters to the command
129 * @param user The user issuing the command
130 * @return A value from CmdResult to indicate command success or failure.
132 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
133 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
138 class CommandQuit : public Command
141 StringExtItem operquit;
144 MessageWrapper msgwrap;
146 /** Constructor for quit.
148 CommandQuit(Module* parent);
151 * @param parameters The parameters to the command
152 * @param user The user issuing the command
153 * @return A value from CmdResult to indicate command success or failure.
155 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
157 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
162 class CommandUser : public SplitCommand
165 /** Constructor for user.
167 CommandUser(Module* parent);
170 * @param parameters The parameters to the command
171 * @param user The user issuing the command
172 * @return A value from CmdResult to indicate command success or failure.
174 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
176 /** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
177 * successfully executes the USER or the NICK command.
178 * @param user User to inspect and possibly pass to the OnUserRegister hook
179 * @return CMD_FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CMD_SUCCESS in every other case
180 * (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
181 * a non-MOD_RES_DENY result).
183 static CmdResult CheckRegister(LocalUser* user);
186 /** Handle /USERHOST.
188 class CommandUserhost : public Command
190 UserModeReference hideopermode;
193 /** Constructor for userhost.
195 CommandUserhost(Module* parent)
196 : Command(parent,"USERHOST", 1)
197 , hideopermode(parent, "hideoper")
199 allow_empty_last_param = false;
200 syntax = "<nick> [<nick>]+";
203 * @param parameters The parameters to the command
204 * @param user The user issuing the command
205 * @return A value from CmdResult to indicate command success or failure.
207 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
212 class ModeUserServerNoticeMask : public ModeHandler
214 /** Process a snomask modifier string, e.g. +abc-de
215 * @param user The target user
216 * @param input A sequence of notice mask characters
217 * @return The cleaned mode sequence which can be output,
218 * e.g. in the above example if masks c and e are not
219 * valid, this function will return +ab-d
221 std::string ProcessNoticeMasks(User* user, const std::string& input);
224 ModeUserServerNoticeMask(Module* Creator);
225 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;
227 /** Create a displayable mode string of the snomasks set on a given user
228 * @param user The user whose notice masks to format
229 * @return The notice mask character sequence
231 std::string GetUserParameter(const User* user) const CXX11_OVERRIDE;
236 class ModeUserOperator : public ModeHandler
239 ModeUserOperator(Module* Creator);
240 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;