Skip to content

[Bug]telegram文件接受问题 #9448

Description

@lq-259

What happened / 发生了什么

telegram平台给bot发文件时llm看不到文件
让bot自己做了修复并整理了一下

TG文件转发修复说明.md

Image

Reproduce / 如何复现?

telegram平台给bot发文件

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

uv

OS

Linux

Logs / 报错日志

2026-07-30 08:22:06.857] [Core] [DBUG] [httpcore._trace:87]: send_request_body.complete
[2026-07-30 08:22:06.857] [Core] [DBUG] [httpcore._trace:87]: receive_response_headers.started request=<Request [b'POST']>
[2026-07-30 08:22:15.475] [Core] [DBUG] [httpcore._trace:87]: receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Thu, 30 Jul 2026 00:22:15 GMT'), (b'Content-Type', b'application/json'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'CF-Ray', b'a23035055e7106ac-SEA'), (b'CF-Cache-Status', b'DYNAMIC'), (b'Access-Control-Allow-Origin', b''), (b'Server', b'cloudflare'), (b'Strict-Transport-Security', b'max-age=31536000; includeSubDomains; preload'), (b'access-control-allow-methods', b'GET, POST, OPTIONS'), (b'access-control-expose-headers', b'Content-Length,Content-Type,Date,Server,Connection'), (b'Report-To', b'{"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=AQUWlTDICKufAS8oY5%2FX1Hh7Ok7NgFgIpYtgnQHorZ5ePt9R9FDdHS3aF6SV8Qrnh9sp3LZwzKU04kLPuaapEDmHAaAbnxX3j0Nld%2FiMxr18zLbZiVBxKMbdUlvP"}]}'), (b'Nel', b'{"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}'), (b'Content-Encoding', b'gzip'), (b'alt-svc', b'h3=":443"; ma=86400')])
[2026-07-30 08:22:15.475] [Core] [INFO] [httpx._client:1740]: HTTP Request: POST https://tg.yswl.cf/bot8637326337:AAFxfJRuFVkWL124zJAKjHWWzNK_uMm5qbQ/getUpdates "HTTP/1.1 200 OK"
[2026-07-30 08:22:15.476] [Core] [DBUG] [httpcore._trace:87]: receive_response_body.started request=<Request [b'POST']>
[2026-07-30 08:22:15.476] [Core] [DBUG] [httpcore._trace:87]: receive_response_body.complete
[2026-07-30 08:22:15.477] [Core] [DBUG] [httpcore._trace:87]: response_closed.started
[2026-07-30 08:22:15.477] [Core] [DBUG] [httpcore._trace:87]: response_closed.complete
[2026-07-30 08:22:15.477] [Core] [DBUG] [telegram._bot:749]: Call to Bot API endpoint getUpdates finished with return value [{'update_id': 648490144, 'message': {'message_id': 61181, 'from': {'id': 641981595, 'is_bot': False, 'first_name': 's', 'last_name': 'ao', 'language_code': 'zh-hans'}, 'chat': {'id': 641981595, 'first_name': 's', 'last_name': 'ao', 'type': 'private'}, 'date': 1785370935, 'forward_origin': {'type': 'user', 'sender_user': {'id': 7437566005, 'is_bot': True, 'first_name': '小人国助理', 'username': 'XRGKINGbot'}, 'date': 1785228889}, 'forward_from': {'id': 7437566005, 'is_bot': True, 'first_name': '小人国助理', 'username': 'XRGKINGbot'}, 'forward_date': 1785228889, 'document': {'file_name': 'wxcode模块.js', 'mime_type': 'application/javascript', 'file_id': 'BQACAgUAAxkBAALkSGpobntIVSl_AmgXfai8l0HrFKBAAAL4IAAC4NdIV40kFtbJSdAmPQQ', 'file_unique_id': 'AgAD-CAAAuDXSFc', 'file_size': 13410}, 'caption': '📥 脚本下载成功\n\n脚本名称: wxcode模块\n脚本类型: 💬 分享脚本'}}]
[2026-07-30 08:22:15.477] [Core] [DBUG] [telegram._bot:4779]: Getting updates: [648490144]
[2026-07-30 08:22:15.480] [Core] [DBUG] [ext._application:1219]: Processing update Update(message=Message(api_kwargs={'forward_date': 1785228889, 'forward_from': {'id': 7437566005, 'is_bot': True, 'first_name': '小人国助理', 'username': 'XRGKINGbot'}}, caption='📥 脚本下载成功\n\n脚本名称: wxcode模块\n脚本类型: 💬 分享脚本', channel_chat_created=False, chat=Chat(first_name='s', id=641981595, last_name='ao', type=<ChatType.PRIVATE>), date=datetime.datetime(2026, 7, 30, 0, 22, 15, tzinfo=datetime.timezone.utc), delete_chat_photo=False, document=Document(file_id='BQACAgUAAxkBAALkSGpobntIVSl_AmgXfai8l0HrFKBAAAL4IAAC4NdIV40kFtbJSdAmPQQ', file_name='wxcode模块.js', file_size=13410, file_unique_id='AgAD-CAAAuDXSFc', mime_type='application/javascript'), forward_origin=MessageOriginUser(date=datetime.datetime(2026, 7, 28, 8, 54, 49, tzinfo=datetime.timezone.utc), sender_user=User(first_name='小人国助理', id=7437566005, is_bot=True, username='XRGKINGbot'), type=<MessageOriginType.USER>), from_user=User(first_name='s', id=641981595, is_bot=False, language_code='zh-hans', last_name='ao'), group_chat_created=False, message_id=61181, supergroup_chat_created=False), update_id=648490144)
[2026-07-30 08:22:15.481] [Core] [DBUG] [telegram.tg_adapter:427]: Telegram message: Message(api_kwargs={'forward_date': 1785228889, 'forward_from': {'id': 7437566005, 'is_bot': True, 'first_name': '小人国助理', 'username': 'XRGKINGbot'}}, caption='📥 脚本下载成功\n\n脚本名称: wxcode模块\n脚本类型: 💬 分享脚本', channel_chat_created=False, chat=Chat(first_name='s', id=641981595, last_name='ao', type=<ChatType.PRIVATE>), date=datetime.datetime(2026, 7, 30, 0, 22, 15, tzinfo=datetime.timezone.utc), delete_chat_photo=False, document=Document(file_id='BQACAgUAAxkBAALkSGpobntIVSl_AmgXfai8l0HrFKBAAAL4IAAC4NdIV40kFtbJSdAmPQQ', file_name='wxcode模块.js', file_size=13410, file_unique_id='AgAD-CAAAuDXSFc', mime_type='application/javascript'), forward_origin=MessageOriginUser(date=datetime.datetime(2026, 7, 28, 8, 54, 49, tzinfo=datetime.timezone.utc), sender_user=User(first_name='小人国助理', id=7437566005, is_bot=True, username='XRGKINGbot'), type=<MessageOriginType.USER>), from_user=User(first_name='s', id=641981595, is_bot=False, language_code='zh-hans', last_name='ao'), group_chat_created=False, message_id=61181, supergroup_chat_created=False)
[2026-07-30 08:22:15.482] [Core] [DBUG] [telegram._bot:740]: Calling Bot API endpoint getFile with parameters {'file_id': 'BQACAgUAAxkBAALkSGpobntIVSl_AmgXfai8l0HrFKBAAAL4IAAC4NdIV40kFtbJSdAmPQQ'}
[2026-07-30 08:22:15.482] [Core] [DBUG] [httpcore._trace:87]: close.started
[2026-07-30 08:22:15.483] [Core] [DBUG] [httpcore._trace:87]: close.complete
[2026-07-30 08:22:15.483] [Core] [DBUG] [httpcore._trace:87]: connect_tcp.started host='tg.yswl.cf' port=443 local_address=None timeout=5.0 socket_options=None
[2026-07-30 08:22:15.484] [Core] [DBUG] [telegram._bot:740]: Calling Bot API endpoint getUpdates with parameters {'timeout': datetime.timedelta(seconds=10), 'offset': 648490145}
[2026-07-30 08:22:15.484] [Core] [DBUG] [httpcore._trace:87]: send_request_headers.started request=<Request [b'POST']>
[2026-07-30 08:22:15.485] [Core] [DBUG] [httpcore._trace:87]: send_request_headers.complete
[2026-07-30 08:22:15.485] [Core] [DBUG] [httpcore._trace:87]: send_request_body.started request=<Request [b'POST']>
[2026-07-30 08:22:15.485] [Core] [DBUG] [httpcore._trace:87]: send_request_body.complete
[2026-07-30 08:22:15.485] [Core] [DBUG] [httpcore._trace:87]: receive_response_headers.started request=<Request [b'POST']>
[2026-07-30 08:22:15.495] [Core] [DBUG] [httpcore._trace:87]: connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f2937d5d400>
[2026-07-30 08:22:15.495] [Core] [DBUG] [httpcore._trace:87]: start_tls.started ssl_context=<ssl.SSLContext object at 0x7f2896815950> server_hostname='tg.yswl.cf' timeout=5.0
[2026-07-30 08:22:15.976] [Core] [DBUG] [httpcore._trace:87]: start_tls.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f28a63d13a0>
[2026-07-30 08:22:15.977] [Core] [DBUG] [httpcore._trace:87]: send_request_headers.started request=<Request [b'POST']>
[2026-07-30 08:22:15.977] [Core] [DBUG] [httpcore._trace:87]: send_request_headers.complete
[2026-07-30 08:22:15.977] [Core] [DBUG] [httpcore._trace:87]: send_request_body.started request=<Request [b'POST']>
[2026-07-30 08:22:15.978] [Core] [DBUG] [httpcore._trace:87]: send_request_body.complete
[2026-07-30 08:22:15.978] [Core] [DBUG] [httpcore._trace:87]: receive_response_headers.started request=<Request [b'POST']>
[2026-07-30 08:22:17.746] [Core] [DBUG] [httpcore._trace:87]: receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Thu, 30 Jul 2026 00:22:17 GMT'), (b'Content-Type', b'application/json'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'CF-Ray', b'a230353e5bfcec08-SEA'), (b'CF-Cache-Status', b'DYNAMIC'), (b'Access-Control-Allow-Origin', b'
'), (b'Server', b'cloudflare'), (b'Strict-Transport-Security', b'max-age=31536000; includeSubDomains; preload'), (b'access-control-allow-methods', b'GET, POST, OPTIONS'), (b'access-control-expose-headers', b'Content-Length,Content-Type,Date,Server,Connection'), (b'Report-To', b'{"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=aSLuCwzyK7K9TMNtnwHOal2mzFWXogw7Dh2REylHVAFfRivSYBUMFAgo43Mitj3K7HJrugkrBkByM7Njj0SfXwHFmBdjNFTODj3f%2BkYs%2BXnHj9SgqTu3sJ73zzGs"}]}'), (b'Nel', b'{"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}'), (b'Content-Encoding', b'gzip'), (b'alt-svc', b'h3=":443"; ma=86400')])
[2026-07-30 08:22:17.747] [Core] [INFO] [httpx._client:1740]: HTTP Request: POST https://tg.yswl.cf/bot8637326337:AAFxfJRuFVkWL124zJAKjHWWzNK_uMm5qbQ/getFile "HTTP/1.1 200 OK"
[2026-07-30 08:22:17.747] [Core] [DBUG] [httpcore._trace:87]: receive_response_body.started request=<Request [b'POST']>
[2026-07-30 08:22:17.747] [Core] [DBUG] [httpcore._trace:87]: receive_response_body.complete
[2026-07-30 08:22:17.747] [Core] [DBUG] [httpcore._trace:87]: response_closed.started
[2026-07-30 08:22:17.748] [Core] [DBUG] [httpcore._trace:87]: response_closed.complete
[2026-07-30 08:22:17.748] [Core] [DBUG] [telegram._bot:749]: Call to Bot API endpoint getFile finished with return value {'file_id': 'BQACAgUAAxkBAALkSGpobntIVSl_AmgXfai8l0HrFKBAAAL4IAAC4NdIV40kFtbJSdAmPQQ', 'file_unique_id': 'AgAD-CAAAuDXSFc', 'file_size': 13410, 'file_path': 'documents/file_220.js'}
[2026-07-30 08:22:17.749] [Core] [INFO] [core.event_bus:74]: [doro] [doro(telegram)] Unknown/641981595: [ComponentType.File] 📥 脚本下载成功

脚本名称: wxcode模块
脚本类型: 💬 分享脚本
[2026-07-30 08:22:17.749] [Core] [DBUG] [waking_check.stage:161]: enabled_plugins_name: ['*']
[2026-07-30 08:22:17.754] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_splitter - on_message
[2026-07-30 08:22:17.754] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_continuous_message - handle_private_msg
[2026-07-30 08:22:17.755] [astrbot_plugin_continuous_message] [INFO] [astrbot_plugin_continuous_message.main:282]: [消息防抖动] 开始收集 - 用户: doro:FriendMessage:641981595
[2026-07-30 08:22:20.756] [astrbot_plugin_continuous_message] [DBUG] [astrbot_plugin_continuous_message.link_parser_adapter:96]: [link_parser] skipped because disabled: No module named 'bilibili_api'
[2026-07-30 08:22:20.756] [astrbot_plugin_continuous_message] [INFO] [astrbot_plugin_continuous_message.main:303]: [消息防抖动] 结算触发 - 共 1 条 -> 发送
[2026-07-30 08:22:20.757] [astrbot_plugin_continuous_message] [INFO] [astrbot_plugin_continuous_message.main:304]: [消息防抖动] 图片统计 | 原图数量: 0 | 解析追加图数量: 0
[2026-07-30 08:22:20.757] [astrbot_plugin_continuous_message] [INFO] [astrbot_plugin_continuous_message.main:307]: [消息防抖动] 合并后的完整消息:
📥 脚本下载成功

脚本名称: wxcode模块
脚本类型: 💬 分享脚本
[2026-07-30 08:22:20.757] [Core] [DBUG] [method.star_request:46]: plugin -> meme_manager - handle_upload_image
[2026-07-30 08:22:20.758] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_shopping_assistant - auto_convert_private_message
[2026-07-30 08:22:20.758] [astrbot_plugin_shopping_assistant] [INFO] [astrbot_plugin_shopping_assistant.main:267]: [shopping_assistant] auto_convert_private_message private=True looks_like=False message_type='' umo='doro:FriendMessage:641981595' text='📥 脚本下载成功 脚本名称: wxcode模块 脚本类型: 💬 分享脚本'

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