Ejemplo n.º 1
0
IrcCommand* IrcCommandPrivate::createCommand(IrcCommand::Type type, const QStringList& parameters)
{
    IrcCommand* command = new IrcCommand;
    command->setType(type);
    command->setParameters(parameters);
    return command;
}
Ejemplo n.º 2
0
IrcCommand* IrcCommandParserPrivate::parseCommand(const IrcCommandInfo& command, const QString& input) const
{
    IrcCommand* cmd = 0;
    QStringList params;
    if (processParameters(command, input, &params)) {
        const int count = params.count();
        if (count >= command.min && count <= command.max) {
            cmd = new IrcCommand;
            cmd->setType(command.type);
            if (command.type == IrcCommand::Custom)
                params.prepend(command.command);
            cmd->setParameters(params);
        }
    }
    return cmd;
}
Ejemplo n.º 3
0
IrcCommand* CommandParser::parseCustomCommand(const QString& command, const QStringList& params, const QString& syntax)
{
	QStringList tokens = syntax.split(" ", QString::SkipEmptyParts);
    int min = 0;
	int max = tokens.count();
	while (!tokens.isEmpty())
	{
		QString p = tokens.takeFirst();
		if ( tokens.isEmpty() && (p.endsWith("...>") || p.endsWith("...>)")) )
            max = INT_MAX;
		if (!p.startsWith("(<"))
			++min;
	}
    if (params.count() >= min && params.count() <= max) {
        IrcCommand* cmd = new IrcCommand;
        cmd->setType(IrcCommand::Custom);
        cmd->setParameters(QStringList(command) + params);
        return cmd;
    }
    return 0;
}
Ejemplo n.º 4
0
 static IrcCommand* create(const QString& target, const QDateTime &timeStamp)
 {
     IrcCommand* command = new IrcMessageSeenCommand;
     command->setParameters(QStringList() << target << timeStamp.toUTC().toString(Qt::ISODate));
     return command;
 }