Create the core_channel module

This commit is contained in:
Attila Molnar 2014-03-05 16:04:06 +01:00
parent c67d3103e9
commit 34f1ef3c9b
7 changed files with 196 additions and 113 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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);
};