fix(restart): show restart completion with elapsed time across channels

This commit is contained in:
imfondof
2026-04-04 02:21:42 +08:00
committed by Xubin Ren
parent ba7c07ccf2
commit 896d578677
8 changed files with 179 additions and 151 deletions
+2 -3
View File
@@ -9,8 +9,8 @@ import sys
from nanobot import __version__
from nanobot.bus.events import OutboundMessage
from nanobot.command.router import CommandContext, CommandRouter
from nanobot.config.runtime_keys import RESTART_NOTIFY_CHANNEL_ENV, RESTART_NOTIFY_CHAT_ID_ENV
from nanobot.utils.helpers import build_status_content
from nanobot.utils.restart import set_restart_notice_to_env
async def cmd_stop(ctx: CommandContext) -> OutboundMessage:
@@ -36,8 +36,7 @@ async def cmd_stop(ctx: CommandContext) -> OutboundMessage:
async def cmd_restart(ctx: CommandContext) -> OutboundMessage:
"""Restart the process in-place via os.execv."""
msg = ctx.msg
os.environ[RESTART_NOTIFY_CHANNEL_ENV] = msg.channel
os.environ[RESTART_NOTIFY_CHAT_ID_ENV] = msg.chat_id
set_restart_notice_to_env(channel=msg.channel, chat_id=msg.chat_id)
async def _do_restart():
await asyncio.sleep(1)