KnorpelSenf / typegram

TypeScript types for the entire Telegram Bot API
MIT License
122 stars 3 forks source link

Audio message not extending MediaMessage #30

Closed ciricc closed 2 years ago

ciricc commented 2 years ago

Telegram supports audio media group messages, but telegraf type doesn't.

bot.on("channel_post", (ctx) => {
    if ("media_group_id" in ctx.channelPost) {
        if ("audio" in ctx.channelPost) {
            console.log(ctx.channelPost) // never type
        }
    }
})
KnorpelSenf commented 2 years ago

I assume this applies to document messages likewise. Can you confirm this?

Both message types should extend media messages rather than captionable messages. This mistake was made when Telegram started to allow more message types in albums.

ciricc commented 2 years ago

I mean audio file media group message

image

It looks like this

image

Or with caption like this

image

https://core.telegram.org/bots/api#inputmediaaudio

KnorpelSenf commented 2 years ago

I understood that. The question is if you have the same problem with document messages, such as PDF files. I believe those messages are affected by the same bug. Can you confirm this?

EdJoPaTo commented 2 years ago

the API states Audio, Document, Photo and Video should work there. https://core.telegram.org/bots/api#sendmediagroup

Interestingly InputMediaAnimation also exists as a possible InputMedia but looks like it isnt working for sendMediaGroup.

KnorpelSenf commented 2 years ago

That's correct. InputMedia is also used in https://core.telegram.org/bots/api#editmessagemedia and that's where you can specify InputMediaAnimation.

ciricc commented 2 years ago

Sorry, i didn't understand. Yes, this bug reproduces also with documents. Documents also can be sent in media group.

KnorpelSenf commented 2 years ago

Alrighty, then I know how to fix this. Thanks for testing it. Will push a patch release tomorrow.