chore(telegram): remove unused imports, fix exception masking, and add explicit boundary checks

keyboardstaff committed Mar 21, 2026 at 01:18 UTC eb92fde0091c8ad2d4b6f9a07ce272ff2ce40b80
3 files changed +6 -3
plugins/_telegram_integration/api/webhook.py
+1 -1
@@ -20,7 +20,7 @@ class TelegramWebhook(ApiHandler):
20 async def process(self, input: dict, request: Request) -> dict | Response:
21 from aiogram.types import Update
22
23 - from plugins._telegram_integration.helpers.bot_manager import get_bot, get_all_bots
23 + from plugins._telegram_integration.helpers.bot_manager import get_bot
24
25 # Identify which bot this update is for
26 bot_name = request.args.get("bot", "")
plugins/_telegram_integration/helpers/handler.py
+4 -1
@@ -492,7 +492,10 @@ async def send_telegram_reply(
492 PrintStyle.error(f"Telegram reply failed: {error}")
493 return error
494 finally:
495 - await reply_bot.session.close()
495 + try:
496 + await reply_bot.session.close()
497 + except Exception:
498 + pass
499
500 # Helpers
501
plugins/_telegram_integration/helpers/telegram_client.py
+1 -1
@@ -188,7 +188,7 @@ def _split_text(text: str, max_len: int) -> list[str]:
188 break
189 # Try to split at newline
190 split_at = text.rfind("\n", 0, max_len)
191 - if split_at < max_len // 2:
191 + if split_at == -1 or split_at < max_len // 2:
192 split_at = max_len
193 chunks.append(text[:split_at])
194 text = text[split_at:].lstrip("\n")