Перейти к содержанию

GetPinnedMessage

GetPinnedMessage(bot, chat_id)

Bases: BaseConnection

Класс для получения закреплённого сообщения в указанном чате.

https://dev.max.ru/docs-api/methods/GET/chats/-chatId-/pin

Attributes:

Name Type Description
bot Bot

Экземпляр бота для выполнения запроса.

chat_id int

Идентификатор чата.

Source code in maxapi/methods/get_pinned_message.py
def __init__(
    self,
    bot: "Bot",
    chat_id: int,
):
    self.bot = bot
    self.chat_id = chat_id

fetch() async

Выполняет GET-запрос для получения закреплённого сообщения.

Returns:

Name Type Description
GettedPin GettedPin

Объект с информацией о закреплённом сообщении.

Source code in maxapi/methods/get_pinned_message.py
async def fetch(self) -> GettedPin:
    """
    Выполняет GET-запрос для получения закреплённого сообщения.

    Returns:
        GettedPin: Объект с информацией о закреплённом сообщении.
    """

    bot = self._ensure_bot()

    response = await super().request(
        method=HTTPMethod.GET,
        path=ApiPath.CHATS + "/" + str(self.chat_id) + ApiPath.PIN,
        model=GettedPin,
        params=bot.params,
    )

    return cast(GettedPin, response)