Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Private Attributes

Channel Class Reference

#include <channels.h>

Inherits Base, and Extensible.

Collaboration diagram for Channel:
Collaboration graph
[legend]

Public Types

typedef std::multimap
< Anope::string, Anope::string
ModeList
typedef std::list
< ChanUserContainer * > 
ChanUserList

Public Member Functions

 Channel (const Anope::string &nname, time_t ts=Anope::CurTime)
 ~Channel ()
void Reset ()
void Sync ()
void CheckModes ()
ChanUserContainerJoinUser (User *u)
void DeleteUser (User *u)
ChanUserContainerFindUser (const User *u) const
bool HasUserStatus (const User *u, ChannelModeStatus *cms) const
bool HasUserStatus (const User *u, const Anope::string &name) const
size_t HasMode (const Anope::string &name, const Anope::string &param="")
void SetModeInternal (MessageSource &source, ChannelMode *cm, const Anope::string &param="", bool enforce_mlock=true)
void RemoveModeInternal (MessageSource &source, ChannelMode *cm, const Anope::string &param="", bool enforce_mlock=true)
void SetMode (BotInfo *bi, ChannelMode *cm, const Anope::string &param="", bool enforce_mlock=true)
void SetMode (BotInfo *bi, const Anope::string &name, const Anope::string &param="", bool enforce_mlock=true)
void RemoveMode (BotInfo *bi, ChannelMode *cm, const Anope::string &param="", bool enforce_mlock=true)
void RemoveMode (BotInfo *bi, const Anope::string &name, const Anope::string &param="", bool enforce_mlock=true)
bool GetParam (const Anope::string &name, Anope::string &target) const
void SetModes (BotInfo *bi, bool enforce_mlock, const char *cmodes,...)
void SetModesInternal (MessageSource &source, const Anope::string &mode, time_t ts=0, bool enforce_mlock=true)
bool MatchesList (User *u, const Anope::string &list)
void KickInternal (MessageSource &source, const Anope::string &nick, const Anope::string &reason)
bool Kick (BotInfo *bi, User *u, const char *reason=NULL,...)
const ModeListGetModes () const
std::pair< ModeList::iterator,
ModeList::iterator > 
GetModeList (const Anope::string &name)
Anope::string GetModes (bool complete, bool plus)
void ChangeTopicInternal (const Anope::string &user, const Anope::string &newtopic, time_t ts=Anope::CurTime)
void ChangeTopic (const Anope::string &user, const Anope::string &newtopic, time_t ts=Anope::CurTime)
void Hold ()
void SetCorrectModes (User *u, bool give_mode, bool check_noop)
bool Unban (const User *u, bool full=false)

Static Public Member Functions

static ChannelFind (const Anope::string &name)

Data Fields

Anope::string name
Serialize::Reference< ChannelInfoci
time_t creation_time
std::set< ChannelFlagflags
ChanUserList users
Anope::string topic
Anope::string topic_setter
time_t topic_ts
time_t topic_time
time_t server_modetime
time_t chanserv_modetime
int16_t server_modecount
int16_t chanserv_modecount
int16_t bouncy_modes

Private Attributes

ModeList modes

Detailed Description

Definition at line 43 of file channels.h.


Member Typedef Documentation

Definition at line 62 of file channels.h.

Definition at line 46 of file channels.h.


Constructor & Destructor Documentation

Channel::Channel ( const Anope::string nname,
time_t  ts = Anope::CurTime 
)

Constructor

Parameters:
name The channel name
ts The time the channel was created

Definition at line 29 of file channels.cpp.

References bouncy_modes, chanserv_modecount, chanserv_modetime, ci, creation_time, Anope::string::empty(), Find(), FOREACH_MOD, I_OnChannelCreate, LOG_DEBUG, name, server_modecount, server_modetime, topic_time, and topic_ts.

Channel::~Channel (  ) 

Destructor

