mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 19:19:02 -04:00
Create the core_channel module
This commit is contained in:
parent
c67d3103e9
commit
34f1ef3c9b
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
43
src/coremods/core_channel/core_channel.cpp
Normal file
43
src/coremods/core_channel/core_channel.cpp
Normal 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)
|
114
src/coremods/core_channel/core_channel.h
Normal file
114
src/coremods/core_channel/core_channel.h
Normal 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);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user