set_chat_guard_bot()

Client.set_chat_guard_bot()

Set or remove a guard bot for a channel or supergroup.

The guard bot screens join requests before approval.

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

  • bot (int | str | None) – Unique identifier (int) or username (str) of the bot to set as guard. Pass None to remove the guard bot (disables join request screening).

  • apply_to_invites (bool, optional) – Pass True to also apply guard bot screening to invite link joins. Defaults to False.

Returns:

bool – True on success.

Example

# Set a guard bot
await app.set_chat_guard_bot(chat_id, "@myguardbot")

# Set guard bot and apply to invite links too
await app.set_chat_guard_bot(chat_id, "@myguardbot", apply_to_invites=True)

# Remove guard bot
await app.set_chat_guard_bot(chat_id, None)