2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2014-2016, 2018 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/>.
22 #include "core_user.h"
26 class CommandPass : public SplitCommand
29 /** Constructor for pass.
31 CommandPass(Module* parent)
32 : SplitCommand(parent, "PASS", 1, 1)
34 works_before_reg = true;
36 syntax = "<password>";
40 * @param parameters The parameters to the command
41 * @param user The user issuing the command
42 * @return A value from CmdResult to indicate command success or failure.
44 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
46 // Check to make sure they haven't registered -- Fix by FCS
47 if (user->registered == REG_ALL)
49 user->CommandFloodPenalty += 1000;
50 user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister");
53 user->password = parameters[0];
61 class CommandPing : public SplitCommand
64 /** Constructor for ping.
66 CommandPing(Module* parent)
67 : SplitCommand(parent, "PING", 1)
69 syntax = "<cookie> [<servername>]";
73 * @param parameters The parameters to the command
74 * @param user The user issuing the command
75 * @return A value from CmdResult to indicate command success or failure.
77 CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
79 size_t origin = parameters.size() > 1 ? 1 : 0;
80 if (parameters[origin].empty())
82 user->WriteNumeric(ERR_NOORIGIN, "No origin specified");
86 ClientProtocol::Messages::Pong pong(parameters[0], origin ? parameters[1] : "");
87 user->Send(ServerInstance->GetRFCEvents().pong, pong);
94 class CommandPong : public Command
97 /** Constructor for pong.
99 CommandPong(Module* parent)
100 : Command(parent, "PONG", 1)
103 syntax = "<cookie> [<servername>]";
107 * @param parameters The parameters to the command
108 * @param user The user issuing the command
109 * @return A value from CmdResult to indicate command success or failure.
111 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
113 size_t origin = parameters.size() > 1 ? 1 : 0;
114 if (parameters[origin].empty())
116 user->WriteNumeric(ERR_NOORIGIN, "No origin specified");
120 // set the user as alive so they survive to next ping
121 LocalUser* localuser = IS_LOCAL(user);
124 // Increase penalty unless we've sent a PING and this is the reply
125 if (localuser->lastping)
126 localuser->CommandFloodPenalty += 1000;
128 localuser->lastping = 1;
134 void MessageWrapper::Wrap(const std::string& message, std::string& out)
136 // If there is a fixed message, it is stored in prefix. Otherwise prefix contains
137 // only the prefix, so append the message and the suffix
140 out.append(message).append(suffix);
143 void MessageWrapper::ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname)
145 ConfigTag* tag = ServerInstance->Config->ConfValue("options");
146 prefix = tag->getString(fixedname);
147 fixed = (!prefix.empty());
150 prefix = tag->getString(prefixname);
151 suffix = tag->getString(suffixname);
155 class CoreModUser : public Module
166 CommandUserhost cmduserhost;
167 SimpleUserModeHandler invisiblemode;
168 ModeUserOperator operatormode;
169 ModeUserServerNoticeMask snomaskmode;
183 , invisiblemode(this, "invisible", 'i')
189 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
191 cmdpart.msgwrap.ReadConfig("prefixpart", "suffixpart", "fixedpart");
192 cmdquit.msgwrap.ReadConfig("prefixquit", "suffixquit", "fixedquit");
195 Version GetVersion() CXX11_OVERRIDE
197 return Version("Provides the AWAY, ISON, NICK, PART, PASS, PING, PONG, QUIT, USERHOST, and USER commands", VF_VENDOR|VF_CORE);
201 MODULE_INIT(CoreModUser)