feat: Add /city and /deb command handlers for weather data and historical weather queries.

This commit is contained in:
2569718930@qq.com
2026-03-14 14:24:11 +08:00
parent 6d1f77cac1
commit 530080a75d
2 changed files with 18 additions and 2 deletions
+9 -1
View File
@@ -11,6 +11,11 @@ from src.bot.services.city_command_service import CityCommandService
from src.bot.settings import CITY_QUERY_COST
def _is_city_command_text(text: str | None) -> bool:
head = str(text or "").strip().split(maxsplit=1)[0].lower()
return head == "/city" or head.startswith("/city@")
class CityCommandHandler:
def __init__(
self,
@@ -25,7 +30,10 @@ class CityCommandHandler:
self.io_layer = io_layer
def register(self) -> None:
@self.bot.message_handler(commands=["city"])
@self.bot.message_handler(
func=lambda message: _is_city_command_text(getattr(message, "text", None)),
content_types=["text"],
)
def _city(message):
self.handle(message)
+9 -1
View File
@@ -11,6 +11,11 @@ from src.bot.services.deb_command_service import DebCommandService
from src.bot.settings import DEB_QUERY_COST
def _is_deb_command_text(text: str | None) -> bool:
head = str(text or "").strip().split(maxsplit=1)[0].lower()
return head == "/deb" or head.startswith("/deb@")
class DebCommandHandler:
def __init__(
self,
@@ -25,7 +30,10 @@ class DebCommandHandler:
self.io_layer = io_layer
def register(self) -> None:
@self.bot.message_handler(commands=["deb"])
@self.bot.message_handler(
func=lambda message: _is_deb_command_text(getattr(message, "text", None)),
content_types=["text"],
)
def _deb(message):
self.handle(message)