The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Command Class Reference

A structure that defines a command. More...

#include <ctables.h>

Inheritance diagram for Command:

Inheritance graph
[legend]
Collaboration diagram for Command:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Command (InspIRCd *Instance, const std::string &cmd, const char *flags, int minpara, int before_reg=false, int penalty=1)
 Create a new command.
virtual CmdResult Handle (const std::vector< std::string > &parameters, User *user)=0
 Handle the command from a user.
virtual CmdResult HandleInternal (const unsigned int, const std::deque< classbase * > &)
 Handle an internal request from another command, the core, or a module.
virtual CmdResult HandleServer (const std::vector< std::string > &, const std::string &)
 Handle the command from a server.
virtual void EncodeParameter (std::string &parameter, int index)
 Encode a parameter for server->server transmission.
virtual void DecodeParameter (std::string &parameter, int index)
 Decode a parameter from server->server transmission.
void Disable (bool setting)
 Disable or enable this command.
bool IsDisabled ()
 Obtain this command's disable state.
bool WorksBeforeReg ()
virtual ~Command ()
 Standard constructor gubbins.

Public Attributes

std::string command
 Command name.
char flags_needed
 User flags needed to execute the command or 0.
unsigned int min_params
 Minimum number of parameters command takes.
long double use_count
 used by /stats m
long double total_bytes
 used by /stats m
std::string source
 used for resource tracking between modules
bool disabled
 True if the command is disabled to non-opers.
bool works_before_reg
 True if the command can be issued before registering.
std::string syntax
 Syntax string for the command, displayed if non-empty string.
std::vector< TranslateTypetranslation
const int Penalty
 How many seconds worth of penalty does this command have?

Protected Attributes

InspIRCdServerInstance
 Owner/Creator object.

Detailed Description

A structure that defines a command.

Every command available in InspIRCd must be defined as derived from Command.

Definition at line 48 of file ctables.h.


Constructor & Destructor Documentation

Command::Command InspIRCd Instance,
const std::string cmd,
const char *  flags,
int  minpara,
int  before_reg = false,
int  penalty = 1
[inline]
 

Create a new command.

Parameters:
Instance Pointer to creator class
cmd Command name. This must be UPPER CASE.
flags User mode required to execute the command. May ONLY be one mode - it's a string to give warnings if people mix params up. For oper only commands, set this to 'o', otherwise use 0.
minpara Minimum parameters required for the command.
before_reg If this is set to true, the command will be allowed before the user is 'registered' (has sent USER, NICK, optionally PASS, and been resolved).

Definition at line 100 of file ctables.h.

virtual Command::~Command  )  [inline, virtual]
 

Standard constructor gubbins.

Definition at line 188 of file ctables.h.


Member Function Documentation

virtual void Command::DecodeParameter std::string parameter,
int  index
[inline, virtual]
 

Decode a parameter from server->server transmission.

Not currently used in this version of InspIRCd. Used for parameters for which the translation type is TR_CUSTOM.

Parameters:
parameter The parameter to decode. Can be modified in place.
index The parameter index (0 == first parameter).

Definition at line 158 of file ctables.h.

void Command::Disable bool  setting  )  [inline]
 

Disable or enable this command.

Parameters:
setting True to disable the command.

Definition at line 165 of file ctables.h.

virtual void Command::EncodeParameter std::string parameter,
int  index
[inline, virtual]
 

Encode a parameter for server->server transmission.

Used for parameters for which the translation type is TR_CUSTOM.

Parameters:
parameter The parameter to encode. Can be modified in place.
index The parameter index (0 == first parameter).

Reimplemented in CommandAccept.

Definition at line 148 of file ctables.h.

Referenced by ModuleSpanningTree::OnPostCommand().

virtual CmdResult Command::Handle const std::vector< std::string > &  parameters,
User user
[pure virtual]
 

Handle the command from a user.

Parameters:
parameters The parameters for the command.
user The user who issued the command.
Returns:
Return CMD_SUCCESS on success, or CMD_FAILURE on failure. If the command succeeds but should remain local to this server, return CMD_LOCALONLY.

