Communi 1.0.0
A cross-platform IRC client library written with Qt 4
|
The IrcCommand class provides the most common IRC commands. More...
#include <IrcCommand>
Inherits QObject.
Public Types | |
enum | Type { Custom, Nick, Quit, Join, Part, Topic, Names, List, Invite, Kick, Mode, Message, Notice, CtcpAction, CtcpRequest, CtcpReply, Who, Whois, Whowas, Away, Quote } |
Public Member Functions | |
IrcCommand (QObject *parent=0) | |
virtual | ~IrcCommand () |
virtual QString | toString () const |
Static Public Member Functions | |
static Q_INVOKABLE IrcCommand * | createAway (const QString &reason=QString()) |
static Q_INVOKABLE IrcCommand * | createCtcpAction (const QString &target, const QString &action) |
static Q_INVOKABLE IrcCommand * | createCtcpReply (const QString &target, const QString &reply) |
static Q_INVOKABLE IrcCommand * | createCtcpRequest (const QString &target, const QString &request) |
static Q_INVOKABLE IrcCommand * | createInvite (const QString &user, const QString &channel) |
static Q_INVOKABLE IrcCommand * | createJoin (const QString &channel, const QString &key=QString()) |
static Q_INVOKABLE IrcCommand * | createKick (const QString &channel, const QString &user, const QString &reason=QString()) |
static Q_INVOKABLE IrcCommand * | createList (const QString &channel, const QString &server=QString()) |
static Q_INVOKABLE IrcCommand * | createMessage (const QString &target, const QString &message) |
static Q_INVOKABLE IrcCommand * | createMode (const QString &target, const QString &mode, const QString &arg=QString()) |
static Q_INVOKABLE IrcCommand * | createNames (const QString &channel) |
static Q_INVOKABLE IrcCommand * | createNick (const QString &nick) |
static Q_INVOKABLE IrcCommand * | createNotice (const QString &target, const QString &message) |
static Q_INVOKABLE IrcCommand * | createPart (const QString &channel, const QString &reason=QString()) |
static Q_INVOKABLE IrcCommand * | createQuit (const QString &reason=QString()) |
static Q_INVOKABLE IrcCommand * | createQuote (const QStringList ¶meters) |
static Q_INVOKABLE IrcCommand * | createTopic (const QString &channel, const QString &topic=QString()) |
static Q_INVOKABLE IrcCommand * | createWho (const QString &mask) |
static Q_INVOKABLE IrcCommand * | createWhois (const QString &user) |
static Q_INVOKABLE IrcCommand * | createWhowas (const QString &user) |
Properties | |
QStringList | parameters |
Type | type |
The IrcCommand class provides the most common IRC commands.
The IrcCommand class supports the most common IRC commands out of the box, and can be extended for custom commands as well. See IrcCommand::Type for the list of built-in command types. IRC commands, as in IrcCommand instances, are sent to the IRC server via IrcSession::sendCommand().
It is recommended to create IrcCommand instances via static IrcCommand::createXxx() methods.
A "custom command" here refers to command types not listed in IrcCommand::Type, the list of built-in command types. There are two ways to send custom commands:
Example implementation of a custom command:
class IrcServerCommand : public IrcCommand { Q_OBJECT public: explicit IrcServerCommand(QObject* parent = 0) : IrcCommand(parent) { } // provided for convenience, to ensure correct parameter order static IrcCommand* create(const QString& serverName, int hopCount, const QString& info) { IrcCommand* command = new IrcServerCommand; command->setParameters(QStringList() << serverName << QString::number(hopCount) << info); return command; } // reimplemented from IrcCommand::toString() virtual toString() const { // SERVER <servername> <hopcount> <info> return QString("SERVER %1 %2 %3").arg(params.value(0), params.value(1), params.value(2)); } };
enum IrcCommand::Type |
This enum describes the built-in command types.
Custom |
A custom command.
|
Nick |
A nick command (NICK) is used to give user a nickname or change the previous one. |
Quit |
A quit command (QUIT) is used to end a client session. |
Join |
A join command (JOIN) is used to start listening a specific channel. |
Part |
A part command (PART) causes the client to be removed from the channel. |
Topic |
A topic command (TOPIC) is used to change or view the topic of a channel. |
Names |
A names command (NAMES) is used to list all nicknames on a channel. |
List |
A list command (LIST) is used to list channels and their topics. |
Invite |
An invite command (INVITE) is used to invite users to a channel. |
Kick |
A kick command (KICK) is used to forcibly remove a user from a channel. |
Mode |
A mode command (MODE) is used to change the mode of users and channels. |
Message |
A message command (PRIVMSG) is used to send private messages to channels and users. |
Notice |
A notice command (NOTICE) is used to send notice messages to channels and users. |
CtcpAction |
A CTCP action command is used to send an action message to channels and users. |
CtcpRequest |
A CTCP request command is used to send a request. |
CtcpReply |
A CTCP reply command is used to send a reply to a request. |
Who |
A who command (WHO) is used to generate a query which returns a list of matching users. |
Whois |
A whois command (WHOIS) is used to query information about a particular user. |
Whowas |
A whowas command (WHOWAS) is used to query information about a user that no longer exists. |
Away |
An away command (AWAY) is used to set the away status. |
Quote |
A quote command is used to send a raw message to the server. |
IrcCommand::IrcCommand | ( | QObject * | parent = 0 | ) | [explicit] |
Constructs a new IrcCommand with parent.
IrcCommand::~IrcCommand | ( | ) | [virtual] |
Destructs the IRC command.
IrcCommand * IrcCommand::createAway | ( | const QString & | reason = QString() | ) | [static] |
Creates a new away command with type IrcCommand::Away and optional parameter reason.
IrcCommand * IrcCommand::createCtcpAction | ( | const QString & | target, |
const QString & | action | ||
) | [static] |
Creates a new CTCP action command with type IrcCommand::CtcpAction and parameters target and action.
IrcCommand * IrcCommand::createCtcpReply | ( | const QString & | target, |
const QString & | reply | ||
) | [static] |
Creates a new CTCP reply command with type IrcCommand::CtcpReply and parameters target and reply.
IrcCommand * IrcCommand::createCtcpRequest | ( | const QString & | target, |
const QString & | request | ||
) | [static] |
Creates a new CTCP request command with type IrcCommand::CtcpRequest and parameters target and request.
IrcCommand * IrcCommand::createInvite | ( | const QString & | user, |
const QString & | channel | ||
) | [static] |
Creates a new invite command with type IrcCommand::Invite and parameters user and channel.
IrcCommand * IrcCommand::createJoin | ( | const QString & | channel, |
const QString & | key = QString() |
||
) | [static] |
Creates a new join command with type IrcCommand::Join and parameters channel and optional key.
IrcCommand * IrcCommand::createKick | ( | const QString & | channel, |
const QString & | user, | ||
const QString & | reason = QString() |
||
) | [static] |
Creates a new kick command with type IrcCommand::Kick and parameters channel, user and optional reason.
IrcCommand * IrcCommand::createList | ( | const QString & | channel, |
const QString & | server = QString() |
||
) | [static] |
Creates a new list command with type IrcCommand::List and parameters channel and optional server.
IrcCommand * IrcCommand::createMessage | ( | const QString & | target, |
const QString & | message | ||
) | [static] |
Creates a new message command with type IrcCommand::Message and parameters target and message.
IrcCommand * IrcCommand::createMode | ( | const QString & | target, |
const QString & | mode, | ||
const QString & | arg = QString() |
||
) | [static] |
Creates a new mode command with type IrcCommand::Mode and parameters target, mode and optional arg.
IrcCommand * IrcCommand::createNames | ( | const QString & | channel | ) | [static] |
Creates a new names command with type IrcCommand::Names and parameter channel.
IrcCommand * IrcCommand::createNick | ( | const QString & | nick | ) | [static] |
Creates a new nick command with type IrcCommand::Nick and parameter nick.
IrcCommand * IrcCommand::createNotice | ( | const QString & | target, |
const QString & | message | ||
) | [static] |
Creates a new notice command with type IrcCommand::Notice and parameters target and message.
IrcCommand * IrcCommand::createPart | ( | const QString & | channel, |
const QString & | reason = QString() |
||
) | [static] |
Creates a new part command with type IrcCommand::Part and parameters channel and optional reason.
IrcCommand * IrcCommand::createQuit | ( | const QString & | reason = QString() | ) | [static] |
Creates a new quit command with type IrcCommand::Quit and optional parameter reason.
IrcCommand * IrcCommand::createQuote | ( | const QStringList & | parameters | ) | [static] |
Creates a new quote command with type IrcCommand::Quote and parameters.
IrcCommand * IrcCommand::createTopic | ( | const QString & | channel, |
const QString & | topic = QString() |
||
) | [static] |
Creates a new topic command with type IrcCommand::Topic and parameters channel and optional topic.
IrcCommand * IrcCommand::createWho | ( | const QString & | mask | ) | [static] |
Creates a new who command with type IrcCommand::Who and parameter mask.
IrcCommand * IrcCommand::createWhois | ( | const QString & | user | ) | [static] |
Creates a new whois command with type IrcCommand::Whois and parameter user.
IrcCommand * IrcCommand::createWhowas | ( | const QString & | user | ) | [static] |
Creates a new whowas command with type IrcCommand::Whowas and parameter user.
QString IrcCommand::toString | ( | ) | const [virtual] |
QStringList IrcCommand::parameters [read, write] |
This property holds the command parameters.
IrcCommand::Type IrcCommand::type [read, write] |
This property holds the command type.