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/>.
36 * Wrap the given message according to the config rules
37 * @param message The message to wrap
38 * @param out String where the result is placed
40 void Wrap(const std::string& message, std::string& out);
43 * Read the settings from the given config keys (options block)
44 * @param prefixname Name of the config key to read the prefix from
45 * @param suffixname Name of the config key to read the suffix from
46 * @param fixedname Name of the config key to read the fixed string string from.
47 * If this key has a non-empty value, all messages will be replaced with it.
49 void ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname);
54 class CommandAway : public Command
57 /** Constructor for away.
59 CommandAway(Module* parent);
61 * @param parameters The parameters to the command
62 * @param user The user issuing the command
63 * @return A value from CmdResult to indicate command success or failure.
65 CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
66 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
69 class CommandMode : public Command
71 unsigned int sent[256];
74 /** Show the list of one or more list modes to a user.
75 * @param user User to send to.
76 * @param chan Channel whose lists to show.
77 * @param mode_sequence Mode letters to show the lists of.
79 void DisplayListModes(User* user, Channel* chan, const std::string& mode_sequence);
81 /** Show the current modes of a channel or a user to a user.
82 * @param user User to show the modes to.
83 * @param targetuser User whose modes to show. NULL if showing the modes of a channel.
84 * @param targetchannel Channel whose modes to show. NULL if showing the modes of a user.
86 void DisplayCurrentModes(User* user, User* targetuser, Channel* targetchannel);
89 /** Constructor for mode.
91 CommandMode(Module* parent);
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.
98 CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
100 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
105 class CommandNick : public SplitCommand
108 /** Constructor for nick.
110 CommandNick(Module* parent);
113 * @param parameters The parameters to the command
114 * @param user The user issuing the command
115 * @return A value from CmdResult to indicate command success or failure.
117 CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
122 class CommandPart : public Command
125 MessageWrapper msgwrap;
127 /** Constructor for part.
129 CommandPart(Module* parent);
132 * @param parameters The parameters to the command
133 * @param user The user issuing the command
134 * @return A value from CmdResult to indicate command success or failure.
136 CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
137 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
142 class CommandQuit : public Command
145 StringExtItem operquit;
148 MessageWrapper msgwrap;
150 /** Constructor for quit.
152 CommandQuit(Module* parent);
155 * @param parameters The parameters to the command
156 * @param user The user issuing the command
157 * @return A value from CmdResult to indicate command success or failure.
159 CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
161 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
166 class CommandUser : public SplitCommand
169 /** Constructor for user.
171 CommandUser(Module* parent);
174 * @param parameters The parameters to the command
175 * @param user The user issuing the command
176 * @return A value from CmdResult to indicate command success or failure.
178 CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
180 /** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
181 * successfully executes the USER or the NICK command.
182 * @param user User to inspect and possibly pass to the OnUserRegister hook
183 * @return CMD_FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CMD_SUCCESS in every other case
184 * (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
185 * a non-MOD_RES_DENY result).
187 static CmdResult CheckRegister(LocalUser* user);
192 class ModeUserServerNoticeMask : public ModeHandler
194 /** Process a snomask modifier string, e.g. +abc-de
195 * @param user The target user
196 * @param input A sequence of notice mask characters
197 * @return The cleaned mode sequence which can be output,
198 * e.g. in the above example if masks c and e are not
199 * valid, this function will return +ab-d
201 std::string ProcessNoticeMasks(User* user, const std::string& input);
204 ModeUserServerNoticeMask(Module* Creator);
205 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;
206 void OnParameterMissing(User* user, User* dest, Channel* channel) CXX11_OVERRIDE;
208 /** Create a displayable mode string of the snomasks set on a given user
209 * @param user The user whose notice masks to format
210 * @return The notice mask character sequence
212 std::string GetUserParameter(const User* user) const CXX11_OVERRIDE;
217 class ModeUserOperator : public ModeHandler
220 ModeUserOperator(Module* Creator);
221 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;