We are developing a Telegram bot using the grammy library and have encountered an issue: when attempting to send GIF files using the sendAnimation method from the grammy documentation, they are being sent and displayed as videos in Telegram, instead of animations.
We have verified that the files are indeed in GIF format. Could anyone suggest a solution or explain why this is happening? Perhaps someone has faced a similar issue.
Link to grammy documentation: Grammy Documentation
async function sendChallengeAnimation(
ctx: CommandContext<Context>
): Promise<void> {
const randomAnimationNumber =
Math.floor(Math.random() * challengeAnimationsCount) + 1
const video = InputMediaBuilder.video(
new InputFile(`media/challenge/${randomAnimationNumber}.gif`)
)
await ctx.replyWithMediaGroup([video])
}
This question gets at functions relying on more of the Telegram rather than the Grammy side and docs can be found here.
In addition to the
Photo,Video,MediaGroupand other media types in Telegram, there is also theAnimationtype. Try substitutingMediaGroupforAnimation.If that doesn't work or you need the MediaGroup type, try substituting the
videoinInputMediaBuilder.videoforanimation.Here's some more relevant docs for that last bit.