Definition at line 54 of file channels.cpp.

References ci, FOREACH_MOD, I_OnChannelDelete, name, and ModeManager::StackerDel().


Member Function Documentation

void Channel::ChangeTopic ( const Anope::string user,
const Anope::string newtopic,
time_t  ts = Anope::CurTime 
)

Update the topic of the channel, and reset it if topiclock etc says to

Parameters:
user The user setting the topic
newtopic The new topic
ts The time when the new topic is being set

Definition at line 878 of file channels.cpp.

References ci, Anope::CurTime, Find(), FOREACH_MOD, I_OnTopicUpdated, IRCD, User::nick, IRCDProto::SendTopic(), topic, topic_setter, topic_time, and topic_ts.

Referenced by ChannelInfo::CheckTopic(), ChannelInfo::RestoreTopic(), and CommandCSTopic::Set().

void Channel::ChangeTopicInternal ( const Anope::string user,
const Anope::string newtopic,
time_t  ts = Anope::CurTime 
)

Update the topic of the channel internally, and reset it if topiclock etc says to

Parameters:
user The user setting the new topic
newtopic The new topic
ts The time the new topic is being set

Definition at line 861 of file channels.cpp.

References ci, Anope::CurTime, Find(), FOREACH_MOD, I_OnTopicUpdated, LOG_DEBUG, name, User::nick, topic, topic_setter, topic_time, and topic_ts.

Referenced by Message::Topic::Run(), IRCDMessageChaninfo::Run(), IRCDMessageFTopic::Run(), and IRCDMessageTopic::Run().

void Channel::CheckModes (  ) 
void Channel::DeleteUser ( User u  ) 

Remove a user internally from the channel

Parameters:
u The user

Definition at line 195 of file channels.cpp.

References User::chans, ci, FOREACH_MOD, Extensible::HasExt(), I_OnLeaveChannel, LOG_DEBUG, name, User::nick, and users.

Referenced by KickInternal(), BotInfo::Part(), and Message::Join::Run().

Channel * Channel::Find ( const Anope::string name  )  [static]
ChanUserContainer * Channel::FindUser ( const User u  )  const
std::pair< Channel::ModeList::iterator, Channel::ModeList::iterator > Channel::GetModeList ( const Anope::string name  ) 

Get a list of modes on a channel

Parameters:
name A mode name to get the list of
Returns:
a pair of iterators for the beginning and end of the list

Definition at line 311 of file channels.cpp.

References modes.

Referenced by CommandCSAKick::DoAdd(), MyXMLRPCEvent::DoChannel(), CommandCSMode::DoSet(), HasMode(), BotInfo::Join(), MatchesList(), RemoveModeInternal(), and Unban().

const Channel::ModeList & Channel::GetModes (  )  const

Get all modes set on this channel, excluding status modes.

Returns:
a map of modes and their optional parameters.

Definition at line 306 of file channels.cpp.

References modes.

Referenced by CommandOSMode::Execute(), and CommandOSChanList::Execute().

Anope::string Channel::GetModes ( bool  complete,
bool  plus 
)

Get a string of the modes set on this channel

Parameters:
complete Include mode parameters
plus If set to false (with complete), mode parameters will not be given for modes requring no parameters to be unset
Returns:
A mode string

Definition at line 280 of file channels.cpp.

References anope_dynamic_static_cast(), ModeManager::FindChannelModeByName(), Mode::mchar, ChannelModeParam::minus_no_arg, MODE_LIST, MODE_PARAM, modes, and Mode::type.

bool Channel::GetParam ( const Anope::string name,
Anope::string target 
) const

Get a modes parameter for the channel

Parameters:
name The mode
target a string to put the param into
Returns:
true if the parameter was fetched, false if on error (mode not set) etc.

Definition at line 583 of file channels.cpp.

References Anope::string::clear(), and modes.

