GIF 使用格莱美库作为视频在 Telegram 中发送

问题描述 投票:0回答:1

我们正在使用

grammy
库开发 Telegram 机器人,但遇到了一个问题:当尝试使用
sendAnimation
文档中的
grammy
方法发送 GIF 文件时,它们在 Telegram 中被发送并显示为视频,而不是动画。

我们已经验证文件确实是GIF格式。谁能提出解决方案或解释为什么会发生这种情况?也许有人遇到过类似的问题。

格莱美文档链接:格莱美文档

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])
}
typescript telegram telegram-bot grammy
1个回答
0
投票

这个问题涉及更多依赖于 Telegram 而不是格莱美方面的功能,可以在here找到文档。

Telegram 中除了

Photo
Video
MediaGroup
等媒体类型外,还有
Animation
类型。尝试用
MediaGroup
代替
Animation

如果这不起作用或者您需要 MediaGroup 类型,请尝试将

video
中的
InputMediaBuilder.video
替换为
animation

这里还有一些与最后一点相关的文档。

© www.soinside.com 2019 - 2024. All rights reserved.