Implemented in CommandAlltime, CommandAccept, CommandCAP, CommandCBan, CommandWebirc, CommandCheck, CommandChghost, CommandChgident, CommandChgname, CommandClones, CommandClose, CommandTitle, CommandCycle, CommandDccallow, CommandDevoice, CommandFilter, CommandGloadmodule, CommandGunloadmodule, CommandGreloadmodule, CommandGlobops, CommandHelpop, CommandJumpserver, CommandKnock, CommandLockserv, CommandUnlockserv, CommandNicklock, CommandNickunlock, CommandOpermotd, CommandMkpasswd, CommandRandquote, CommandRemove, CommandFpart, CommandSajoin, CommandSamode, CommandSanick, CommandSapart, CommandSaquit, CommandAuthenticate, CommandSATopic, CommandSethost, CommandSetident, CommandSetidle, CommandSetname, cmd_shun, CommandSVSSilence, CommandSilence, CommandSvshold, CommandSwhois, CommandTaxonomy, CommandDalinfo, CommandTban, CommandTline, CommandUninvite, CommandUserip, CommandVhost, CommandSVSWatch, CommandWatch, CommandRLine, CommandStartTLS, cmd_fingerprint, cmd_sslinfo, cmd_rconnect, cmd_rsquit, CommandAdmin, CommandAway, CommandClearcache, CommandCommands, CommandConnect, CommandDie, CommandEline, CommandGline, CommandInfo, CommandInvite, CommandIson, CommandJoin, CommandKick, CommandKill, CommandKline, CommandLinks, CommandList, CommandLoadmodule, CommandLusers, CommandMap, CommandMode, CommandModules, CommandMotd, CommandNames, CommandNick, CommandNotice, CommandOper, CommandPart, CommandPass, CommandPing, CommandPong, CommandPrivmsg, CommandQline, CommandQuit, CommandRehash, CommandReloadmodule, CommandRestart, CommandRules, CommandServer, CommandSquit, CommandStats, CommandTime, CommandTopic, CommandTrace, CommandUnloadmodule, CommandUser, CommandUserhost, CommandVersion, CommandWallops, CommandWho, CommandWhois, CommandWhowas, CommandZline, and cmd_reload.

Referenced by ModuleSQLOper::LoginFail(), CommandParser::LoopCall(), FilterBase::OnPreCommand(), ModuleInvisible::OnUserQuit(), ModuleDelayJoin::OnUserQuit(), and ModuleAuditorium::OnUserQuit().

virtual CmdResult Command::HandleInternal const unsigned int  ,
const std::deque< classbase * > & 
[inline, virtual]
 

Handle an internal request from another command, the core, or a module.

Parameters:
Command ID
Zero or more parameters, whos form is specified by the command ID.
Returns:
Return CMD_SUCCESS on success, or CMD_FAILURE on failure. If the command succeeds but should remain local to this server, return CMD_LOCALONLY.

Reimplemented in CommandNick, and CommandWhowas.

Definition at line 125 of file ctables.h.

References CMD_INVALID.

Referenced by User::AddToWhoWas(), User::ForceNickChange(), and ValidateWhoWas().

virtual CmdResult Command::HandleServer const std::vector< std::string > &  ,
const std::string
[inline, virtual]
 

Handle the command from a server.

Not currently used in this version of InspIRCd.

Parameters:
parameters The parameters given
servername The server name which issued the command
Returns:
Return CMD_SUCCESS on success, or CMD_FAILURE on failure. If the command succeeds but should remain local to this server, return CMD_LOCALONLY.

Definition at line 138 of file ctables.h.

References CMD_INVALID.

bool Command::IsDisabled  )  [inline]
 

Obtain this command's disable state.

Returns:
true if the command is currently disabled (disabled commands can be used only by operators)

Definition at line 174 of file ctables.h.

bool Command::WorksBeforeReg  )  [inline]
 

Returns:
true if the command works before registration.

Definition at line 181 of file ctables.h.


Member Data Documentation

std::string Command::command
 

Command name.

Definition at line 57 of file ctables.h.

Referenced by InspIRCd::AddCommand(), and CommandParser::CreateCommand().

bool Command::disabled
 

True if the command is disabled to non-opers.

Definition at line 75 of file ctables.h.

char Command::flags_needed
 

User flags needed to execute the command or 0.

Definition at line 60 of file ctables.h.

Referenced by ModuleOperLog::OnPreCommand().

unsigned int Command::min_params
 

Minimum number of parameters command takes.

Definition at line 63 of file ctables.h.

const int Command::Penalty
 

How many seconds worth of penalty does this command have?

Definition at line 88 of file ctables.h.

InspIRCd* Command::ServerInstance [protected]
 

Owner/Creator object.

Definition at line 53 of file ctables.h.

