ircpp::message Class Reference

The message represents one incoming IRC message. More...

#include <message.h>

List of all members.

Public Member Functions

const sessionparent () const
 Returns the parent session to which the message belongs.
const std::string & raw_line () const
 Returns the raw message string.
const commandcmd () const
 Returns the message's command or numeric.
const userfrom () const
 Returns the sender of the message.
const entityto () const
 Returns the recipient of the message.
const entitytarget () const
 Returns the target of the message.
const size_t num_params (bool allparams=false) const
 Returns the number of parameters (words) in the message.
const std::string & param (size_t num, bool strip=true, bool allparams=false) const
 Returns the n'th parameter (word) of the message.
const std::string & params (size_t num=0, bool strip=true, bool allparams=false) const
 Returns all the parameters of the message, or the parameters from "num" to the end.
bool is_ctcp () const
 Determine whether the message is a CTCP message.


Detailed Description

The message represents one incoming IRC message.

Every message received is emitted as a message object. The message object contains various functions for extracting the message data in different ways, for example single words, or an entire line.

The message also contains references to the sender of the message, the recipient, and the target (in the case of messages like modes).

The sender is always a user; the recipient and target may be users or channels.


Member Function Documentation

const session & ircpp::message::parent (  )  const

Returns the parent session to which the message belongs.

Each message is associated with one IRC session. This function allows you to tell which session the message came from.

Returns:
The parent session to which the message belongs.

const string & ircpp::message::raw_line (  )  const

Returns the raw message string.

Use this function to get the raw message string, unprocessed.

Returns:
The raw message string.

const command & ircpp::message::cmd (  )  const

Returns the message's command or numeric.

Each IRC message contains a command (e.g. NOTICE) or a numeric (e.g. 354), which identifies what the message does. This function returns the command.

Note that the returned command is an object. It can be treated as an integer for comparison purposes (e.g. if(msg.cmd() == 354)). If you want to print out the command, use msg.cmd().str(), which will return the string representation of the command.

For more information, see command

Returns:
The message's command.

const user & ircpp::message::from (  )  const

Returns the sender of the message.

Messages are sent by users, and this function returns a reference to a user object which represents the user that sent the message.

Returns:
The message's sender.

const entity & ircpp::message::to (  )  const

Returns the recipient of the message.

Messages can be sent to a user or a channel. This function returns a reference to a user or channel object which represents the recipient of the message.

Note: Only some messages have a recipient. For message with no recipient, the null user is returned.

The return type is "entity &" because the recipient can be either a user or a channel. You can use the entity object's to_channel() or to_user() functions to convert the recipient to the appropriate type.

Returns:
The message's recipient.

const entity & ircpp::message::target (  )  const

Returns the target of the message.

Some messages (e.g. mode, kick) contain a recipient (usually the channel) and a target (the subject of the mode change, or the kickee). This function returns the target of the message, if present. If the message has no target, it returns the null user.

Returns:
The message's target.

const size_t ircpp::message::num_params ( bool  allparams = false  )  const

Returns the number of parameters (words) in the message.

Each IRC message has a number of parameters (words) after the sender, command, and recipient (if present). This function returns the count of these parameters.

If the message contains a target(), the number of parameters returned excludes the target, unless allparams is set to true.

Parameters:
allparams If true, include the target in the count of the parameters.
Returns:
The number of parameters (words) in the message.

const string & ircpp::message::param ( size_t  num,
bool  strip = true,
bool  allparams = false 
) const

Returns the n'th parameter (word) of the message.

Each IRC message has a number of parameters (words) after the sender, command, and recipient (if present). This function returns a single numbered parameter (word).

"num" specifies the number of the parameter to be returned.

The optional "strip" parameter controls whether or not unnecessary characters (e.g. leading colons (:)) are stripped from the returned string.

The optional "allparams" parameter controls whether only the relevant parameters are returned, or all of them as received from the irc server. If set to false (the default), the recipient and target (if present) will be excluded.

Parameters:
num The number of the parameter to return
strip (optional) If true, unnecessary characters will be stripped from the returned string. If omitted, defaults to true.
allparams (optional) If true, do not exclude the recipient and target from the parameters. If omitted, defaults to false.
Returns:
The n'th parameter (word) of the message.

const string & ircpp::message::params ( size_t  num = 0,
bool  strip = true,
bool  allparams = false 
) const

Returns all the parameters of the message, or the parameters from "num" to the end.

Each IRC message has a number of parameters (words) after the sender, command, and recipient (if present). This function returns all or some of the parameters.

If "num" is specified, params() will return a string containing the parameters starting with parameter "num" and ending at the end of the message. Leave it out, or set it to 0, to return all the parameters.

The optional "strip" parameter controls whether or not unnecessary characters (e.g. leading colons (:)) are stripped from the returned string.

The optional "allparams" parameter controls whether only the relevant parameters are returned, or all of them as received from the irc server. If set to false (the default), the recipient and target (if present) will be excluded.

Parameters:
num (optional) The number of the parameter to start at. If omitted, defaults to 0, returning all parameters.
strip (optional) If true, unnecessary characters will be stripped from the returned string. If omitted, defaults to true.
allparams (optional) If true, do not exclude the recipient and target from the parameters. If omitted, defaults to false.
Returns:
The parameters of the message from "num" to the end.

bool ircpp::message::is_ctcp (  )  const

Determine whether the message is a CTCP message.

CTCP (Client to Client Protocol) messages are sent as PRIVMSGs with the message body surrounded by special characters. Because of this, it is not possible to tell apart PRIVMSG and CTCP messages just from their command. Use this function to determine if a PRIVMSG is a CTCP or not.

Returns:
True if the message is a CTCP message, false otherwise.


The documentation for this class was generated from the following files:
Generated on Sat Oct 13 23:35:41 2007 for libircpp by  doxygen 1.5.3