fix(telegram): use static thumbnail for animated stickers - #9610
Merged
Soulter merged 1 commit intoAug 10, 2026
Conversation
Soulter
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Animated Telegram stickers never reach the model as images: ask what a sticker shows and the model describes the emoji it is tagged with rather than the artwork. The sticker branch in
convert_message()does not distinguish sticker types, always callingsticker.get_file()and wrapping the result inComp.Image, but an animated sticker's payload is.tgs(gzipped Lottie JSON) or.webm, neither of which is a bitmap.ensure_jpeg()in the preprocess stage therefore throws atPIL.Image.open()and the component stays on the message chain unchanged; the provider side then fails to detect a MIME type when converting it to base64 and drops the entry. Animated stickers are common on Telegram, so any feature that needs to read the artwork fails.The Bot API already ships a static thumbnail for these stickers,
Sticker.thumbnail, in.WEBPor.JPG. Reading that gives us the artwork and avoids adding a new dependency.Modifications / 改动点
astrbot/core/platform/sources/telegram/tg_adapter.py:is_animatedoris_videois set, readsticker.thumbnail.get_file()instead. Static stickers keep usingsticker.get_file()and behave exactly as before.thumbnailno longer appends aComp.Image.tests/test_telegram_adapter.py: four new cases covering static stickers still using the sticker's own file,is_animatedandis_videoeach switching to the thumbnail, and a missing thumbnail producing noComp.Imagewhile the text component survives.Screenshots or Test Results / 运行截图或测试结果
Before the fix
The sticker carries a
thumbnail, but the.tgspayload is what gets fetched. AnImagecomponent does reach the chain ([图片]in the log below), and it fails twice: once in the preprocess stage, once on the provider side. The request fired when the sticker arrived carries no IMAGE entry.Asked to describe the sticker, the model answers "a clenched fist with the thumb pointing up" — the shape of the Unicode 👍, not the duck the sticker actually shows.Log (before)
After the fix
Same sticker (
file_unique_idmatches the run above), both warnings gone, and the thumbnail makes it into the request. The comparison is limited to the request fired when the sticker arrived: the TEXT token count is identical (3342) and the only difference is the addedIMAGE: 1089. Asked the same question, the model now describes the picture: a round cartoon duck whose right wing is drawn as an oversized thumbs-up.Log (after)
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Handle Telegram animated/video stickers using their static thumbnails so sticker artwork reaches image-aware features without errors.
Bug Fixes:
Tests: