grammyjs / grammY

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

fix: `ctx.chat` for callback queries #555

Closed KnorpelSenf closed 4 months ago

KnorpelSenf commented 5 months ago

Potential fix for https://t.me/grammyjs/228143

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 45.78%. Comparing base (4cb8e68) to head (aadc45e). Report is 2 commits behind head on main.

:exclamation: Current head aadc45e differs from pull request most recent head 25529fa. Consider uploading reports for the commit 25529fa to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #555 +/- ## ========================================== - Coverage 46.43% 45.78% -0.65% ========================================== Files 19 19 Lines 6121 5139 -982 Branches 330 331 +1 ========================================== - Hits 2842 2353 -489 + Misses 3276 2784 -492 + Partials 3 2 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

KnightNiwrem commented 5 months ago

To also fix in another PQ with similar "patterns" of code:

msgId: [Shortcuts<U>["msg"]] extends [object] ? number

Screenshot 2024-04-09 at 12 42 17 PM Screenshot 2024-04-09 at 12 50 11 PM Screenshot 2024-04-09 at 12 50 49 PM

businessConnectionId: [Shortcuts<U>["msg"]] extends [object] ? string | undefined

Screenshot 2024-04-09 at 12 44 24 PM

: [U["business_connection"]] extends [object] ? [U["business_connection"]["id"]]

Screenshot 2024-04-09 at 12 48 35 PM

: [U["deleted_business_messages"]] extends [object] ? [U["deleted_business_messages"]["business_connection_id"]]

Screenshot 2024-04-09 at 12 55 23 PM
KnorpelSenf commented 5 months ago

Right, I'll fix those

KnightNiwrem commented 4 months ago

All fixes for https://github.com/grammyjs/grammY/pull/555#issuecomment-2044140513 has been verified.

Some regression bugs have surfaced.

Screenshot 2024-04-20 at 3 14 44 PM Screenshot 2024-04-20 at 3 14 38 PM Screenshot 2024-04-20 at 3 11 26 PM
KnorpelSenf commented 4 months ago

All fixes for #555 (comment) has been verified.

Awesome!

Some regression bugs have surfaced. Screenshot 2024-04-20 at 3 14 44 PM Screenshot 2024-04-20 at 3 14 38 PM

Those two are invalid. There is no such field as id on a message, so the error is correct. You might have meant message_id which works correctly.

Screenshot 2024-04-20 at 3 11 26 PM

I cannot reproduce this. For me, ctx.chat is Chat | undefined which is correct. image_2024-05-06_21-24-29