feat(discord): add native send_animation for inline GIF playback#10272
Closed
sprmn24 wants to merge 1 commit into
Closed
feat(discord): add native send_animation for inline GIF playback#10272sprmn24 wants to merge 1 commit into
sprmn24 wants to merge 1 commit into
Conversation
Contributor
Contributor
Author
|
thanks, glad it was clean enough to cherry-pick directly 🙏 |
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.
What does this PR do?
Adds a
send_animationoverride to the Discord platform adapter so that animated GIFs are sent as native Discord file attachments and auto-play inline, instead of falling back tosend_image.Telegram already has this override. Discord's base class fallback sends GIFs through
send_image, which works but loses the animation context. Discord's CDN serves GIF attachments with the correct MIME type when the filename ends in.gif, triggering the client's native animation renderer. Without this override, GIFs sent viasend_imageare uploaded asimage.gifbut without the animation context path — this override ensures the file is explicitly namedanimation.gifand routed through the animation code path.Type of Change
Changes Made
send_animationmethod toDiscordPlatformingateway/platforms/discord.pyanimation_urlviaaiohttpusing the same proxy pattern assend_imagediscord.Filewithfilename="animation.gif"so Discord renders it as an auto-playing animationis_safe_urlbefore any network callsuper().send_animation()onImportErroror any exceptionHow to Test
https://media.giphy.com/media/3o7abKhOpu0NwenH3O/giphy.gif)Checklist
send_imagepattern exactly)send_image)