stage-9: heartbeat system with periodic checks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MoltBot Service
2026-02-13 16:40:39 +00:00
parent 24a4d87f8c
commit 0bc4b8cb3e
6 changed files with 527 additions and 1 deletions

View File

@@ -123,6 +123,7 @@ def create_bot(config: Config) -> discord.Client:
"`/model <choice>` — Change model for this channel's session",
"`/logs [n]` — Show last N log lines (default 10)",
"`/restart` — Restart the bot process (owner only)",
"`/heartbeat` — Run heartbeat health checks",
"",
"**Cron Jobs**",
"`/cron list` — List all scheduled jobs",
@@ -400,6 +401,18 @@ def create_bot(config: Config) -> discord.Client:
tree.add_command(cron_group)
@tree.command(name="heartbeat", description="Run heartbeat health checks")
async def heartbeat_cmd(interaction: discord.Interaction) -> None:
from src.heartbeat import run_heartbeat
await interaction.response.defer(ephemeral=True)
try:
result = await asyncio.to_thread(run_heartbeat)
await interaction.followup.send(result, ephemeral=True)
except Exception as e:
await interaction.followup.send(
f"Heartbeat error: {e}", ephemeral=True
)
@tree.command(name="channels", description="List registered channels")
async def channels(interaction: discord.Interaction) -> None:
ch_map = config.get("channels", {})