2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "core_user.h"
23 class CommandMode : public Command
26 /** Constructor for mode.
28 CommandMode(Module* parent)
29 : Command(parent, "MODE", 1)
31 syntax = "<target> <modes> {<mode-parameters>}";
35 * @param parameters The parameters to the command
36 * @param user The user issuing the command
37 * @return A value from CmdResult to indicate command success or failure.
39 CmdResult Handle(const std::vector<std::string>& parameters, User* user)
41 ServerInstance->Modes->Process(parameters, user, (IS_LOCAL(user) ? ModeParser::MODE_NONE : ModeParser::MODE_LOCALONLY));
45 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
47 return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST);
53 class CommandPass : public SplitCommand
56 /** Constructor for pass.
58 CommandPass(Module* parent)
59 : SplitCommand(parent, "PASS", 1, 1)
61 works_before_reg = true;
63 syntax = "<password>";
67 * @param parameters The parameters to the command
68 * @param user The user issuing the command
69 * @return A value from CmdResult to indicate command success or failure.
71 CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser *user)
73 // Check to make sure they haven't registered -- Fix by FCS
74 if (user->registered == REG_ALL)
76 user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister");
79 user->password = parameters[0];
87 class CommandPing : public Command
90 /** Constructor for ping.
92 CommandPing(Module* parent)
93 : Command(parent, "PING", 1, 2)
96 syntax = "<servername> [:<servername>]";
100 * @param parameters The parameters to the command
101 * @param user The user issuing the command
102 * @return A value from CmdResult to indicate command success or failure.
104 CmdResult Handle(const std::vector<std::string>& parameters, User* user)
106 user->WriteServ("PONG %s :%s", ServerInstance->Config->ServerName.c_str(), parameters[0].c_str());
113 class CommandPong : public Command
116 /** Constructor for pong.
118 CommandPong(Module* parent)
119 : Command(parent, "PONG", 0, 1)
122 syntax = "<ping-text>";
126 * @param parameters The parameters to the command
127 * @param user The user issuing the command
128 * @return A value from CmdResult to indicate command success or failure.
130 CmdResult Handle(const std::vector<std::string>& parameters, User* user)
132 // set the user as alive so they survive to next ping
134 IS_LOCAL(user)->lastping = 1;
139 class CoreModUser : public Module
153 : cmdaway(this), cmdmode(this), cmdnick(this), cmdpart(this), cmdpass(this), cmdping(this)
154 , cmdpong(this), cmdquit(this), cmduser(this)
158 Version GetVersion() CXX11_OVERRIDE
160 return Version("Provides the AWAY, MODE, NICK, PART, PASS, PING, PONG, QUIT and USER commands", VF_VENDOR|VF_CORE);
164 MODULE_INIT(CoreModUser)