grammyjs / grammY

The Telegram Bot Framework.
https://grammy.dev
MIT License
2.24k stars 112 forks source link

feat: ctx.message.message_thread_id presumably should not be | undefined in message:is_topic_message #569

Closed mordv closed 5 months ago

mordv commented 5 months ago

I might be mistaken, or my IDE misleading me, but I think message_thread_id should not be undefined in this scenario.

Screenshot 2024-05-07 at 23 55 12

Should it also infer correct type without specifying chatType('supergroup') explicitly, since is_topic_message is only available in supergroup?

KnorpelSenf commented 5 months ago

You're right.

These things don't happen automatically. Every such case has to be programmed manually. We can do this easily.

Note to self: We can define a same-level twin type on L2 for is_topic_message: message_thread_id.

KnorpelSenf commented 5 months ago

Simply needs to be added to https://github.com/grammyjs/grammY/blob/f1950b30d4d7bfd28f4d7521365ef10db3cb8899/src/filter.ts#L717

KnorpelSenf commented 5 months ago

While we're at it, we can make sure that caption entities ensure the existence of a caption

KnorpelSenf commented 5 months ago

@mordv I have implemented this in #573. Can you try out the changes and let me know if they work for you? If they do, please approve the pull request.

KnorpelSenf commented 5 months ago

@all-contributors add @mordv for this idea!

allcontributors[bot] commented 5 months ago

@KnorpelSenf

I've put up a pull request to add @mordv! :tada: