From ee769bedcb655c638c4e8f808cbf27274ce6afdd Mon Sep 17 00:00:00 2001 From: mzwing Date: Sun, 22 Mar 2026 03:25:24 +0800 Subject: [PATCH] fix(platform.tg_adapter): import Forbidden instead of deprecated Unauthorized (#6765) --- astrbot/core/platform/sources/telegram/tg_adapter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/core/platform/sources/telegram/tg_adapter.py b/astrbot/core/platform/sources/telegram/tg_adapter.py index 2829759102..5f44913573 100644 --- a/astrbot/core/platform/sources/telegram/tg_adapter.py +++ b/astrbot/core/platform/sources/telegram/tg_adapter.py @@ -8,7 +8,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from telegram import BotCommand, Update from telegram.constants import ChatType -from telegram.error import InvalidToken, Unauthorized +from telegram.error import Forbidden, InvalidToken from telegram.ext import ApplicationBuilder, ContextTypes, ExtBot, filters from telegram.ext import MessageHandler as TelegramMessageHandler @@ -183,7 +183,7 @@ async def run(self) -> None: ) except asyncio.CancelledError: raise - except (Unauthorized, InvalidToken) as e: + except (Forbidden, InvalidToken) as e: logger.error( f"Telegram token is invalid or unauthorized: {e}. Polling stopped." )