добавил обработку счетчиков
This commit is contained in:
@@ -108,6 +108,7 @@ QString CommandProcessor::processCommand(const QString &sender, const QString &f
|
||||
response = parseTextFiles(response);
|
||||
response = parseBan(response, sender);
|
||||
response = parseAPI(response, sender);
|
||||
response = parseCounters(response);
|
||||
|
||||
if (response.contains("[AI]", Qt::CaseInsensitive)) {
|
||||
response = parseAI(response, parameters);
|
||||
@@ -214,6 +215,24 @@ QString CommandProcessor::parseTextFiles(const QString &response)
|
||||
return result;
|
||||
}
|
||||
|
||||
QString CommandProcessor::parseCounters(const QString &response)
|
||||
{
|
||||
QString result = response;
|
||||
// Используем ленивый квантификатор +?
|
||||
QRegularExpression regex("\\|\\)([^\\)]+?)\\|\\)");
|
||||
QRegularExpressionMatchIterator matches = regex.globalMatch(response);
|
||||
|
||||
while (matches.hasNext()) {
|
||||
QRegularExpressionMatch match = matches.next();
|
||||
QString counterName = match.captured(1);
|
||||
int count = m_context.counterManager->getCount(counterName);
|
||||
QString countStr = QString::number(count);
|
||||
result.replace("|)" + counterName + "|)", countStr);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString CommandProcessor::parseRandomGroups(const QString &response)
|
||||
{
|
||||
QString result = response;
|
||||
|
||||
Reference in New Issue
Block a user