добавил обработку счетчиков

This commit is contained in:
2026-02-14 11:26:45 +03:00
parent 5f53bdcf96
commit 63b7fa4ea1
12 changed files with 796 additions and 131 deletions
+19
View File
@@ -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;