InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Channel Class Reference

#include <channels.h>

Inheritance diagram for Channel:
Extensible InviteBase classbase

Public Member Functions

 Channel (const std::string &name, time_t ts)
 
void SetMode (ModeHandler *mode, bool value)
 
void SetMode (char mode, bool mode_on)
 
void SetModeParam (ModeHandler *mode, const std::string &parameter)
 
void SetModeParam (char mode, const std::string &parameter)
 
bool IsModeSet (char mode)
 
bool IsModeSet (ModeHandler *mode)
 
std::string GetModeParameter (char mode)
 
std::string GetModeParameter (ModeHandler *mode)
 
int SetTopic (User *u, std::string &t, bool forceset=false)
 
long GetUserCounter ()
 
MembershipAddUser (User *user)
 
void DelUser (User *user)
 
const UserMembList * GetUsers ()
 
bool HasUser (User *user)
 
MembershipGetUser (User *user)
 
void KickUser (User *src, User *user, const char *reason)
 
void PartUser (User *user, std::string &reason)
 
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)
 
long GetMaxBans ()
 
char * ChanModes (bool showkey)
 
void UserList (User *user)
 
int CountInvisible ()
 
const char * GetPrefixChar (User *user)
 
const char * GetAllPrefixChars (User *user)
 
unsigned int GetPrefixValue (User *user)
 
void RemoveAllPrefixes (User *user)
 
bool SetPrefix (User *user, char prefix, bool adding)
 
bool IsBanned (User *user)
 
bool CheckBan (User *user, const std::string &banmask)
 
ModResult GetExtBanStatus (User *u, char type)
 
void ResetMaxBans ()
 
- Public Member Functions inherited from Extensible
const ExtensibleStore & GetExtList () const
 
virtual CullResult cull ()
 
void doUnhookExtensions (const std::vector< reference< ExtensionItem > > &toRemove)
 
- Public Member Functions inherited from InviteBase
void ClearInvites ()
 

Static Public Member Functions

static ChannelJoinUser (User *user, const char *cn, bool override, const char *key, bool bursting, time_t TS=0)
 

Public Attributes

std::string name
 
time_t age
 
UserMembList userlist
 
std::string topic
 
time_t topicset
 
std::string setby
 
BanList bans
 

Additional Inherited Members

- Public Types inherited from Extensible
typedef std::map< reference
< ExtensionItem >, void * > 
ExtensibleStore
 
- Protected Attributes inherited from InviteBase
InviteList invites
 

Detailed Description

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.

Constructor & Destructor Documentation

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

Creates a channel record and initialises it with default values

Exceptions
Nothingat present.

Member Function Documentation

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.

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
bool Channel::CheckBan ( User user,
const std::string &  banmask 
)

Check a single ban for match

int Channel::CountInvisible ( )

Get the number of invisible users on this channel

Returns
Number of invisible users
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
const char * Channel::GetAllPrefixChars ( User user)

Return all of a users mode prefixes into a char* string.

Parameters
userThe user to look up
Returns
A list of all prefix characters. The prefixes will always be in rank order, greatest first, as certain IRC clients require this when multiple prefixes are used names lists.
ModResult Channel::GetExtBanStatus ( User u,
char  type 
)

Get the status of an "action" type extban

long Channel::GetMaxBans ( )

Returns the maximum number of bans allowed to be set on this channel

Returns
The maximum number of bans allowed
std::string Channel::GetModeParameter ( char  mode)

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
const char * Channel::GetPrefixChar ( User user)

Get a users prefix on this channel in a string.

Parameters
userThe user to look up
Returns
A character array containing the prefix string. Unlike GetStatus and GetStatusFlags which will only return the core specified modes @, % and + (op, halfop and voice), GetPrefixChar will also return module-defined prefixes. If the user has to prefix, an empty but non-null string is returned. If the user has multiple prefixes, the highest is returned. If you do not recognise the prefix character you can get, you can deal with it in a 'proprtional' manner compared to known prefixes, using 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.
long Channel::GetUserCounter ( )

Obtain the channel "user counter" This returns the channel reference counter, which is initialized to 0 when the channel is created and incremented/decremented upon joins, parts quits and kicks.

Returns
The number of users on this channel
const UserMembList * Channel::GetUsers ( )

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*).
bool Channel::HasUser ( User user)

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
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
bool Channel::IsModeSet ( char  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
void Channel::KickUser ( User src,
User user,
const char *  reason 
)

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

Parameters
srcThe source of the kick
userThe user being kicked (must be on this channel)
reasonThe reason for the kick
void 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
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

void Channel::RemoveAllPrefixes ( User user)

This method removes all prefix characters from a user. It will not inform the user or the channel of the removal of prefixes, and should be used when the user parts or quits.

Parameters
userThe user to remove all prefixes from
void Channel::ResetMaxBans ( )

Clears the cached max bans value

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
void Channel::SetModeParam ( ModeHandler mode,
const std::string &  parameter 
)

Sets or unsets a custom mode in the channels info

Parameters
modeThe mode character to set or unset
parameterThe parameter string to associate with this mode character. If it is empty, the mode is unset; if it is nonempty, the mode is set.
bool Channel::SetPrefix ( User user,
char  prefix,
bool  adding 
)

Add a prefix character to a user. Only the core should call this method, usually from within the mode parser or when the first user joins the channel (to grant ops to them)

Parameters
userThe user to associate the privilage with
prefixThe prefix character to associate
addingTrue if adding the prefix, false when removing
Returns
True if a change was made
int Channel::SetTopic ( User u,
std::string &  t,
bool  forceset = false 
)

Sets the channel topic.

Parameters
uThe user setting the topic
tThe topic to set it to. Non-const, as it may be modified by a hook.
forcesetIf set to true then all access checks will be bypassed.
void Channel::UserList ( User user)

Spool the NAMES list for this channel to the given user

Parameters
userThe user to spool the NAMES list to
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 nick!user@host 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
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 nick!user@host 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
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 nick!user@host 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
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 nick!user@host 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
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
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
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
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

Member Data Documentation

time_t Channel::age

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

BanList Channel::bans

The list of all bans set on the channel.

std::string Channel::name

The channel's name.

std::string Channel::setby

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

std::string Channel::topic

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

time_t Channel::topicset

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

UserMembList Channel::userlist

User list.


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