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

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)
 
long 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 WriteChannel (User *user, const char *text,...) CUSTOM_PRINTF(3
 
void void WriteChannel (User *user, const std::string &text)
 
void WriteChannelWithServ (const std::string &ServName, const char *text,...) CUSTOM_PRINTF(3
 
void void WriteChannelWithServ (const std::string &ServName, const std::string &text)
 
void WriteAllExceptSender (User *user, bool serversource, char status, const char *text,...) CUSTOM_PRINTF(5
 
void void WriteAllExcept (User *user, bool serversource, char status, CUList &except_list, const char *text,...) CUSTOM_PRINTF(6
 
void void void WriteAllExceptSender (User *user, bool serversource, char status, const std::string &text)
 
void WriteAllExcept (User *user, bool serversource, char status, CUList &except_list, const std::string &text)
 
void RawWriteAllExcept (User *user, bool serversource, char status, CUList &except_list, const std::string &text)
 
const char * ChanModes (bool showkey)
 
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)
 
- Public Member Functions inherited from Extensible
const ExtensibleStoreGetExtList () const
 
virtual CullResult cull () CXX11_OVERRIDE
 
void doUnhookExtensions (const std::vector< reference< ExtensionItem > > &toRemove)
 
void FreeAllExtItems ()
 

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 relevent 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

Parameters
nameThe name of the channel
tsThe creation time of the channel
Exceptions
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

Parameters
userThe user to add

The data inserted into the reference list is a table as it is an arbitary 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  showkey)

Return the channel's modes with parameters.

Parameters
showkeyIf this is set to true, the actual key is shown, otherwise it is replaced with '<KEY>'
Returns
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

Parameters
userThe user to delete
Returns
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

Parameters
userThe user to join to the channel
privsPriviliges (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)
Returns
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)
inline

Returns the parameter for a custom mode on a channel.

Parameters
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.

Returns
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.

Parameters
userThe user to look up
Returns
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()

long Channel::GetUserCounter ( ) const
inline

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

Returns
The number of users on this channel

◆ GetUsers()

const MemberMap& Channel::GetUsers ( ) const
inline

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.

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

◆ HasUser()

bool Channel::HasUser ( User user)
inline

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

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

◆ IsBanned()

bool Channel::IsBanned ( User user)

Check if a user is banned on this channel

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

◆ IsModeSet()

bool Channel::IsModeSet ( ModeHandler mode)
inline

Returns true if a mode is set on a channel

Parameters
modeThe mode character you wish to query
Returns
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 = "" 
)
static

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

Parameters
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
Returns
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.

Parameters
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 
)
inline

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

Parameters
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.

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

◆ RawWriteAllExcept()

void Channel::RawWriteAllExcept ( User user,
bool  serversource,
char  status,
CUList &  except_list,
const std::string &  text 
)

Write a line of text that already includes the source

◆ SetMode()

void Channel::SetMode ( ModeHandler mode,
bool  value 
)

Sets or unsets a custom mode in the channels info

Parameters
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.

Parameters
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.

◆ WriteAllExcept() [1/2]

void Channel::WriteAllExcept ( User user,
bool  serversource,
char  status,
CUList &  except_list,
const char *  text,
  ... 
)

Write to all users on a channel except a list of users, using va_args for text

Parameters
userUser whos details to prefix the line with, and to omit from receipt of the message
serversourceIf this parameter is true, use the local server name as the source of the text, otherwise, use the [email protected] of the user.
statusThe status of the users to write to, e.g. '@' or ''. Use a value of 0 to write to everyone
except_listA list of users NOT to send the text to
textA printf-style format string which builds the output line without prefix
...Zero or more POD type

◆ WriteAllExcept() [2/2]

void Channel::WriteAllExcept ( User user,
bool  serversource,
char  status,
CUList &  except_list,
const std::string &  text 
)

Write to all users on a channel except a list of users, using std::string for text

Parameters
userUser whos details to prefix the line with, and to omit from receipt of the message
serversourceIf this parameter is true, use the local server name as the source of the text, otherwise, use the [email protected] of the user.
statusThe status of the users to write to, e.g. '@' or ''. Use a value of 0 to write to everyone
except_listA list of users NOT to send the text to
textA std::string containing the output line without prefix

◆ WriteAllExceptSender() [1/2]

void Channel::WriteAllExceptSender ( User user,
bool  serversource,
char  status,
const char *  text,
  ... 
)

Write to all users on a channel except a specific user, using va_args for text. Internally, this calls WriteAllExcept().

Parameters
userUser whos details to prefix the line with, and to omit from receipt of the message
serversourceIf this parameter is true, use the local server name as the source of the text, otherwise, use the [email protected] of the user.
statusThe status of the users to write to, e.g. '@' or ''. Use a value of 0 to write to everyone
textA printf-style format string which builds the output line without prefix
...Zero or more POD type

◆ WriteAllExceptSender() [2/2]

void Channel::WriteAllExceptSender ( User user,
bool  serversource,
char  status,
const std::string &  text 
)

Write to all users on a channel except a specific user, using std::string for text. Internally, this calls WriteAllExcept().

Parameters
userUser whos details to prefix the line with, and to omit from receipt of the message
serversourceIf this parameter is true, use the local server name as the source of the text, otherwise, use the [email protected] of the user.
statusThe status of the users to write to, e.g. '@' or ''. Use a value of 0 to write to everyone
textA std::string containing the output line without prefix

◆ WriteChannel() [1/2]

void Channel::WriteChannel ( User user,
const char *  text,
  ... 
)

Write to a channel, from a user, using va_args for text

Parameters
userUser whos details to prefix the line with
textA printf-style format string which builds the output line without prefix
...Zero or more POD types

◆ WriteChannel() [2/2]

void Channel::WriteChannel ( User user,
const std::string &  text 
)

Write to a channel, from a user, using std::string for text

Parameters
userUser whos details to prefix the line with
textA std::string containing the output line without prefix

◆ WriteChannelWithServ() [1/2]

void Channel::WriteChannelWithServ ( const std::string &  ServName,
const char *  text,
  ... 
)

Write to a channel, from a server, using va_args for text

Parameters
ServNameServer name to prefix the line with
textA printf-style format string which builds the output line without prefix
...Zero or more POD type

◆ WriteChannelWithServ() [2/2]

void Channel::WriteChannelWithServ ( const std::string &  ServName,
const std::string &  text 
)

Write to a channel, from a server, using std::string for text

Parameters
ServNameServer name to prefix the line with
textA std::string containing the output line without prefix

◆ WriteNotice()

void Channel::WriteNotice ( const std::string &  text)

Write a NOTICE to all local users on the channel

Parameters
textText to send

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: