From 3e68b7a3f3fcef9da43045098c4b7770c721816a Mon Sep 17 00:00:00 2001 From: Lockinwize Lolite Date: Sun, 22 Mar 2026 13:35:09 +0800 Subject: [PATCH] fix(platform.tg_adapter): import Forbidden instead of deprecated Unauthorized (#6765) (#6769) --- 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 282975910..5f4491357 100644 --- a/astrbot/core/platform/sources/telegram/tg_adapter.py +++ b/astrbot/core/platform/sources/telegram/tg_adapter.py @@ -8,7 +8,7 @@ from typing import cast 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 @@ class TelegramPlatformAdapter(Platform): ) 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." )