answer_guard_bot_query()

Client.answer_guard_bot_query()

Answer a guard bot query received via GuardBotQuery.

Guard bots receive GuardBotQuery updates when a user requests to join a channel/supergroup protected by the bot. Every query must be answered.

Usable by Users Bots
Parameters:
  • query_id (int) – Unique identifier of the query to answer.

  • action (str) – Decision for the join request. One of:

    • "approve" — approve the user immediately.

    • "decline" — reject the join request.

    • "queue" — hold the request for later review.

    • "web_view" — open a WebApp for the user (requires url).

  • url (str, optional) – HTTPS URL of the WebApp to open for the user. Required when action="web_view".

Raises:

ValueError – On unknown action or missing url for web_view.

Example

# Approve
await app.answer_guard_bot_query(query.query_id, "approve")

# Decline
await app.answer_guard_bot_query(query.query_id, "decline")

# Show captcha WebApp
await app.answer_guard_bot_query(
    query.query_id,
    "web_view",
    url="https://example.com/captcha"
)