Ejemplo n.º 1
0
//![receive]
void IrcBot::processMessage(IrcPrivateMessage* message)
{
    if (message->isPrivate()) {
        // private message: reply to the message sender
        // => triggers: "!<cmd> <params>" and "<cmd> <params>"
        parser.setTarget(message->nick());
        parser.setTriggers(QStringList() << "!" << "");
    } else {
        // channel message: reply to the target channel
        // => triggers: "!<cmd> <params>" and "bot: <cmd> <params>"
        parser.setTarget(message->target());
        parser.setTriggers(QStringList() << "!" << nickName().append(":"));
    }

    IrcCommand* cmd = parser.parse(message->content());
    if (cmd) {
        if (cmd->type() == IrcCommand::Custom && cmd->parameters().value(0) == "HELP") {
            help(cmd->parameters().mid(1));
        } else {
            sendCommand(cmd);

            if (cmd->type() == IrcCommand::Quit) {
                connect(this, SIGNAL(disconnected()), qApp, SLOT(quit()));
                QTimer::singleShot(1000, qApp, SLOT(quit()));
            }
        }
    }
}
Ejemplo n.º 2
0
void tst_IrcCommand::testDefaults()
{
    IrcCommand cmd;
    QVERIFY(cmd.parameters().isEmpty());
    QCOMPARE(cmd.type(), IrcCommand::Custom);
    QCOMPARE(cmd.encoding(), QByteArray("UTF-8"));

    QTest::ignoreMessage(QtWarningMsg, "Reimplement IrcCommand::toString() for IrcCommand::Custom");
    QVERIFY(cmd.toString().isEmpty());
}
Ejemplo n.º 3
0
void tst_IrcCommand::testDefaults()
{
    IrcCommand cmd;
    QVERIFY(cmd.type() == IrcCommand::Custom);
    QVERIFY(cmd.parameters().isEmpty());
}