Add local peak timing and /markets bot digest

This commit is contained in:
2569718930@qq.com
2026-04-01 18:24:50 +08:00
parent 07b2770e9d
commit c9719cf577
8 changed files with 192 additions and 45 deletions
+25
View File
@@ -9,6 +9,7 @@ from src.bot.observability import CommandTrace
from src.bot.runtime_coordinator import RuntimeStatus, render_runtime_status_html
_BASIC_COMMANDS = {"start", "help", "id", "top", "diag", "bind", "unbind"}
_BASIC_COMMANDS = {"start", "help", "id", "top", "diag", "bind", "unbind", "markets"}
class BasicCommandHandler:
@@ -17,10 +18,12 @@ class BasicCommandHandler:
bot: Any,
io_layer: BotIOLayer,
runtime_status_provider: Callable[[], RuntimeStatus],
config: dict | None = None,
):
self.bot = bot
self.io_layer = io_layer
self.runtime_status_provider = runtime_status_provider
self.config = config or {}
def register(self) -> None:
@self.bot.message_handler(commands=["start", "help"])
@@ -47,6 +50,10 @@ class BasicCommandHandler:
def _unbind(message):
self._dispatch(message)
@self.bot.message_handler(commands=["markets"])
def _markets(message):
self._dispatch(message)
@self.bot.message_handler(
content_types=["text"],
func=lambda message: extract_command_name(
@@ -87,6 +94,9 @@ class BasicCommandHandler:
if command == "unbind":
self.handle_unbind(message)
return
if command == "markets":
self.handle_markets(message)
return
def handle_start_help(self, message: Any) -> None:
trace = CommandTrace("/start", message)
@@ -233,3 +243,18 @@ class BasicCommandHandler:
trace.set_status("ok", "unbound")
finally:
trace.emit()
def handle_markets(self, message: Any) -> None:
trace = CommandTrace("/markets", message)
try:
from src.utils.telegram_push import build_market_monitor_digest
summary = build_market_monitor_digest(
self.config,
slot_label="当前市场概览",
force_refresh=False,
)
self.bot.reply_to(message, summary)
trace.set_status("ok")
finally:
trace.emit()