mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-11 16:26:02 +00:00
fix: telegram adapter gracefully stop
This commit is contained in:
@@ -218,7 +218,6 @@ class TelegramAdapter(adapter.MessagePlatformAdapter):
|
|||||||
):
|
):
|
||||||
msg_seq = bot_message.msg_sequence
|
msg_seq = bot_message.msg_sequence
|
||||||
if (msg_seq - 1) % 8 == 0 or is_final:
|
if (msg_seq - 1) % 8 == 0 or is_final:
|
||||||
|
|
||||||
assert isinstance(message_source.source_platform_object, Update)
|
assert isinstance(message_source.source_platform_object, Update)
|
||||||
components = await TelegramMessageConverter.yiri2target(message, self.bot)
|
components = await TelegramMessageConverter.yiri2target(message, self.bot)
|
||||||
args = {}
|
args = {}
|
||||||
@@ -295,8 +294,12 @@ class TelegramAdapter(adapter.MessagePlatformAdapter):
|
|||||||
self.bot_account_id = (await self.bot.get_me()).username
|
self.bot_account_id = (await self.bot.get_me()).username
|
||||||
await self.application.updater.start_polling(allowed_updates=Update.ALL_TYPES)
|
await self.application.updater.start_polling(allowed_updates=Update.ALL_TYPES)
|
||||||
await self.application.start()
|
await self.application.start()
|
||||||
|
await self.logger.info('Telegram adapter running')
|
||||||
|
|
||||||
async def kill(self) -> bool:
|
async def kill(self) -> bool:
|
||||||
if self.application.running:
|
if self.application.running:
|
||||||
await self.application.stop()
|
await self.application.stop()
|
||||||
|
if self.application.updater:
|
||||||
|
await self.application.updater.stop()
|
||||||
|
await self.logger.info('Telegram adapter stopped')
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user