diff options
-rw-r--r-- | src/coremods/core_channel/cmd_invite.cpp | 30 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_join.cpp | 28 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_kick.cpp | 28 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_names.cpp | 30 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_topic.cpp | 36 | ||||
-rw-r--r-- | src/coremods/core_channel/core_channel.cpp | 43 | ||||
-rw-r--r-- | src/coremods/core_channel/core_channel.h | 114 |
7 files changed, 196 insertions, 113 deletions
diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index 25afc0713..3260d7862 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -21,26 +21,14 @@ #include "inspircd.h" +#include "core_channel.h" -/** Handle /INVITE. - */ -class CommandInvite : public Command +CommandInvite::CommandInvite(Module* parent) + : Command(parent, "INVITE", 0, 0) { - public: - /** Constructor for invite. - */ - CommandInvite ( Module* parent) : Command(parent,"INVITE", 0, 0) { Penalty = 4; syntax = "[<nick> <channel>]"; } - /** 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) - { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); - } -}; + Penalty = 4; + syntax = "[<nick> <channel>]"; +} /** Handle /INVITE */ @@ -155,5 +143,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use return CMD_SUCCESS; } - -COMMAND_INIT(CommandInvite) +RouteDescriptor CommandInvite::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); +} diff --git a/src/coremods/core_channel/cmd_join.cpp b/src/coremods/core_channel/cmd_join.cpp index 1e6e515ba..1945bf52e 100644 --- a/src/coremods/core_channel/cmd_join.cpp +++ b/src/coremods/core_channel/cmd_join.cpp @@ -19,28 +19,14 @@ #include "inspircd.h" +#include "core_channel.h" -/** Handle /JOIN. - */ -class CommandJoin : public SplitCommand +CommandJoin::CommandJoin(Module* parent) + : SplitCommand(parent, "JOIN", 1, 2) { - public: - /** Constructor for join. - */ - CommandJoin(Module* parent) - : SplitCommand(parent, "JOIN", 1, 2) - { - syntax = "<channel>{,<channel>} {<key>{,<key>}}"; - Penalty = 2; - } - - /** 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 HandleLocal(const std::vector<std::string>& parameters, LocalUser* user); -}; + syntax = "<channel>{,<channel>} {<key>{,<key>}}"; + Penalty = 2; +} /** Handle /JOIN */ @@ -72,5 +58,3 @@ CmdResult CommandJoin::HandleLocal(const std::vector<std::string>& parameters, L user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name", parameters[0].c_str()); return CMD_FAILURE; } - -COMMAND_INIT(CommandJoin) diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp index 01f2039fa..260264faf 100644 --- a/src/coremods/core_channel/cmd_kick.cpp +++ b/src/coremods/core_channel/cmd_kick.cpp @@ -19,26 +19,13 @@ #include "inspircd.h" +#include "core_channel.h" -/** Handle /KICK. - */ -class CommandKick : public Command +CommandKick::CommandKick(Module* parent) + : Command(parent, "KICK", 2, 3) { - public: - /** Constructor for kick. - */ - CommandKick ( Module* parent) : Command(parent,"KICK",2,3) { syntax = "<channel> <nick>{,<nick>} [<reason>]"; } - /** 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) - { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); - } -}; + syntax = "<channel> <nick>{,<nick>} [<reason>]"; +} /** Handle /KICK */ @@ -93,4 +80,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } -COMMAND_INIT(CommandKick) +RouteDescriptor CommandKick::GetRouting(User* user, const std::vector<std::string>& parameters) +{ + return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); +} diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp index 8c8bc58dd..81ada28bc 100644 --- a/src/coremods/core_channel/cmd_names.cpp +++ b/src/coremods/core_channel/cmd_names.cpp @@ -19,30 +19,14 @@ #include "inspircd.h" +#include "core_channel.h" -/** Handle /NAMES. - */ -class CommandNames : public Command +CommandNames::CommandNames(Module* parent) + : Command(parent, "NAMES", 0, 0) + , secretmode(parent, "secret") { - ChanModeReference secretmode; - - public: - /** Constructor for names. - */ - CommandNames(Module* parent) - : Command(parent, "NAMES", 0, 0) - , secretmode(parent, "secret") - { - syntax = "{<channel>{,<channel>}}"; - } - - /** 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); -}; + syntax = "{<channel>{,<channel>}}"; +} /** Handle /NAMES */ @@ -76,5 +60,3 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } - -COMMAND_INIT(CommandNames) diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp index 2b0f81fb6..ea723c024 100644 --- a/src/coremods/core_channel/cmd_topic.cpp +++ b/src/coremods/core_channel/cmd_topic.cpp @@ -21,33 +21,16 @@ #include "inspircd.h" +#include "core_channel.h" -/** Handle /TOPIC. - */ -class CommandTopic : public SplitCommand +CommandTopic::CommandTopic(Module* parent) + : SplitCommand(parent, "TOPIC", 1, 2) + , secretmode(parent, "secret") + , topiclockmode(parent, "topiclock") { - ChanModeReference secretmode; - ChanModeReference topiclockmode; - - public: - /** Constructor for topic. - */ - CommandTopic(Module* parent) - : SplitCommand(parent, "TOPIC", 1, 2) - , secretmode(parent, "secret") - , topiclockmode(parent, "topiclock") - { - syntax = "<channel> [<topic>]"; - Penalty = 2; - } - - /** 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 HandleLocal(const std::vector<std::string>& parameters, LocalUser* user); -}; + syntax = "<channel> [<topic>]"; + Penalty = 2; +} CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) { @@ -101,6 +84,3 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, c->SetTopic(user, t); return CMD_SUCCESS; } - - -COMMAND_INIT(CommandTopic) diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp new file mode 100644 index 000000000..47f722e1e --- /dev/null +++ b/src/coremods/core_channel/core_channel.cpp @@ -0,0 +1,43 @@ +/* + * 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_channel.h" + +class CoreModChannel : public Module +{ + CommandInvite cmdinvite; + CommandJoin cmdjoin; + CommandKick cmdkick; + CommandNames cmdnames; + CommandTopic cmdtopic; + + public: + CoreModChannel() + : cmdinvite(this), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this) + { + } + + Version GetVersion() CXX11_OVERRIDE + { + return Version("Provides the INVITE, JOIN, KICK, NAMES, and TOPIC commands", VF_VENDOR|VF_CORE); + } +}; + +MODULE_INIT(CoreModChannel) diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h new file mode 100644 index 000000000..d3adbc9c9 --- /dev/null +++ b/src/coremods/core_channel/core_channel.h @@ -0,0 +1,114 @@ +/* + * 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/>. + */ + + +#pragma once + +#include "inspircd.h" + +/** Handle /INVITE. + */ +class CommandInvite : public Command +{ + public: + /** Constructor for invite. + */ + CommandInvite (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 /JOIN. + */ +class CommandJoin : public SplitCommand +{ + public: + /** Constructor for join. + */ + CommandJoin(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 HandleLocal(const std::vector<std::string>& parameters, LocalUser* user); +}; + +/** Handle /TOPIC. + */ +class CommandTopic : public SplitCommand +{ + ChanModeReference secretmode; + ChanModeReference topiclockmode; + + public: + /** Constructor for topic. + */ + CommandTopic(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 HandleLocal(const std::vector<std::string>& parameters, LocalUser* user); +}; + +/** Handle /NAMES. + */ +class CommandNames : public Command +{ + ChanModeReference secretmode; + + public: + /** Constructor for names. + */ + CommandNames(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); +}; + +/** Handle /KICK. + */ +class CommandKick : public Command +{ + public: + /** Constructor for kick. + */ + CommandKick(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); +}; |