InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | Public Attributes | List of all members
Command Class Referenceabstract

#include <ctables.h>

Inheritance diagram for Command:
ServiceProvider classbase SplitCommand

Public Member Functions

 Command (Module *me, const std::string &cmd, int minpara=0, int maxpara=0)
 
virtual CmdResult Handle (const std::vector< std::string > &parameters, User *user)=0
 
virtual RouteDescriptor GetRouting (User *user, const std::vector< std::string > &parameters)
 
virtual void EncodeParameter (std::string &parameter, int index)
 
virtual void DecodeParameter (std::string &parameter, int index)
 
void Disable (bool setting)
 
bool IsDisabled ()
 
bool WorksBeforeReg ()
 
- Public Member Functions inherited from ServiceProvider
 ServiceProvider (Module *Creator, const std::string &Name, ServiceType Type)
 
- Public Member Functions inherited from classbase
virtual CullResult cull ()
 

Public Attributes

char flags_needed
 
const unsigned int min_params
 
const unsigned int max_params
 
unsigned long use_count
 
unsigned long total_bytes
 
bool disabled
 
bool works_before_reg
 
bool allow_empty_last_param
 
std::string syntax
 
std::vector< TranslateType > translation
 
int Penalty
 
- Public Attributes inherited from ServiceProvider
ModuleRef creator
 
const std::string name
 
const ServiceType service
 

Detailed Description

A structure that defines a command. Every command available in InspIRCd must be defined as derived from Command.

Constructor & Destructor Documentation

Command::Command ( Module me,
const std::string &  cmd,
int  minpara = 0,
int  maxpara = 0 
)
inline

Create a new command.

Parameters
meThe module which created this command.
cmdCommand name. This must be UPPER CASE.
minparaMinimum parameters required for the command.
maxparaMaximum number of parameters this command may have - extra parameters will be tossed into one last space-seperated param.

Member Function Documentation

virtual void Command::DecodeParameter ( std::string &  parameter,
int  index 
)
inlinevirtual

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
parameterThe parameter to decode. Can be modified in place.
indexThe parameter index (0 == first parameter).
void Command::Disable ( bool  setting)
inline

Disable or enable this command.

Parameters
settingTrue to disable the command.
virtual void Command::EncodeParameter ( std::string &  parameter,
int  index 
)
inlinevirtual

Encode a parameter for server->server transmission. Used for parameters for which the translation type is TR_CUSTOM.

Parameters
parameterThe parameter to encode. Can be modified in place.
indexThe parameter index (0 == first parameter).
virtual CmdResult Command::Handle ( const std::vector< std::string > &  parameters,
User user 
)
pure virtual

Handle the command from a user.

Parameters
parametersThe parameters for the command.
userThe user who issued the command.
Returns
Return CMD_SUCCESS on success, or CMD_FAILURE on failure.

Implemented in SplitCommand.

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)
bool Command::WorksBeforeReg ( )
inline
Returns
true if the command works before registration.

Member Data Documentation

bool Command::allow_empty_last_param

True if the command allows an empty last parameter. When false and the last parameter is empty, it's popped BEFORE checking there are enough params, etc. (i.e. the handler won't be called if there aren't enough params after popping the empty param). True by default

bool Command::disabled

True if the command is disabled to non-opers

char Command::flags_needed

User flags needed to execute the command or 0

const unsigned int Command::max_params

Maximum number of parameters command takes. This is used by the command parser to join extra parameters into one last param. If not set, no munging is done to this command.

const unsigned int Command::min_params

Minimum number of parameters command takes

int Command::Penalty

How many seconds worth of penalty does this command have?

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.

unsigned long Command::total_bytes

used by /stats m

std::vector<TranslateType> Command::translation

Translation type list for possible parameters, used to tokenize parameters into UIDs and SIDs etc.

unsigned long Command::use_count

used by /stats m

bool Command::works_before_reg

True if the command can be issued before registering


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