Referenced by CheckModes(), CommandCSEnforce::DoLimit(), CommandCSGetKey::Execute(), BotInfo::Join(), NSAJoin::OnNickIdentify(), RemoveMode(), and SetMode().

size_t Channel::HasMode ( const Anope::string name,
const Anope::string param = "" 
)
bool Channel::HasUserStatus ( const User u,
const Anope::string name 
) const

Check if a user has a status on a channel Use the overloaded function for ChannelModeStatus* to check for no status

Parameters:
u The user
name The mode name, eg CMODE_OP, CMODE_VOICE
Returns:
true or false

Definition at line 264 of file channels.cpp.

References ModeManager::FindChannelModeByName(), and HasUserStatus().

bool Channel::HasUserStatus ( const User u,
ChannelModeStatus cms 
) const

Check if a user has a status on a channel

Parameters:
u The user
cms The status mode, or NULL to represent no status
Returns:
true or false

Definition at line 249 of file channels.cpp.

References User::FindChannel(), ChannelStatus::modes, Mode::name, and ChanUserContainer::status.

Referenced by CommandCSRegister::Execute(), HasUserStatus(), RemoveMode(), SetCorrectModes(), and SetMode().

void Channel::Hold (  ) 

Hold the channel open using ChanServ

A timer used to keep the BotServ bot/ChanServ in the channel after kicking the last user in a channel

Constructor

Parameters:
chan The channel

Called when the delay is up

Parameters:
The current time

Definition at line 897 of file channels.cpp.

References anope_override, ServerConfig::BSMinUsers, ChanServ, Config, ServerConfig::CSInhabit, BotInfo::Join(), and BotInfo::Part().

Referenced by ChannelInfo::CheckKick(), and Sync().

ChanUserContainer * Channel::JoinUser ( User u  ) 

Join a user internally to the channel

Parameters:
u The user
Returns:
The UserContainer for the user

Definition at line 176 of file channels.cpp.

References User::chans, ci, creation_time, IRCD, LOG_DEBUG, name, Reset(), IRCDProto::SendChannel(), and users.

Referenced by BotInfo::Join(), and Message::Join::SJoin().

bool Channel::Kick ( BotInfo bi,
User u,
const char *  reason = NULL,
  ... 
)

Kick a user from the channel

Parameters:
bi The sender, can be NULL for the service bot for this channel
u The user being kicked
reason The reason for the kick
Returns:
true if the kick was scucessful, false if a module blocked the kick

Definition at line 832 of file channels.cpp.

References BUFSIZE, ci, EVENT_STOP, FOREACH_RESULT, I_OnBotKick, IRCD, User::IsProtected(), Server::IsULined(), KickInternal(), User::nick, IRCDProto::SendKick(), and User::server.

Referenced by BSKick::bot_kick(), ChannelInfo::CheckKick(), CommandCSEnforce::DoBans(), CommandCSEnforce::DoLimit(), CommandCSEnforce::DoRegOnly(), CommandCSEnforce::DoRestricted(), CommandCSEnforce::DoSSLOnly(), CommandOSKick::Execute(), CommandCSSuspend::Execute(), CommandCSKick::Execute(), CommandCSBan::Execute(), and CommandOSSQLine::OnAdd().

void Channel::KickInternal ( MessageSource source,
const Anope::string nick,
const Anope::string reason 
)

Kick a user from a channel internally

Parameters:
source The sender of the kick
nick The nick being kicked
reason The reason for the kick

Definition at line 793 of file channels.cpp.

References ModeManager::DefaultBotModes, DeleteUser(), Extensible::Extend(), Find(), User::FindChannel(), FOREACH_MOD, MessageSource::GetSource(), MessageSource::GetUser(), I_OnUserKicked, BotInfo::Join(), Me, name, User::nick, User::server, and Extensible::Shrink().

Referenced by Kick(), and Message::Kick::Run().

bool Channel::MatchesList ( User u,
const Anope::string list 
)

