Skip to content

Complete Bot API 10.0 Guest Mode: SentGuestMessage, answer_guest_query, filter#5234

Merged
Poolitzer merged 4 commits into
python-telegram-bot:api-10.0-guestfrom
Phil9l:guest-mode
May 19, 2026
Merged

Complete Bot API 10.0 Guest Mode: SentGuestMessage, answer_guest_query, filter#5234
Poolitzer merged 4 commits into
python-telegram-bot:api-10.0-guestfrom
Phil9l:guest-mode

Conversation

@Phil9l
Copy link
Copy Markdown

@Phil9l Phil9l commented May 18, 2026

Builds on top of the existing WIP commit on api-10.0-guest (a7ff5fb "Almost everything in guest mode") and adds the remaining pieces needed to fully cover Bot API 10.0 Guest Mode. Closes #5228.

Summary

  • Add telegram.SentGuestMessage (return type of answerGuestQuery).
  • Add Bot.answer_guest_query with the answerGuestQuery camelCase alias, plus the rate-limited wrapper on ExtBot.
  • Add telegram.ext.filters.UpdateType.GUEST_MESSAGE and include update.guest_message in UpdateType.ALL.
  • Add docs page (docs/source/telegram.sentguestmessage.rst) and register in the toctree.
  • Add a chango fragment closing Full Support for Bot API 10.0 #5228.
  • Add unit tests for the new class, the new bot method and the new filter (plus a SentGuestMessage entry in tests/auxil/dummy_objects.py).

The pre-existing types (Update.guest_message, Message.is_guest, User.is_guest, related constants) and registered allowed-update string were already added by @Poolitzer in a7ff5fb — this PR layers the missing surface on top so the API is end-to-end usable.

Test plan

  • pytest tests/test_sentguestmessage.py — passes.
  • pytest tests/test_bot.py -k "test_answer_guest_query or test_answer_web_app_query" — passes.
  • pytest tests/ext/test_filters.py -k "test_update_type_guest_message" — passes.
  • Combined sweep pytest tests/test_bot.py tests/test_sentguestmessage.py tests/ext/test_filters.py tests/test_official/ — 2020 passed; only failures are pre-existing flaky integration tests hitting flood-control on the real Bot API (unrelated to this change).
  • Reviewer to update uid = "PR_NUMBER" in changes/unreleased/5228.*.toml to this PR's number before merging.

Phil9l added 2 commits May 18, 2026 11:54
…SAGE filter

Completes Bot API 10.0 Guest Mode support on top of the WIP commit in
api-10.0-guest by introducing the missing pieces:

- `telegram.SentGuestMessage` for the answerGuestQuery return type.
- `telegram.Bot.answer_guest_query` (+ `answerGuestQuery` camelCase alias)
  and the rate-limited wrapper on `telegram.ext.ExtBot`.
- `telegram.ext.filters.UpdateType.GUEST_MESSAGE` and inclusion of
  `update.guest_message` in `UpdateType.ALL`.
- Docs entry and chango fragment closing python-telegram-bot#5228.
- Unit tests for the new class, bot method and filter, plus a dummy
  entry in `tests/auxil/dummy_objects.py`.
Copy link
Copy Markdown
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The changes themselves look quite good, just a few more touchups needed.

Can you also fix the failing tests?

Comment thread src/telegram/_bot.py Outdated
Comment thread src/telegram/_sentguestmessage.py Outdated
Comment thread tests/ext/test_filters.py
Comment thread tests/test_bot.py
… test, revert channel_post in effective_user

- Rename changes/unreleased/5228.*.toml -> 5234.*.toml so the chango action recognizes it (file must be named after the PR number).
- Exclude guest_bot_caller_chat, guest_bot_caller_user, and guest_query_id from is_type_attribute since these are metadata, not message types.
- Remove channel_post from the effective_user chain in Update; the api-10.0-central baseline did not include it and adding it regressed test_messagehandler::test_context.
@Phil9l
Copy link
Copy Markdown
Author

Phil9l commented May 19, 2026

Pushed 61625f0 to address the failing CI checks:

  • Renamed changes/unreleased/5228.*.toml5234.*.toml so the chango action stops complaining (filenames need to be the PR number).
  • Added guest_bot_caller_chat, guest_bot_caller_user, guest_query_id to is_type_attribute's exclusion set in tests/test_constants.py since they are metadata, not message types (analogous to is_accessible, via_bot, etc.).
  • Reverted or self.channel_post from the effective_user chain in _update.py. The api-10.0-central baseline did not have channel_post in that chain, and adding it in a7ff5fb was an inadvertent behavior change that broke tests/ext/test_messagehandler.py::TestMessageHandler::test_context. With that line removed the test passes again.

The remaining check-conformity failures (BotAccessSettings, InputMediaLivePhoto, InputMediaLocation, InputMediaSticker, InputMediaVenue, InputPaidMediaLivePhoto, InputPollMedia, InputPollOptionMedia, LivePhoto, PaidMediaLivePhoto, PollMedia) are unrelated Bot API 10.0 types missing from api-10.0-central; happy to defer those to the central branch work.

- Shorten SentGuestMessage class docstring
- Shorten Bot.answer_guest_query method docstring
- Assert GUEST_MESSAGE filter is False in other UpdateType filter tests
- Add test_answer_guest_query_defaults modeled on the web_app_query variant
@Phil9l
Copy link
Copy Markdown
Author

Phil9l commented May 19, 2026

Thanks for the PR! The changes themselves look quite good, just a few more touchups needed.

Can you also fix the failing tests?

Hi, thank you! I addressed your comments, but some tests are still failing, even in master, without this change. Anything I should do about them?

Copy link
Copy Markdown
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick changes! You don't need to worry about the failing tests on master, everything looks good now.

@harshil21 harshil21 requested review from Poolitzer and aelkheir May 19, 2026 08:26
@harshil21 harshil21 added the ⚙️ bot-api affected functionality: bot-api label May 19, 2026
Copy link
Copy Markdown
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM nice work

@Poolitzer Poolitzer merged commit 532e897 into python-telegram-bot:api-10.0-guest May 19, 2026
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️ bot-api affected functionality: bot-api

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants