aiogram.api.methods.set_chat_permissions

aiogram/api/methods/set_chat_permissions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Dict, Union

from ..types import ChatPermissions
from .base import Request, TelegramMethod

if TYPE_CHECKING:  # pragma: no cover
    from ..client.bot import Bot


class SetChatPermissions(TelegramMethod[bool]):
    """
    Use this method to set default chat permissions for all members. The bot must be an
    administrator in the group or a supergroup for this to work and must have the
    can_restrict_members admin rights. Returns True on success.

    Source: https://core.telegram.org/bots/api#setchatpermissions
    """

    __returning__ = bool

    chat_id: Union[int, str]
    """Unique identifier for the target chat or username of the target supergroup (in the format
    @supergroupusername)"""
    permissions: ChatPermissions
    """New default chat permissions"""

    def build_request(self, bot: Bot) -> Request:
        data: Dict[str, Any] = self.dict()

        return Request(method="setChatPermissions", data=data)