InspIRCd  4.0
Public Member Functions | Protected Attributes | List of all members
PrefixMode Class Reference

#include <mode.h>

Inheritance diagram for PrefixMode:
ModeHandler ServiceProvider Cullable insp::uncopiable

Public Member Functions

 PrefixMode (Module *Creator, const std::string &Name, char ModeLetter, unsigned int Rank=0, char PrefixChar=0)
ModResult AccessCheck (User *source, Channel *channel, Modes::Change &change) override
ModeAction OnModeChange (User *source, User *dest, Channel *channel, Modes::Change &change) override
void Update (unsigned int rank, unsigned int setrank, unsigned int unsetrank, bool selfrm)
void RemoveMode (Channel *channel, Modes::ChangeList &changelist) override
bool CanSelfRemove () const
char GetPrefix () const
unsigned int GetPrefixRank () const
- Public Member Functions inherited from ModeHandler
 ModeHandler (Module *me, const std::string &name, char modeletter, ParamSpec params, ModeType type, Class mclass=MC_OTHER)
Cullable::Result Cull () override
void RegisterService () override
bool IsListMode () const
PrefixModeIsPrefixMode ()
const PrefixModeIsPrefixMode () const
ListModeBaseIsListModeBase ()
const ListModeBaseIsListModeBase () const
ParamModeBaseIsParameterMode ()
const ParamModeBaseIsParameterMode () 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 void DisplayList (User *user, Channel *channel)
virtual void OnParameterMissing (User *user, User *dest, Channel *channel)
virtual void OnParameterInvalid (User *user, Channel *targetchannel, User *targetuser, const std::string &parameter)
virtual void DisplayEmptyList (User *user, Channel *channel)
virtual bool ResolveModeConflict (const std::string &their_param, const std::string &our_param, Channel *channel)
void RemoveMode (User *user)
unsigned int GetLevelRequired (bool adding) const
const std::string & GetSyntax () const
- Public Member Functions inherited from ServiceProvider
 ServiceProvider (Module *Creator, const std::string &Name, ServiceType Type)
const char * GetTypeString () const
void DisableAutoRegister ()
- Public Member Functions inherited from Cullable
virtual ~Cullable ()

Protected Attributes

char prefix
unsigned int prefixrank
bool selfremove = true
- Protected Attributes inherited from ModeHandler
ParamSpec parameters_taken
char mode
bool oper = false
bool list = false
ModeType m_type
const Class type_id
unsigned int ranktoset = HALFOP_VALUE
unsigned int ranktounset = HALFOP_VALUE
std::string syntax

Additional Inherited Members

- Public Types inherited from ModeHandler
typedef size_t Id
- Public Attributes inherited from ServiceProvider
ModuleRef creator
const std::string name
const ServiceType service
- Protected Member Functions inherited from Cullable
 Cullable ()

Detailed Description

Prefix modes are channel modes that grant a specific rank to members having prefix mode set. They require a parameter when setting and unsetting; the parameter is always a member of the channel. A prefix mode may be set on any number of members on a channel, but for a given member a given prefix mode is either set or not set, in other words members cannot have the same prefix mode set more than once.

A rank of a member is defined as the rank given by the 'strongest' prefix mode that member has. Other parts of the IRCd use this rank to determine whether a channel action is allowable for a user or not. The rank of a prefix mode is constant, i.e. the same rank value is given to all users having that prefix mode set.

Note that it is possible that the same action requires a different rank on a different channel; for example changing the topic on a channel having +t set requires a rank that is >= than the rank of a halfop, but there is no such restriction when +t isn't set.

Constructor & Destructor Documentation

◆ PrefixMode()

PrefixMode::PrefixMode ( Module Creator,
const std::string &  Name,
char  ModeLetter,
unsigned int  Rank = 0,
char  PrefixChar = 0 


CreatorThe module creating this mode
NameThe user-friendly one word name of the prefix mode, e.g.: "op", "voice"
ModeLetterThe mode letter of this mode
RankRank given by this prefix mode, see explanation above
PrefixCharPrefix character, or 0 if the mode has no prefix character

Member Function Documentation

◆ AccessCheck()

ModResult PrefixMode::AccessCheck ( User source,
Channel channel,
Modes::Change change 

Called when a channel mode change access check for your mode occurs.

sourceContains the user setting the mode.
channelcontains the destination channel the modes are being set on.
changeInformation regarding the mode change.
allow, deny, or passthru to check against the required level

Reimplemented from ModeHandler.

◆ CanSelfRemove()

bool PrefixMode::CanSelfRemove ( ) const

Determines whether a user with this prefix mode can remove it.

◆ GetPrefix()

char PrefixMode::GetPrefix ( ) const

Mode prefix or 0. If this is defined, you should also implement GetPrefixRank() to return an integer value for this mode prefix.

◆ GetPrefixRank()

unsigned int PrefixMode::GetPrefixRank ( ) const

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.

◆ OnModeChange()

ModeAction PrefixMode::OnModeChange ( User source,
User dest,
Channel channel,
Modes::Change change 

Handles setting and unsetting the prefix mode. Finds the given member of the given channel, if it's not found an error message is sent to 'source' and MODEACTION_DENY is returned. Otherwise the mode change is attempted.

sourceSource of the mode change, an error message is sent to this user if the target is not found
channelThe channel the mode change is happening on
changeInformation regarding the mode change.
MODEACTION_ALLOW if the change happened, MODEACTION_DENY if no change happened The latter occurs either when the member cannot be found or when the member already has this prefix set (when setting) or doesn't have this prefix set (when unsetting).

Reimplemented from ModeHandler.

◆ RemoveMode()

void PrefixMode::RemoveMode ( Channel channel,
Modes::ChangeList changelist 

Removes this prefix mode from all users on the given channel

channelThe channel which the server wants to remove your mode from
changelistMode change list to populate with the removal of this mode

Reimplemented from ModeHandler.

◆ Update()

void PrefixMode::Update ( unsigned int  rank,
unsigned int  setrank,
unsigned int  unsetrank,
bool  selfrm 

Updates the configuration of this prefix.

rankThe prefix rank of this mode.
setrankThe prefix rank required to set this mode on channels.
unsetrankThe prefix rank required to set this unmode on channels.
selfrmWhether a client with this prefix can remove it from themself.

Member Data Documentation

◆ prefix

char PrefixMode::prefix

The prefix character granted by this mode. '@' for op, '+' for voice, etc. If 0, this mode does not have a visible prefix character.

◆ prefixrank

unsigned int PrefixMode::prefixrank

The prefix rank of this mode, used to compare prefix modes

◆ selfremove

bool PrefixMode::selfremove = true

Whether a client with this prefix can remove it from themself.

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