Referenced by CommandWatch::add_watch(), CommandAccept::EncodeParameter(), cmd_rsquit::Handle(), cmd_rconnect::Handle(), CommandWatch::Handle(), CommandSVSWatch::Handle(), CommandVhost::Handle(), CommandUserip::Handle(), CommandUninvite::Handle(), CommandTline::Handle(), CommandTban::Handle(), CommandTaxonomy::Handle(), CommandSwhois::Handle(), CommandSvshold::Handle(), cmd_sslinfo::Handle(), cmd_fingerprint::Handle(), CommandStartTLS::Handle(), CommandSVSSilence::Handle(), cmd_shun::Handle(), CommandSetname::Handle(), CommandSetidle::Handle(), CommandSetident::Handle(), CommandSethost::Handle(), CommandSATopic::Handle(), CommandAuthenticate::Handle(), CommandSaquit::Handle(), CommandSapart::Handle(), CommandSanick::Handle(), CommandSamode::Handle(), CommandSajoin::Handle(), CommandRLine::Handle(), CommandNickunlock::Handle(), CommandNicklock::Handle(), CommandUnlockserv::Handle(), CommandLockserv::Handle(), CommandKnock::Handle(), CommandJumpserver::Handle(), CommandGlobops::Handle(), CommandGreloadmodule::Handle(), CommandGunloadmodule::Handle(), CommandGloadmodule::Handle(), CommandFilter::Handle(), CommandDevoice::Handle(), CommandDccallow::Handle(), CommandCycle::Handle(), CommandTitle::Handle(), CommandClose::Handle(), CommandClones::Handle(), CommandChgname::Handle(), CommandChgident::Handle(), CommandChghost::Handle(), CommandCheck::Handle(), CommandWebirc::Handle(), CommandCBan::Handle(), CommandAccept::Handle(), CommandAlltime::Handle(), cmd_reload::Handle(), cmd_rsquit::NoticeUser(), and CommandWatch::remove_watch().

std::string Command::source
 

used for resource tracking between modules

Definition at line 72 of file ctables.h.

Referenced by cmd_fingerprint::cmd_fingerprint(), cmd_rconnect::cmd_rconnect(), cmd_rsquit::cmd_rsquit(), cmd_shun::cmd_shun(), cmd_sslinfo::cmd_sslinfo(), CommandAccept::CommandAccept(), CommandAlltime::CommandAlltime(), CommandAuthenticate::CommandAuthenticate(), CommandCAP::CommandCAP(), CommandCBan::CommandCBan(), CommandCheck::CommandCheck(), CommandChghost::CommandChghost(), CommandChgident::CommandChgident(), CommandChgname::CommandChgname(), CommandClones::CommandClones(), CommandClose::CommandClose(), CommandCycle::CommandCycle(), CommandDalinfo::CommandDalinfo(), CommandDccallow::CommandDccallow(), CommandDevoice::CommandDevoice(), CommandFilter::CommandFilter(), CommandFpart::CommandFpart(), CommandGloadmodule::CommandGloadmodule(), CommandGlobops::CommandGlobops(), CommandGreloadmodule::CommandGreloadmodule(), CommandGunloadmodule::CommandGunloadmodule(), CommandHelpop::CommandHelpop(), CommandJumpserver::CommandJumpserver(), CommandKnock::CommandKnock(), CommandLockserv::CommandLockserv(), CommandMkpasswd::CommandMkpasswd(), CommandNicklock::CommandNicklock(), CommandNickunlock::CommandNickunlock(), CommandOpermotd::CommandOpermotd(), CommandRandquote::CommandRandquote(), CommandRemove::CommandRemove(), CommandRLine::CommandRLine(), CommandSajoin::CommandSajoin(), CommandSamode::CommandSamode(), CommandSanick::CommandSanick(), CommandSapart::CommandSapart(), CommandSaquit::CommandSaquit(), CommandSATopic::CommandSATopic(), CommandSethost::CommandSethost(), CommandSetident::CommandSetident(), CommandSetidle::CommandSetidle(), CommandSetname::CommandSetname(), CommandSilence::CommandSilence(), CommandStartTLS::CommandStartTLS(), CommandSvshold::CommandSvshold(), CommandSVSSilence::CommandSVSSilence(), CommandSVSWatch::CommandSVSWatch(), CommandSwhois::CommandSwhois(), CommandTaxonomy::CommandTaxonomy(), CommandTban::CommandTban(), CommandTitle::CommandTitle(), CommandTline::CommandTline(), CommandUninvite::CommandUninvite(), CommandUnlockserv::CommandUnlockserv(), CommandUserip::CommandUserip(), CommandVhost::CommandVhost(), CommandWatch::CommandWatch(), and CommandWebirc::CommandWebirc().

std::string Command::syntax
 

Syntax string for the command, displayed if non-empty string.

This takes place of the text in the 'not enough parameters' numeric.

Definition at line 82 of file ctables.h.

