InspIRCd
3.0
|
#include <mode.h>
Public Types | |
enum | Class { MC_PREFIX, MC_LIST, MC_PARAM, MC_OTHER } |
typedef size_t | Id |
Public Member Functions | |
ModeHandler (Module *me, const std::string &name, char modeletter, ParamSpec params, ModeType type, Class mclass=MC_OTHER) | |
CullResult | cull () CXX11_OVERRIDE |
void | RegisterService () CXX11_OVERRIDE |
bool | IsListMode () const |
PrefixMode * | IsPrefixMode () |
const PrefixMode * | IsPrefixMode () const |
ListModeBase * | IsListModeBase () |
const ListModeBase * | IsListModeBase () const |
ParamModeBase * | IsParameterMode () |
const ParamModeBase * | IsParameterMode () const |
ModeType | GetModeType () const |
bool | NeedsOper () const |
bool | NeedsParam (bool adding) const |
char | GetModeChar () const |
Id | GetId () const |
virtual std::string | GetUserParameter (const User *user) const |
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) |
void | RemoveMode (User *user) |
virtual void | RemoveMode (Channel *channel, Modes::ChangeList &changelist) |
unsigned int | GetLevelRequired (bool adding) const |
const std::string & | GetSyntax () const |
![]() | |
ServiceProvider (Module *Creator, const std::string &Name, ServiceType Type) | |
void | DisableAutoRegister () |
Protected Attributes | |
ParamSpec | parameters_taken |
char | mode |
bool | oper |
bool | list |
ModeType | m_type |
const Class | type_id |
unsigned int | ranktoset |
unsigned int | ranktounset |
std::string | syntax |
Friends | |
class | ModeParser |
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, | ||
Class | mclass = MC_OTHER |
||
) |
The constructor for ModeHandler initializes 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) |
mclass | The object type of this mode handler, one of ModeHandler::Class |
|
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. |
Reimplemented in PrefixMode.
|
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 they're requesting an item list of (e.g. a banlist, or an exception list etc) |
Reimplemented in ListModeBase.
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) |
Reimplemented in ListModeBase.
|
inline |
Return the id of this mode which is used in User::modes and Channel::modes as the index to determine whether a mode is set.
|
inline |
Retrieves the level required to modify this mode.
adding | Whether the mode is being added or removed. |
|
inline |
Returns the mode character this handler handles.
|
inline |
Returns the mode's type
|
inline |
Retrieves the syntax of the parameter for this mode.
|
virtual |
For user modes, return the current parameter, if any
|
inline |
Returns true if the mode is a list mode
|
inline |
Check whether this mode handler inherits from ListModeBase
const ListModeBase* ModeHandler::IsListModeBase | ( | ) | const |
Check whether this mode handler inherits from ListModeBase
|
inline |
Check whether this mode handler inherits from ParamModeBase
const ParamModeBase* ModeHandler::IsParameterMode | ( | ) | const |
Check whether this mode handler inherits from ParamModeBase
|
inline |
Check whether this mode is a prefix mode
const PrefixMode* ModeHandler::IsPrefixMode | ( | ) | const |
Check whether this mode is a prefix mode
|
inline |
Returns true if the mode can only be set/unset by an oper
bool ModeHandler::NeedsParam | ( | bool | adding | ) | const |
Check if the mode needs a parameter for adding or removing
adding | True to check if the mode needs a parameter when setting, false to check if the mode needs a parameter when unsetting |
|
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 SimpleChannelModeHandler, SimpleUserModeHandler, PrefixMode, ParamModeBase, and ListModeBase.
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. |
Reimplemented in ListModeBase.
|
virtual |
Register this object in the ModeParser
Reimplemented from ServiceProvider.
|
virtual |
When a MODETYPE_CHANNEL mode handler is being removed, the server will call this method for every channel on the server. The mode handler has to populate the given modestacker with mode changes that remove the mode from the channel. The default implementation of this method can remove all kinds of channel modes except listmodes. In the case of listmodes, the entire list of items must be added to the modestacker (which is handled by ListModeBase, so if you inherit from it or your mode can be removed by the default implementation then you do not have to implement this function).
channel | The channel which the server wants to remove your mode from |
changelist | Mode change list to populate with the removal of this mode |
Reimplemented in PrefixMode, and ListModeBase.
void ModeHandler::RemoveMode | ( | User * | user | ) |
When a MODETYPE_USER mode handler is being removed, the core will call this method for every user on the server. The usermode will be removed using the appropriate server mode using InspIRCd::SendMode().
user | The user which the server wants to remove your mode from |
|
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 |
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 whether your module can produce 'lists' or not (e.g. banlists, etc)
|
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 |
The prefix rank required to set this mode on channels.
|
protected |
The prefix rank required to unset this mode on channels.
|
protected |
If non-empty then the syntax of the parameter for this mode.
|
protected |
The object type of this mode handler