Does the given user match the given list? (CMODE_BAN, CMODE_EXCEPT, etc, a list mode)

Parameters:
u The user
list The mode of the list to check (eg CMODE_BAN)
Returns:
true if the user matches the list

Definition at line 776 of file channels.cpp.

References GetModeList(), HasMode(), and Entry::Matches().

Referenced by CommandCSEnforce::DoBans(), CommandCSBan::Execute(), and NSAJoin::OnNickIdentify().

void Channel::RemoveMode ( BotInfo bi,
const Anope::string name,
const Anope::string param = "",
bool  enforce_mlock = true 
)

Remove a mode from a channel

Parameters:
bi The client setting the modes
name The mode name
param Optional param arg for the mode
enforce_mlock true if mlocks should be enforced, false to override mlock

Definition at line 578 of file channels.cpp.

References ModeManager::FindChannelModeByName(), and RemoveMode().

void Channel::RemoveMode ( BotInfo bi,
ChannelMode cm,
const Anope::string param = "",
bool  enforce_mlock = true 
)
void Channel::RemoveModeInternal ( MessageSource source,
ChannelMode cm,
const Anope::string param = "",
bool  enforce_mlock = true 
)

Remove a mode internally on a channel, this is not sent out to the IRCd

Parameters:
setter The Setter
cm The mode
param The param
enforce_mlock true if mlocks should be enforced, false to override mlock

Definition at line 391 of file channels.cpp.

References anope_dynamic_static_cast(), CheckModes(), ci, ModeManager::DefaultBotModes, Anope::string::empty(), EVENT_STOP, Find(), User::FindChannel(), FOREACH_RESULT, GetModeList(), User::GetUID(), Extensible::HasExt(), I_OnChannelModeUnset, LOG_DEBUG, Anope::Match(), Mode::mchar, MODE_LIST, MODE_STATUS, modes, ChannelStatus::modes, Mode::name, name, User::nick, ChannelModeList::OnDel(), SetCorrectModes(), SetMode(), Extensible::Shrink(), ChanUserContainer::status, Mode::type, and users.

Referenced by RemoveMode(), and SetModesInternal().

void Channel::Reset (  ) 

Call if we need to unset all modes and clear all user status (internally). Only useful if we get a SJOIN with a TS older than what we have here

Definition at line 68 of file channels.cpp.

References ModeManager::ChannelModes, CheckModes(), ci, BotInfo::Find(), User::GetUID(), Server::IsSynced(), Me, ChannelStatus::modes, modes, Mode::name, User::nick, SetCorrectModes(), SetMode(), ChanUserContainer::status, ChanUserContainer::user, and users.

Referenced by JoinUser(), SetModesInternal(), and Message::Join::SJoin().

void Channel::SetCorrectModes ( User u,
bool  give_mode,
bool  check_noop 
)

Set the correct modes, or remove the ones granted without permission, for the specified user.

Parameters:
user The user to give/remove modes to/from
give_modes if true modes may be given to the user
check_noop if true, CI_NOAUTOOP is checked before giving modes

Definition at line 945 of file channels.cpp.

References User::Account(), ci, ModeManager::FindChannelModeByName(), User::GetDisplayedMask(), User::GetUID(), Extensible::HasExt(), HasMode(), HasUserStatus(), Server::IsSynced(), Server::IsULined(), LOG_DEBUG, Anope::Match(), MODE_STATUS, ModeLock::name, name, User::nick, ModeLock::param, RemoveMode(), User::server, ModeLock::set, SetMode(), and Mode::type.

Referenced by CommandCSEnforce::DoSecureOps(), CommandCSUp::Execute(), CommandCSSync::Execute(), NickServCore::OnNickIdentify(), NickServCore::OnNickUpdate(), RemoveModeInternal(), Reset(), SetModeInternal(), and Message::Join::SJoin().

