#include <message.h>
Public Member Functions | |
| const session & | parent () const |
| Returns the parent session to which the message belongs. | |
| const std::string & | raw_line () const |
| Returns the raw message string. | |
| const command & | cmd () const |
| Returns the message's command or numeric. | |
| const user & | from () const |
| Returns the sender of the message. | |
| const entity & | to () const |
| Returns the recipient of the message. | |
| const entity & | target () 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. | |
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.
| const session & ircpp::message::parent | ( | ) | const |
| const string & ircpp::message::raw_line | ( | ) | const |
| 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
| const user & ircpp::message::from | ( | ) | const |
| 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.
| 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.
| 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.
| allparams | If true, include the target in the count of the parameters. |
| 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.
| 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. |
| 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.
| 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. |
| 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.
1.5.3