libircpp
Version: 0.0.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
irc::channel Class Reference

#include <irc/channel.hpp>

Detailed Description

IRC channel class.

Public Member Functions

 channel (session &connection__, std::string name_)
 Constructor. More...
 
sessionget_session ()
 Returns the associated session object. More...
 
const sessionget_session () const
 Returns the associated session object (const). More...
 
const std::string & get_name () const
 Returns the channel name. More...
 
const std::string & get_topic () const
 Returns the channel topic. More...
 
bool is_operator (const user &u) const
 Returns if the specified user is a channel operator. More...
 
void async_send_message (const std::string &msg)
 Sends a message in to the channel. More...
 
void async_part ()
 Leaves the channel. More...
 
user_iterator begin_users ()
 Returns an iterator to the beginning of the user list. More...
 
user_iterator end_users ()
 Returns an iterator to the end of the user list. More...
 
const_user_iterator begin_users () const
 Returns a const iterator to the beginning of the user list. More...
 
const_user_iterator end_users () const
 Returns a const iterator to the end of the user list. More...
 
const mode_block & get_modes () const
 Returns the mode block for this channel. More...
 
mode_block & get_modes ()
 Returns the mode block for this channel (const version). More...
 
void add_modes (const prefix &pfx, mode_list modes)
 Adds the specified modes to the channel. More...
 
void remove_modes (const prefix &pfx, const mode_list &modes)
 Removes the specified modes from the channel. More...
 
void message (const shared_user &user, const std::string message)
 Sends a message to the channel. More...
 
void user_part (const shared_user &user, const optional_string &msg)
 An user has left the channel. More...
 
void user_join (const shared_user &user)
 An user has joined the channel. More...
 
bool add_user (const shared_user &user)
 Adds an user to the channel user list. More...
 
void user_quit (const shared_user &user, const std::string &msg)
 An user has quitted IRC. More...
 
void set_topic (std::string str)
 Sets the channel topic. More...
 
void set_operator (const user &u)
 Sets a specified user as channel operator. More...
 
void list_users ()
 Sends a command::list request to the IRC server. More...
 
void part ()
 Sends a command::part request to the IRC server to leave this channel. More...
 
template<typename F >
bsig::connection connect_on_message (F &&f)
 Connect to the on_message signal. More...
 
template<typename F >
bsig::connection connect_on_topic_change (F &&f)
 Connect to the on_topic signal. More...
 
template<typename F >
bsig::connection connect_on_user_join (F &&f)
 Connect to the on_user_join signal. More...
 
template<typename F >
bsig::connection connect_on_user_part (F &&f)
 Connect to the on_user_join signal. More...
 
template<typename F >
bsig::connection connect_on_channel_part (F &&f)
 Connect to the on_channel_part signal. More...
 
template<typename F >
bsig::connection connect_on_list_users (F &&f)
 Connect to the on_list_users signal. More...
 
template<typename F >
bsig::connection connect_on_set_mode (F &&f)
 Connect to the on_set_mode signal. More...
 

Constructor & Destructor Documentation

irc::channel::channel ( session connection__,
std::string  name_ 
)

Constructor.

Parameters
connection__The associated IRC session.
name_The channel name.

Member Function Documentation

void irc::channel::add_modes ( const prefix pfx,
mode_list  modes 
)

Adds the specified modes to the channel.

Parameters
pfxThe user prefix who sets the new modes.
modesThe new modes.
bool irc::channel::add_user ( const shared_user &  user)

Adds an user to the channel user list.

Parameters
userThe new user entry.
Returns
true on success, false otherwise.
void irc::channel::async_part ( )

Leaves the channel.

void irc::channel::async_send_message ( const std::string &  msg)

Sends a message in to the channel.

Parameters
msgThe message to send.
user_iterator irc::channel::begin_users ( )

Returns an iterator to the beginning of the user list.

Returns
An iterator to the beginning of the user list.
const_user_iterator irc::channel::begin_users ( ) const

Returns a const iterator to the beginning of the user list.