Referenced by cmd_fingerprint::cmd_fingerprint(), cmd_rconnect::cmd_rconnect(), cmd_reload::cmd_reload(), cmd_rsquit::cmd_rsquit(), cmd_sslinfo::cmd_sslinfo(), CommandAccept::CommandAccept(), CommandAdmin::CommandAdmin(), CommandAlltime::CommandAlltime(), CommandAway::CommandAway(), CommandCBan::CommandCBan(), CommandCheck::CommandCheck(), CommandChghost::CommandChghost(), CommandChgident::CommandChgident(), CommandChgname::CommandChgname(), CommandClones::CommandClones(), CommandConnect::CommandConnect(), CommandCycle::CommandCycle(), CommandDccallow::CommandDccallow(), CommandDevoice::CommandDevoice(), CommandDie::CommandDie(), CommandEline::CommandEline(), CommandFilter::CommandFilter(), CommandFpart::CommandFpart(), CommandGline::CommandGline(), CommandGloadmodule::CommandGloadmodule(), CommandGlobops::CommandGlobops(), CommandGreloadmodule::CommandGreloadmodule(), CommandGunloadmodule::CommandGunloadmodule(), CommandHelpop::CommandHelpop(), CommandInfo::CommandInfo(), CommandInvite::CommandInvite(), CommandIson::CommandIson(), CommandJoin::CommandJoin(), CommandJumpserver::CommandJumpserver(), CommandKick::CommandKick(), CommandKill::CommandKill(), CommandKline::CommandKline(), CommandKnock::CommandKnock(), CommandLoadmodule::CommandLoadmodule(), CommandLockserv::CommandLockserv(), CommandMkpasswd::CommandMkpasswd(), CommandMode::CommandMode(), CommandModules::CommandModules(), CommandMotd::CommandMotd(), CommandNames::CommandNames(), CommandNick::CommandNick(), CommandNicklock::CommandNicklock(), CommandNickunlock::CommandNickunlock(), CommandNotice::CommandNotice(), CommandOper::CommandOper(), CommandOpermotd::CommandOpermotd(), CommandPart::CommandPart(), CommandPass::CommandPass(), CommandPing::CommandPing(), CommandPong::CommandPong(), CommandPrivmsg::CommandPrivmsg(), CommandQline::CommandQline(), CommandQuit::CommandQuit(), CommandRehash::CommandRehash(), CommandReloadmodule::CommandReloadmodule(), CommandRemove::CommandRemove(), CommandRestart::CommandRestart(), CommandRules::CommandRules(), CommandSajoin::CommandSajoin(), CommandSamode::CommandSamode(), CommandSanick::CommandSanick(), CommandSapart::CommandSapart(), CommandSaquit::CommandSaquit(), CommandSATopic::CommandSATopic(), CommandSethost::CommandSethost(), CommandSetident::CommandSetident(), CommandSetidle::CommandSetidle(), CommandSetname::CommandSetname(), CommandSilence::CommandSilence(), CommandSquit::CommandSquit(), CommandStats::CommandStats(), CommandSvshold::CommandSvshold(), CommandSVSSilence::CommandSVSSilence(), CommandSVSWatch::CommandSVSWatch(), CommandSwhois::CommandSwhois(), CommandTaxonomy::CommandTaxonomy(), CommandTban::CommandTban(), CommandTime::CommandTime(), CommandTitle::CommandTitle(), CommandTline::CommandTline(), CommandTopic::CommandTopic(), CommandTrace::CommandTrace(), CommandUninvite::CommandUninvite(), CommandUnloadmodule::CommandUnloadmodule(), CommandUnlockserv::CommandUnlockserv(), CommandUser::CommandUser(), CommandUserhost::CommandUserhost(), CommandUserip::CommandUserip(), CommandVersion::CommandVersion(), CommandVhost::CommandVhost(), CommandWallops::CommandWallops(), CommandWatch::CommandWatch(), CommandWebirc::CommandWebirc(), CommandWho::CommandWho(), CommandWhois::CommandWhois(), and CommandZline::CommandZline().

long double Command::total_bytes
 

used by /stats m

Definition at line 69 of file ctables.h.

std::vector<TranslateType> Command::translation
 

Definition at line 84 of file ctables.h.

Referenced by CommandAlltime::CommandAlltime(), and ModuleSpanningTree::OnPostCommand().

long double Command::use_count
 

used by /stats m

Definition at line 66 of file ctables.h.

bool Command::works_before_reg
 

True if the command can be issued before registering.

Definition at line 78 of file ctables.h.


The documentation for this class was generated from the following file: