InspIRCd
2.0
|
#include <mode.h>
Public Member Functions | |
ModeHandler (Module *me, const std::string &name, char modeletter, ParamSpec params, ModeType type) | |
virtual CullResult | cull () |
bool | IsListMode () |
char | GetPrefix () const |
virtual unsigned int | GetPrefixRank () |
ModeType | GetModeType () const |
TranslateType | GetTranslateType () const |
bool | NeedsOper () const |
int | GetNumParams (bool adding) |
char | GetModeChar () |
virtual std::string | GetUserParameter (User *useor) |
virtual ModResult | AccessCheck (User *source, Channel *channel, std::string ¶meter, bool adding) |
virtual ModeAction | OnModeChange (User *source, User *dest, Channel *channel, std::string ¶meter, bool adding) |
virtual void | DisplayList (User *user, Channel *channel) |
virtual void | OnParameterMissing (User *user, User *dest, Channel *channel) |
virtual void | DisplayEmptyList (User *user, Channel *channel) |
virtual bool | ResolveModeConflict (std::string &their_param, const std::string &our_param, Channel *channel) |
virtual void | RemoveMode (User *user, irc::modestacker *stack=NULL) |
virtual void | RemoveMode (Channel *channel, irc::modestacker *stack=NULL) |
unsigned int | GetLevelRequired () const |
![]() | |
ServiceProvider (Module *Creator, const std::string &Name, ServiceType Type) | |
Protected Attributes | |
TranslateType | m_paramtype |
ParamSpec | parameters_taken |
char | mode |
char | prefix |
bool | oper |
bool | list |
ModeType | m_type |
int | levelrequired |
Additional Inherited Members | |
![]() | |
ModuleRef | creator |
const std::string | name |
const ServiceType | service |
Each mode is implemented by ONE ModeHandler class. You must derive ModeHandler and add the child class to the list of modes handled by the ircd, using ModeParser::AddMode. When the mode you implement is set by a user, the virtual function OnModeChange is called. If you specify a value greater than 0 for parameters_on or parameters_off, then when the mode is set or unset respectively, std::string ¶meter will contain the parameter given by the user, else it will contain an empty string. You may alter this parameter string, and if you alter it to an empty string, and your mode is expected to have a parameter, then this is equivalent to returning MODEACTION_DENY.
ModeHandler::ModeHandler | ( | Module * | me, |
const std::string & | name, | ||
char | modeletter, | ||
ParamSpec | params, | ||
ModeType | type | ||
) |
The constructor for ModeHandler initalizes the mode handler. The constructor of any class you derive from ModeHandler should probably call this constructor with the parameters set correctly.
me | The module which created this mode |
name | A one-word name for the mode |
modeletter | The mode letter you wish to handle |
params | Parameters taken by the mode |
type | Type of the mode (MODETYPE_USER or MODETYPE_CHANNEL) |
|
virtual |
Called when a channel mode change access check for your mode occurs.
source | Contains the user setting the mode. |
channel | contains the destination channel the modes are being set on. |
parameter | The parameter for your mode. This is modifiable. |
adding | This value is true when the mode is being set, or false when it is being unset. |
|
virtual |
Called just prior to destruction via cull list.
Reimplemented from classbase.
If your mode is a listmode, this method will be called to display an empty list (just the end of list numeric)
user | The user issuing the command |
channel | The channel tehy're requesting an item list of (e.g. a banlist, or an exception list etc) |
If your mode is a listmode, then this method will be called for displaying an item list, e.g. on MODE #channel +modechar without any parameter or other modes in the command.
user | The user issuing the command |
channel | The channel they're requesting an item list of (e.g. a banlist, or an exception list etc) |
|
inline |
Returns the mode character this handler handles.
|
inline |
Returns the mode's type
int ModeHandler::GetNumParams | ( | bool | adding | ) |
Returns the number of parameters for the mode. Any non-zero value should be considered to be equivalent to one.
adding | If this is true, the number of parameters required to set the mode should be returned, otherwise the number of parameters required to unset the mode shall be returned. |
|
inline |
Mode prefix or 0. If this is defined, you should also implement GetPrefixRank() to return an integer value for this mode prefix.
|
virtual |
Get the 'value' of this modes prefix. determines which to display when there are multiple. The mode with the highest value is ranked first. See the PrefixModeValue enum and Channel::GetPrefixValue() for more information.
|
inline |
Returns the mode's parameter translation type
|
virtual |
For user modes, return the current parameter, if any
bool ModeHandler::IsListMode | ( | ) |
Returns true if the mode is a list mode
|
inline |
Returns true if the mode can only be set/unset by an oper
|
virtual |
Called when a mode change for your mode occurs.
source | Contains the user setting the mode. |
dest | For usermodes, contains the destination user the mode is being set on. For channelmodes, this is an undefined value. |
channel | For channel modes, contains the destination channel the modes are being set on. For usermodes, this is an undefined value. |
parameter | The parameter for your mode, if you indicated that your mode requires a parameter when being set or unset. Note that if you alter this value, the new value becomes the one displayed and send out to the network, also, if you set this to an empty string but you specified your mode REQUIRES a parameter, this is equivalent to returning MODEACTION_DENY and will prevent the mode from being displayed. |
adding | This value is true when the mode is being set, or false when it is being unset. |
Reimplemented in ParamChannelModeHandler, SimpleChannelModeHandler, and SimpleUserModeHandler.
In the event that the mode should be given a parameter, and no parameter was provided, this method is called. This allows you to give special information to the user, or handle this any way you like.
user | The user issuing the mode change |
dest | For user mode changes, the target of the mode. For channel mode changes, NULL. |
channel | For channel mode changes, the target of the mode. For user mode changes, NULL. |
|
virtual |
When a MODETYPE_CHANNEL mode handler is being removed, the server will call this method for every channel on the server. Your mode handler should remove its user mode from the channel by sending the appropriate server modes using InspIRCd::SendMode(). The default implementation of this method can remove simple modes which have no parameters, and can be used when your mode is of this type, otherwise you must implement a more advanced version of it to remove your mode properly from each channel. Note that in the case of listmodes, you should remove the entire list of items.
channel | The channel which the server wants to remove your mode from |
stack | The mode stack to add the mode change to |
This default implementation can remove simple channel modes (no parameters)
|
virtual |
When a MODETYPE_USER mode handler is being removed, the server will call this method for every user on the server. Your mode handler should remove its user mode from the user by sending the appropriate server modes using InspIRCd::SendMode(). The default implementation of this method can remove simple modes which have no parameters, and can be used when your mode is of this type, otherwise you must implement a more advanced version of it to remove your mode properly from each user.
user | The user which the server wants to remove your mode from |
stack | The mode stack to add the mode change to |
This default implementation can remove simple user modes
|
virtual |
If your mode needs special action during a server sync to determine which side wins when comparing timestamps, override this function and use it to return true or false. The default implementation just returns true if theirs < ours. This will only be called for non-listmodes with parameters, when adding the mode and where theirs == ours (therefore the default implementation will always return false).
their_param | Their parameter if the mode has a parameter |
our_param | Our parameter if the mode has a parameter |
channel | The channel we are checking against |
|
protected |
The prefix char needed on channel to use this mode, only checked for channel modes
|
protected |
Mode is a 'list' mode. The behaviour of your mode is now set entirely within the class as of the 1.1 api, rather than inside the mode parser as in the 1.0 api, so the only use of this value (along with IsListMode()) is for the core to determine wether your module can produce 'lists' or not (e.g. banlists, etc)
|
protected |
The mode parameter translation type
|
protected |
The mode type, either MODETYPE_USER or MODETYPE_CHANNEL.
|
protected |
The mode letter you're implementing.
|
protected |
True if the mode requires oper status to set.
|
protected |
What kind of parameters does the mode take?
|
protected |
Mode prefix, or 0