From 34f1ef3c9b2a50bbeb3c97eb9f4d5e07895e27db Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 5 Mar 2014 16:04:06 +0100 Subject: Create the core_channel module --- src/coremods/core_channel/cmd_invite.cpp | 30 +++----- src/coremods/core_channel/cmd_join.cpp | 28 ++----- src/coremods/core_channel/cmd_kick.cpp | 28 +++---- src/coremods/core_channel/cmd_names.cpp | 30 ++------ src/coremods/core_channel/cmd_topic.cpp | 36 ++------- src/coremods/core_channel/core_channel.cpp | 43 +++++++++++ src/coremods/core_channel/core_channel.h | 114 +++++++++++++++++++++++++++++ 7 files changed, 196 insertions(+), 113 deletions(-) create mode 100644 src/coremods/core_channel/core_channel.cpp create mode 100644 src/coremods/core_channel/core_channel.h 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 = "[ ]"; } - /** 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& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector& parameters) - { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); - } -}; + Penalty = 4; + syntax = "[ ]"; +} /** Handle /INVITE */ @@ -155,5 +143,7 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use return CMD_SUCCESS; } - -COMMAND_INIT(CommandInvite) +RouteDescriptor CommandInvite::GetRouting(User* user, const std::vector& 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 = "{,} {{,}}"; - 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& parameters, LocalUser* user); -}; + syntax = "{,} {{,}}"; + Penalty = 2; +} /** Handle /JOIN */ @@ -72,5 +58,3 @@ CmdResult CommandJoin::HandleLocal(const std::vector& 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 = " {,} []"; } - /** 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& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector& parameters) - { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); - } -}; + syntax = " {,} []"; +} /** Handle /KICK */ @@ -93,4 +80,7 @@ CmdResult CommandKick::Handle (const std::vector& parameters, User return CMD_SUCCESS; } -COMMAND_INIT(CommandKick) +RouteDescriptor CommandKick::GetRouting(User* user, const std::vector& 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 = "{{,}}"; - } - - /** 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& parameters, User *user); -}; + syntax = "{{,}}"; +} /** Handle /NAMES */ @@ -76,5 +60,3 @@ CmdResult CommandNames::Handle (const std::vector& 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 = " []"; - 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& parameters, LocalUser* user); -}; + syntax = " []"; + Penalty = 2; +} CmdResult CommandTopic::HandleLocal(const std::vector& parameters, LocalUser* user) { @@ -101,6 +84,3 @@ CmdResult CommandTopic::HandleLocal(const std::vector& 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 + * + * 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 . + */ + + +#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 + * + * 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 . + */ + + +#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& parameters, User*user); + RouteDescriptor GetRouting(User* user, const std::vector& 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& 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& 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& 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& parameters, User *user); + RouteDescriptor GetRouting(User* user, const std::vector& parameters); +}; -- cgit v1.2.3