InspIRCd  3.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Channel Class Reference

#include <channels.h>

Inheritance diagram for Channel:
Extensible classbase Serializable

Public Types

typedef std::map< User *, insp::aligned_storage< Membership > > MemberMap
- Public Types inherited from Extensible
typedef insp::flat_map< reference< ExtensionItem >, void * > ExtensibleStore

Public Member Functions

 Channel (const std::string &name, time_t ts)
void CheckDestroy ()
void SetMode (ModeHandler *mode, bool value)
bool IsModeSet (ModeHandler *mode)
bool IsModeSet (ModeHandler &mode)
bool IsModeSet (ChanModeReference &mode)
std::string GetModeParameter (ModeHandler *mode)
std::string GetModeParameter (ChanModeReference &mode)
std::string GetModeParameter (ParamModeBase *pm)
void SetTopic (User *user, const std::string &topic, time_t topicts, const std::string *setter=NULL)
size_t GetUserCounter () const
MembershipAddUser (User *user)
void DelUser (User *user)
const MemberMapGetUsers () const
bool HasUser (User *user)
MembershipGetUser (User *user)
void KickUser (User *src, const MemberMap::iterator &victimiter, const std::string &reason)
void KickUser (User *src, User *user, const std::string &reason)
bool PartUser (User *user, std::string &reason)
MembershipForceJoin (User *user, const std::string *privs=NULL, bool bursting=false, bool created_by_local=false)
void Write (ClientProtocol::Event &protoev, char status=0, const CUList &except_list=CUList())
void Write (ClientProtocol::EventProvider &protoevprov, ClientProtocol::Message &msg, char status=0, const CUList &except_list=CUList())
const char * ChanModes (bool showsecret)
unsigned int GetPrefixValue (User *user)
bool IsBanned (User *user)
bool CheckBan (User *user, const std::string &banmask)
ModResult GetExtBanStatus (User *u, char type)
void WriteNotice (const std::string &text, char status=0)
void WriteRemoteNotice (const std::string &text, char status=0)
- Public Member Functions inherited from Extensible
const ExtensibleStoreGetExtList () const
CullResult cull () CXX11_OVERRIDE
void doUnhookExtensions (const std::vector< reference< ExtensionItem > > &toRemove)
void FreeAllExtItems ()
bool Deserialize (Data &data) CXX11_OVERRIDE
bool Serialize (Serializable::Data &data) CXX11_OVERRIDE

Static Public Member Functions

static ChannelJoinUser (LocalUser *user, std::string channame, bool override=false, const std::string &key="")

Public Attributes

std::string name
time_t age
MemberMap userlist
std::string topic
time_t topicset
std::string setby

Detailed Description

Holds an entry for a ban list, exemption list, or invite list. This class contains a single element in a channel list, such as a banlist. Holds all relevant information for a channel. This class represents a channel, and contains its name, modes, topic, topic set time, etc, and an instance of the BanList type.

Member Typedef Documentation

◆ MemberMap

A map of Memberships on a channel keyed by User pointers

Constructor & Destructor Documentation

◆ Channel()