Returns
A const iterator to the beginning of the user list.
See Also
begin_users()
template<typename F >
bsig::connection irc::channel::connect_on_channel_part ( F &&  f)

Connect to the on_channel_part signal.

This signal is triggered when we leaves the channel.

Parameters
fA callback function with the following signature:
void f(channel& chan)
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::channel::connect_on_list_users ( F &&  f)

Connect to the on_list_users signal.

This signal is triggered when we required a command::list.

Parameters
fA callback function with the following signature:
void f()
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::channel::connect_on_message ( F &&  f)

Connect to the on_message signal.

This signal is triggered when a message was sent to the channel.

Parameters
fA callback function with the following signature:
void f(channel& chan, user& usr, const std::string& msg)
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::channel::connect_on_set_mode ( F &&  f)

Connect to the on_set_mode signal.

This signal is triggered when channel modes changed.

Parameters
fA callback function with the following signature:
void f( const prefix& pfx, const std::vector<std::pair<char, optional_string>>& modes)
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::channel::connect_on_topic_change ( F &&  f)

Connect to the on_topic signal.

This signal is triggered when the topic has changed.

Parameters
fA callback function with the following signature:
void f(channel& chan, const std::string& new_topic)
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::channel::connect_on_user_join ( F &&  f)

Connect to the on_user_join signal.

This signal is triggered when an user joins the channel.

Parameters
fA callback function with the following signature:
void f(channel& chan, user& usr)
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::channel::connect_on_user_part ( F &&  f)

Connect to the on_user_join signal.

This signal is triggered when an user leaves the channel.

Parameters
fA callback function with the following signature:
void f(channel& chan, user& usr, const optional_string& msg)
Returns
The connection object to disconnect from the signal.
user_iterator irc::channel::end_users ( )

Returns an iterator to the end of the user list.

Returns
An iterator to the end of the user list.
const_user_iterator irc::channel::end_users ( ) const

Returns a const iterator to the end of the user list.

Returns
A const iterator to the end of the user list.
See Also
end_users()
const mode_block& irc::channel::get_modes ( ) const

Returns the mode block for this channel.

Returns
the mode block for this channel.
mode_block& irc::channel::get_modes ( )

Returns the mode block for this channel (const version).

Returns
the mode block for this channel.
See Also
get_modes()
const std::string& irc::channel::get_name ( ) const

Returns the channel name.

Returns
The channel name.
session& irc::channel::get_session ( )

Returns the associated session object.

Returns
The associated session object.
const session& irc::channel::get_session ( ) const

Returns the associated session object (const).

Returns
The associated session object.
See Also
get_session()
const std::string& irc::channel::get_topic ( ) const

Returns the channel topic.

Returns
The channel topic.
bool irc::channel::is_operator ( const user u) const

Returns if the specified user is a channel operator.

Parameters
uThe user to check.
Returns
true if u is an operator, false otherwise.
void irc::channel::list_users ( )

Sends a command::list request to the IRC server.

void irc::channel::message ( const shared_user &  user,
const std::string  message 
)

Sends a message to the channel.

Parameters
userThe user who sent the message.
messageThe message.
void irc::channel::part ( )

Sends a command::part request to the IRC server to leave this channel.

void irc::channel::remove_modes ( const prefix pfx,
const mode_list &  modes 
)

Removes the specified modes from the channel.

Parameters
pfxThe user prefix who sets the modes.
modesThe modes to remove.
void irc::channel::set_operator ( const user u)

Sets a specified user as channel operator.

Parameters
uThe user to set as op.
void irc::channel::set_topic ( std::string  str)

Sets the channel topic.

Parameters
strThe new channel topic.
void irc::channel::user_join ( const shared_user &  user)

An user has joined the channel.

Parameters
userThe new user entry.
void irc::channel::user_part ( const shared_user &  user,
const optional_string &  msg 
)

An user has left the channel.

Parameters
userThe user who leaves the channel.
msgA message to display when the user leave the channel (optional).
void irc::channel::user_quit ( const shared_user &  user,
const std::string &  msg 
)

An user has quitted IRC.

Parameters
userThe user that has quitted.
msgA quit message (optional).