Skip to content

[Bug] Cannot use Telegram Bot #6765

@mzwing

Description

@mzwing

What happened / 发生了什么

无法正常使用Telegram Bot Adapter。

经过查找,该Bug在 #6648 中被引入。其astrbot/core/platform/sources/telegram/tg_adapter.py#L11中错误地从telegram.error导入了Unauthorized

而根据https://docs.python-telegram-bot.org/en/stable/telegram.error.html,在 python-telegram-bot v20.0中,Unauthorized已被Forbidden代替。而pyproject.tomlrequirements.txt却设置了python-telegram-bot>=22.6

另外,经过查找,在#6648 (comment)中,Codex Review Bot已经提醒此处使用了已被弃用的API,但是却没有被修复即被合并,并跟随v4.21.0一同发布。

Reproduce / 如何复现?

也许正常配置一个Telegram Bot就可以?

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

AstrBot版本:v4.21.0

部署方式:Docker

提供商:OpenAI-Compatible的Qwen/Qwen3.5-397B-A17B

消息平台适配器:Telegram Bot

OS

Linux

Logs / 报错日志

[2026-03-22 02:38:07.634] [Core] [INFO] [respond.stage:89]: 分段回复间隔时间:[1.5, 3.5]
[2026-03-22 02:38:07.634] [Core] [INFO] [platform.manager:125]: 载入 telegram(mzwing's AstrBot) 平台适配器 ...
[2026-03-22 02:38:08.130] [Core] [ERRO] [v4.21.0] [platform.manager:188]: 加载平台适配器 telegram 失败,原因:cannot import name 'Unauthorized' from 'telegram.error' (/usr/local/lib/python3.12/site-packages/telegram/error.py)。请检查依赖库是否安装。提示:可以在 管理面板->平台日志->安装Pip库 中安装依赖库。
[2026-03-22 02:38:08.131] [Core] [ERRO] [v4.21.0] [platform.manager:195]: 未找到适用于 telegram(mzwing's AstrBot) 平台适配器,请检查是否已经安装或者名称填写错误
[2026-03-22 02:38:09.640] [Core] [INFO] [dashboard.server:331]: 正在启动 WebUI, 监听地址: http://0.0.0.0:6185
[2026-03-22 02:38:09.640] [Core] [INFO] [dashboard.server:333]: 提示: WebUI 将监听所有网络接口,请注意安全。(可在 data/cmd_config.json 中配置 dashboard.host 以修改 host)

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platformThe bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions