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;
73 class CommandMode : public Command
75 unsigned int sent[256];
78 /** Show the list of one or more list modes to a user.
79 * @param user User to send to.
80 * @param chan Channel whose lists to show.
81 * @param mode_sequence Mode letters to show the lists of.
83 void DisplayListModes(User* user, Channel* chan, const std::string& mode_sequence);
85 /** Show the current modes of a channel or a user to a user.
86 * @param user User to show the modes to.
87 * @param targetuser User whose modes to show. NULL if showing the modes of a channel.
88 * @param targetchannel Channel whose modes to show. NULL if showing the modes of a user.
90 void DisplayCurrentModes(User* user, User* targetuser, Channel* targetchannel);
93 /** Constructor for mode.
95 CommandMode(Module* parent);
98 * @param parameters The parameters to the command
99 * @param user The user issuing the command
100 * @return A value from CmdResult to indicate command success or failure.
102 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
104 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
109 class CommandNick : public SplitCommand
112 /** Constructor for nick.
114 CommandNick(Module* parent);
117 * @param parameters The parameters to the command
118 * @param user The user issuing the command
119 * @return A value from CmdResult to indicate command success or failure.
121 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
126 class CommandPart : public Command
129 MessageWrapper msgwrap;
131 /** Constructor for part.
133 CommandPart(Module* parent);
136 * @param parameters The parameters to the command
137 * @param user The user issuing the command
138 * @return A value from CmdResult to indicate command success or failure.
140 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
141 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
146 class CommandQuit : public Command
149 StringExtItem operquit;
152 MessageWrapper msgwrap;
154 /** Constructor for quit.
156 CommandQuit(Module* parent);
159 * @param parameters The parameters to the command
160 * @param user The user issuing the command
161 * @return A value from CmdResult to indicate command success or failure.
163 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
165 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
170 class CommandUser : public SplitCommand
173 /** Constructor for user.
175 CommandUser(Module* parent);
178 * @param parameters The parameters to the command
179 * @param user The user issuing the command
180 * @return A value from CmdResult to indicate command success or failure.
182 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
184 /** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
185 * successfully executes the USER or the NICK command.
186 * @param user User to inspect and possibly pass to the OnUserRegister hook
187 * @return CMD_FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CMD_SUCCESS in every other case
188 * (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
189 * a non-MOD_RES_DENY result).
191 static CmdResult CheckRegister(LocalUser* user);
196 class ModeUserServerNoticeMask : public ModeHandler
198 /** Process a snomask modifier string, e.g. +abc-de
199 * @param user The target user
200 * @param input A sequence of notice mask characters
201 * @return The cleaned mode sequence which can be output,
202 * e.g. in the above example if masks c and e are not
203 * valid, this function will return +ab-d
205 std::string ProcessNoticeMasks(User* user, const std::string& input);
208 ModeUserServerNoticeMask(Module* Creator);
209 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;
210 void OnParameterMissing(User* user, User* dest, Channel* channel) CXX11_OVERRIDE;
212 /** Create a displayable mode string of the snomasks set on a given user
213 * @param user The user whose notice masks to format
214 * @return The notice mask character sequence
216 std::string GetUserParameter(const User* user) const CXX11_OVERRIDE;
221 class ModeUserOperator : public ModeHandler
224 ModeUserOperator(Module* Creator);
225 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) CXX11_OVERRIDE;