Channel::Channel ( const std::string &  name,
time_t  ts 

Creates a channel record and initialises it with default values

nameThe name of the channel
tsThe creation time of the channel
CoreExceptionif this channel name is in use

Member Function Documentation

◆ AddUser()

Membership * Channel::AddUser ( User user)

Add a user pointer to the internal reference list

userThe user to add

The data inserted into the reference list is a table as it is an arbitrary pointer compared to other users by its memory address, as this is a very fast 32 or 64 bit integer comparison.

◆ ChanModes()

const char * Channel::ChanModes ( bool  showsecret)

Return the channel's modes with parameters.

showsecretIf this is set to true, the value of secret parameters are shown, otherwise they are replaced with '<name>'.
The channel mode string

◆ CheckBan()

bool Channel::CheckBan ( User user,
const std::string &  banmask 

Check a single ban for match

◆ CheckDestroy()

void Channel::CheckDestroy ( )

Checks whether the channel should be destroyed, and if yes, begins the teardown procedure.

If there are users on the channel or a module vetoes the deletion (OnPreChannelDelete hook) then nothing else happens. Otherwise, first the OnChannelDelete event is fired, then the channel is removed from the channel list. All pending invites are destroyed and finally the channel is added to the cull list.

◆ DelUser()

void Channel::DelUser ( User user)

Delete a user pointer to the internal reference list

userThe user to delete
number of users left on the channel after deletion of the user

◆ ForceJoin()

Membership * Channel::ForceJoin ( User user,
const std::string *  privs = NULL,
bool  bursting = false,
bool  created_by_local = false 

Join a user to an existing channel, without doing any permission checks

userThe user to join to the channel
privsPrivileges (prefix mode letters) to give to this user, may be NULL
burstingTrue if this join is the result of a netburst (passed to modules in the OnUserJoin hook)
created_by_localTrue if this channel was just created by a local user (passed to modules in the OnUserJoin hook)
A newly created Membership object, or NULL if the user was already inside the channel or if the user is a server user

◆ GetExtBanStatus()

ModResult Channel::GetExtBanStatus ( User u,
char  type 

Get the status of an "action" type extban

◆ GetModeParameter()

std::string Channel::GetModeParameter ( ModeHandler mode)

Returns the parameter for a custom mode on a channel.

modeThe mode character you wish to query

For example if "+L #foo" is set, and you pass this method 'L', it will return '#foo'. If the mode is not set on the channel, or the mode has no parameters associated with it, it will return an empty string.

The parameter for this mode is returned, or an empty string

◆ GetPrefixValue()

unsigned int Channel::GetPrefixValue ( User user)

Get the value of a users prefix on this channel.

userThe user to look up
The module or core-defined value of the users prefix. The values for op, halfop and voice status are constants in mode.h, and are OP_VALUE, HALFOP_VALUE, and VOICE_VALUE respectively. If the value you are given does not match one of these three, it is a module-defined mode, and it should be compared in proportion to these three constants. For example a value greater than OP_VALUE is a prefix of greater 'worth' than ops, and a value less than VOICE_VALUE is of lesser 'worth' than a voice.

◆ GetUserCounter()

size_t Channel::GetUserCounter ( ) const

Obtain the channel "user counter" This returns the number of users on this channel

The number of users on this channel

◆ GetUsers()

const MemberMap& Channel::GetUsers ( ) const

Obtain the internal reference list The internal reference list contains a list of User*. These are used for rapid comparison to determine channel membership for PRIVMSG, NOTICE, QUIT, PART etc. The resulting pointer to the vector should be considered readonly and only modified via AddUser and DelUser.

This function returns pointer to a map of User pointers (CUList*).

◆ HasUser()

bool Channel::HasUser ( User user)

Returns true if the user given is on the given channel.

userThe user to look for
True if the user is on this channel

◆ IsBanned()

bool Channel::IsBanned ( User user)

Check if a user is banned on this channel

userA user to check against the banlist
True if the user given is banned

◆ IsModeSet()

bool Channel::IsModeSet ( ModeHandler mode)

Returns true if a mode is set on a channel

modeThe mode character you wish to query
True if the custom mode is set, false if otherwise

◆ JoinUser()

Channel * Channel::JoinUser ( LocalUser user,
std::string  channame,
bool  override = false,
const std::string &  key = "" 

Join a local user to a channel, with or without permission checks. May be a channel that doesn't exist yet.

userThe user to join to the channel.
channameThe channel name to join to. Does not have to exist.
keyThe key of the channel, if given
overrideIf true, override all join restrictions such as +bkil
A pointer to the Channel the user was joined to. A new Channel may have been created if the channel did not exist before the user was joined to it. If the user could not be joined to a channel, the return value is NULL.

◆ KickUser() [1/2]

void Channel::KickUser ( User src,
const MemberMap::iterator &  victimiter,
const std::string &  reason 

Make src kick user from this channel with the given reason.

srcThe source of the kick
victimiterIterator to the user being kicked, must be valid
reasonThe reason for the kick

◆ KickUser() [2/2]

void Channel::KickUser ( User src,
User user,
const std::string &  reason 

Make src kick user from this channel with the given reason.

srcThe source of the kick
userThe user being kicked
reasonThe reason for the kick

◆ PartUser()

bool Channel::PartUser ( User user,
std::string &  reason 

Part a user from this channel with the given reason. If the reason field is NULL, no reason will be sent.

userThe user who is parting (must be on this channel)
reasonThe part reason
True if the user was on the channel and left, false if they weren't and nothing happened

◆ SetMode()

void Channel::SetMode ( ModeHandler mode,
bool  value 

Sets or unsets a custom mode in the channels info

modeThe mode character to set or unset
valueTrue if you want to set the mode or false if you want to remove it

◆ SetTopic()

void Channel::SetTopic ( User user,
const std::string &  topic,
time_t  topicts,
const std::string *  setter = NULL 

Sets the channel topic.

userThe user setting the topic.
topicThe topic to set it to.
topictsTimestamp of the new topic.
setterSetter string, may be used when the original setter is no longer online. If omitted or NULL, the setter string is obtained from the user.

◆ Write() [1/2]

void Channel::Write ( ClientProtocol::Event protoev,
char  status = 0,
const CUList &  except_list = CUList() 

Write to all users on a channel except some users

protoevEvent to send, may contain any number of messages.
statusThe status of the users to write to, e.g. '@' or ''. Use a value of 0 to write to everyone
except_listList of users not to send to

◆ Write() [2/2]

void Channel::Write ( ClientProtocol::EventProvider protoevprov,
ClientProtocol::Message msg,
char  status = 0,
const CUList &  except_list = CUList() 

Write to all users on a channel except some users.

protoevprovProtocol event provider for the message.
msgMessage to send.
statusThe status of the users to write to, e.g. '@' or ''. Use a value of 0 to write to everyone
except_listList of users not to send to

◆ WriteNotice()

void Channel::WriteNotice ( const std::string &  text,
char  status = 0 

Write a NOTICE to all local users on the channel

textText to send
statusThe minimum status rank to send this message to.

Member Data Documentation

◆ age

time_t Channel::age

Time that the object was instantiated (used for TS calculation etc)

◆ name

std::string Channel::name

The channel's name.

◆ setby

std::string Channel::setby

The last user to set the topic. If this member is an empty string, no topic was ever set.

◆ topic

std::string Channel::topic

Channel topic. If this is an empty string, no channel topic is set.

◆ topicset

time_t Channel::topicset

Time topic was set. If no topic was ever set, this will be equal to Channel::created

◆ userlist

MemberMap Channel::userlist

User list.

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