void Channel::SetMode ( BotInfo bi,
ChannelMode cm,
const Anope::string param = "",
bool  enforce_mlock = true 
)
void Channel::SetMode ( BotInfo bi,
const Anope::string name,
const Anope::string param = "",
bool  enforce_mlock = true 
)

Set a mode on a channel

Parameters:
bi The client setting the modes
name The mode name
param Optional param arg for the mode
enforce_mlock true if mlocks should be enforced, false to override mlock

Definition at line 527 of file channels.cpp.

References ModeManager::FindChannelModeByName(), and SetMode().

void Channel::SetModeInternal ( MessageSource source,
ChannelMode cm,
const Anope::string param = "",
bool  enforce_mlock = true 
)

Set a mode internally on a channel, this is not sent out to the IRCd

Parameters:
setter The setter
cm The mode
param The param
enforce_mlock true if mlocks should be enforced, false to override mlock

Definition at line 319 of file channels.cpp.

References anope_dynamic_static_cast(), CheckModes(), ci, Anope::string::empty(), EVENT_STOP, Extensible::Extend(), Find(), User::FindChannel(), FOREACH_RESULT, I_OnChannelModeSet, LOG_DEBUG, Mode::mchar, MODE_LIST, MODE_STATUS, modes, ChannelStatus::modes, Mode::name, name, User::nick, ChannelModeList::OnAdd(), SetCorrectModes(), ChanUserContainer::status, and Mode::type.

Referenced by IRCDMessageSJoin::Run(), IRCDMessageBMask::Run(), Server::Server(), SetMode(), and SetModesInternal().

void Channel::SetModes ( BotInfo bi,
bool  enforce_mlock,
const char *  cmodes,
  ... 
)

Set a string of modes on the channel

Parameters:
bi The client setting the modes
enforce_mlock Should mlock be enforced on this mode change
cmodes The modes to set

Definition at line 598 of file channels.cpp.

References BUFSIZE, Find(), ModeManager::FindChannelModeByChar(), sepstream::GetToken(), User::GetUID(), Anope::string::length(), MODE_REGULAR, MODE_STATUS, RemoveMode(), SetMode(), and Mode::type.

void Channel::SetModesInternal ( MessageSource source,
const Anope::string mode,
time_t  ts = 0,
bool  enforce_mlock = true 
)
void Channel::Sync (  ) 

Restore the channel topic, set mlock (key), set stickied bans, etc

Definition at line 100 of file channels.cpp.

References CheckModes(), ci, HasMode(), Hold(), Server::IsSynced(), Me, and users.

Referenced by Message::Join::SJoin(), and Server::Sync().

bool Channel::Unban ( const User u,
bool  full = false 
)

Unbans a user from this channel.

Parameters:
u The user to unban
full Whether or not to match using the user's real host and IP
Returns:
whether or not a ban was removed

Definition at line 1019 of file channels.cpp.

References Entry::GetMask(), GetModeList(), HasMode(), Entry::Matches(), and RemoveMode().

Referenced by CommandCSUnban::Execute().


Field Documentation

Definition at line 81 of file channels.h.

Referenced by Channel(), CheckModes(), CommandOSMode::Execute(), and CommandOSKick::Execute().

Definition at line 80 of file channels.h.

Referenced by Channel(), CheckModes(), RemoveMode(), and SetMode().

Definition at line 78 of file channels.h.

Referenced by Channel(), RemoveMode(), and SetMode().

Definition at line 59 of file channels.h.

A map of channel modes with their parameters set on this channel

Definition at line 50 of file channels.h.

Referenced by GetModeList(), GetModes(), GetParam(), HasMode(), RemoveModeInternal(), Reset(), and SetModeInternal().

Definition at line 79 of file channels.h.

Referenced by Channel(), CheckModes(), and SetModesInternal().

Definition at line 77 of file channels.h.

Referenced by Channel(), and SetModesInternal().


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