mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-18 23:45:49 +00:00
chore(telegram): remove unused imports, fix exception masking, and add explicit boundary checks
This commit is contained in:
parent
fc787ea2c4
commit
eb92fde009
3 changed files with 6 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ class TelegramWebhook(ApiHandler):
|
|||
async def process(self, input: dict, request: Request) -> dict | Response:
|
||||
from aiogram.types import Update
|
||||
|
||||
from plugins._telegram_integration.helpers.bot_manager import get_bot, get_all_bots
|
||||
from plugins._telegram_integration.helpers.bot_manager import get_bot
|
||||
|
||||
# Identify which bot this update is for
|
||||
bot_name = request.args.get("bot", "")
|
||||
|
|
|
|||
|
|
@ -492,7 +492,10 @@ async def send_telegram_reply(
|
|||
PrintStyle.error(f"Telegram reply failed: {error}")
|
||||
return error
|
||||
finally:
|
||||
await reply_bot.session.close()
|
||||
try:
|
||||
await reply_bot.session.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Helpers
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ def _split_text(text: str, max_len: int) -> list[str]:
|
|||
break
|
||||
# Try to split at newline
|
||||
split_at = text.rfind("\n", 0, max_len)
|
||||
if split_at < max_len // 2:
|
||||
if split_at == -1 or split_at < max_len // 2:
|
||||
split_at = max_len
|
||||
chunks.append(text[:split_at])
|
||||
text = text[split_at:].lstrip("\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue