feat: Add new handlers for /deb and /city commands, and a general activity tracker.

This commit is contained in:
2569718930@qq.com
2026-03-14 21:47:21 +08:00
parent 530080a75d
commit 1c57a6f56e
3 changed files with 59 additions and 3 deletions
+17 -1
View File
@@ -16,5 +16,21 @@ class ActivityHandler:
self.handle(message)
def handle(self, message: Any) -> None:
text = str(getattr(message, "text", "") or "")
normalized = text
for marker in (
"\ufeff",
"\u200b",
"\u200c",
"\u200d",
"\u2060",
"\u2066",
"\u2067",
"\u2068",
"\u2069",
):
normalized = normalized.replace(marker, "")
normalized = normalized.lstrip()
if normalized.startswith("/") or normalized.startswith(""):
return
self.io_layer.track_group_text_activity(message)
+21 -1
View File
@@ -11,8 +11,28 @@ from src.bot.services.city_command_service import CityCommandService
from src.bot.settings import CITY_QUERY_COST
def _normalized_command_head(text: str | None) -> str:
raw = str(text or "")
for marker in (
"\ufeff",
"\u200b",
"\u200c",
"\u200d",
"\u2060",
"\u2066",
"\u2067",
"\u2068",
"\u2069",
):
raw = raw.replace(marker, "")
raw = raw.strip()
if raw.startswith(""):
raw = "/" + raw[1:]
return raw.split(maxsplit=1)[0].lower() if raw else ""
def _is_city_command_text(text: str | None) -> bool:
head = str(text or "").strip().split(maxsplit=1)[0].lower()
head = _normalized_command_head(text)
return head == "/city" or head.startswith("/city@")
+21 -1
View File
@@ -11,8 +11,28 @@ from src.bot.services.deb_command_service import DebCommandService
from src.bot.settings import DEB_QUERY_COST
def _normalized_command_head(text: str | None) -> str:
raw = str(text or "")
for marker in (
"\ufeff",
"\u200b",
"\u200c",
"\u200d",
"\u2060",
"\u2066",
"\u2067",
"\u2068",
"\u2069",
):
raw = raw.replace(marker, "")
raw = raw.strip()
if raw.startswith(""):
raw = "/" + raw[1:]
return raw.split(maxsplit=1)[0].lower() if raw else ""
def _is_deb_command_text(text: str | None) -> bool:
head = str(text or "").strip().split(maxsplit=1)[0].lower()
head = _normalized_command_head(text)
return head == "/deb" or head.startswith("/deb@")