From 4bbfa2f1d72414ce2c4e8a12e0d0e2a35f1de1c4 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Sun, 17 Aug 2025 13:52:02 +0800 Subject: [PATCH] fix: telegram adapter gracefully stop --- pkg/platform/sources/telegram.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/platform/sources/telegram.py b/pkg/platform/sources/telegram.py index 42279317..8aee12d7 100644 --- a/pkg/platform/sources/telegram.py +++ b/pkg/platform/sources/telegram.py @@ -218,7 +218,6 @@ class TelegramAdapter(adapter.MessagePlatformAdapter): ): msg_seq = bot_message.msg_sequence if (msg_seq - 1) % 8 == 0 or is_final: - assert isinstance(message_source.source_platform_object, Update) components = await TelegramMessageConverter.yiri2target(message, self.bot) args = {} @@ -295,8 +294,12 @@ class TelegramAdapter(adapter.MessagePlatformAdapter): self.bot_account_id = (await self.bot.get_me()).username await self.application.updater.start_polling(allowed_updates=Update.ALL_TYPES) await self.application.start() + await self.logger.info('Telegram adapter running') async def kill(self) -> bool: if self.application.running: await self.application.stop() + if self.application.updater: + await self.application.updater.stop() + await self.logger.info('Telegram adapter stopped') return True