2 * InspIRCd -- Internet Relay Chat Daemon
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>
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.
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
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/>.
27 #include "modules/away.h"
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
41 void Wrap(const std::string& message, std::string& out);
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.
50 void ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname);
55 class CommandAway : public Command
58 Away::EventProvider awayevprov;
61 /** Constructor for away.
63 CommandAway(Module* parent);
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.
69 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
70 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
75 class CommandIson : public SplitCommand
78 /** Constructor for ison.
80 CommandIson(Module* parent)
81 : SplitCommand(parent, "ISON", 1)
83 allow_empty_last_param = false;
84 syntax = "<nick> [<nick>]+";
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.
91 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
97 class CommandNick : public SplitCommand
100 /** Constructor for nick.
102 CommandNick(Module* parent);
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.
109 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
114 class CommandPart : public Command
117 MessageWrapper msgwrap;
119 /** Constructor for part.
121 CommandPart(Module* parent);
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.
128 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
129 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
134 class CommandQuit : public Command
137 StringExtItem operquit;
140 MessageWrapper msgwrap;
142 /** Constructor for quit.
144 CommandQuit(Module* parent);
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.
151 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
153 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
158 class CommandUser : public SplitCommand
161 /** Constructor for user.
163 CommandUser(Module* parent);
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.
170 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
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).
179 static CmdResult CheckRegister(LocalUser* user);
182 /** Handle /USERHOST.
184 class CommandUserhost : public Command
186 UserModeReference hideopermode;
189 /** Constructor for userhost.
191 CommandUserhost(Module* parent)
192 : Command(parent,"USERHOST", 1)
193 , hideopermode(parent, "hideoper")
195 allow_empty_last_param = false;
196 syntax = "<nick> [<nick>]+";
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.
203 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
208 class ModeUserServerNoticeMask : public ModeHandler
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
217 std::string ProcessNoticeMasks(User* user, const std::string& input);
220 ModeUserServerNoticeMask(Module* Creator);
221 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;
222 void OnParameterMissing(User* user, User* dest, Channel* channel) CXX11_OVERRIDE;
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
228 std::string GetUserParameter(const User* user) const CXX11_OVERRIDE;
233 class ModeUserOperator : public ModeHandler
236 ModeUserOperator(Module* Creator);
237 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;