diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-09-04 13:11:48 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-09-04 13:11:48 +0200 |
commit | a1b74f4dfb2393c0baff25101c6366588975fa27 (patch) | |
tree | cce684ef1a91f2ee19bb9a4fb9abf34c7289f586 | |
parent | e3fc46af3ea3999ea5eea7274f038f4f03357e0e (diff) |
core_user Expand the MODE handler into its own file
-rw-r--r-- | src/coremods/core_user/cmd_mode.cpp | 37 | ||||
-rw-r--r-- | src/coremods/core_user/core_user.cpp | 28 | ||||
-rw-r--r-- | src/coremods/core_user/core_user.h | 17 |
3 files changed, 54 insertions, 28 deletions
diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_user/cmd_mode.cpp new file mode 100644 index 000000000..b154f5e22 --- /dev/null +++ b/src/coremods/core_user/cmd_mode.cpp @@ -0,0 +1,37 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "inspircd.h" +#include "core_user.h" + +CommandMode::CommandMode(Module* parent) + : Command(parent, "MODE", 1) +{ + syntax = "<target> <modes> {<mode-parameters>}"; +} + +CmdResult CommandMode::Handle(const std::vector<std::string>& parameters, User* user) +{ + ServerInstance->Modes->Process(parameters, user, (IS_LOCAL(user) ? ModeParser::MODE_NONE : ModeParser::MODE_LOCALONLY)); + return CMD_SUCCESS; +} + +RouteDescriptor CommandMode::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); +} diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index 103880a6e..ffa6aa2ff 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -20,34 +20,6 @@ #include "inspircd.h" #include "core_user.h" -class CommandMode : public Command -{ - public: - /** Constructor for mode. - */ - CommandMode(Module* parent) - : Command(parent, "MODE", 1) - { - syntax = "<target> <modes> {<mode-parameters>}"; - } - - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector<std::string>& parameters, User* user) - { - ServerInstance->Modes->Process(parameters, user, (IS_LOCAL(user) ? ModeParser::MODE_NONE : ModeParser::MODE_LOCALONLY)); - return CMD_SUCCESS; - } - - RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) - { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); - } -}; - /** Handle /PASS. */ class CommandPass : public SplitCommand diff --git a/src/coremods/core_user/core_user.h b/src/coremods/core_user/core_user.h index a529e0ccf..7cc3d1e05 100644 --- a/src/coremods/core_user/core_user.h +++ b/src/coremods/core_user/core_user.h @@ -62,6 +62,23 @@ class CommandAway : public Command RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); }; +class CommandMode : public Command +{ + public: + /** Constructor for mode. + */ + CommandMode(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User* user); + + RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); +}; + /** Handle /NICK. */ class CommandNick : public SplitCommand |