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

Get_chat_by_id

maxapi.methods.get_chat_by_id.GetChatById(bot, id)

Bases: BaseConnection

Класс для получения информации о чате по его идентификатору.

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

Attributes:

Name Type Description
bot Bot

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

id int

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

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

fetch() async

Выполняет GET-запрос для получения данных чата.

Returns:

Name Type Description
Chat Chat

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

Source code in maxapi/methods/get_chat_by_id.py
async def fetch(self) -> Chat:
    """
    Выполняет GET-запрос для получения данных чата.

    Returns:
        Chat: Объект чата с полной информацией.
    """

    bot = self._ensure_bot()

    response = await super().request(
        method=HTTPMethod.GET,
        path=ApiPath.CHATS.value + "/" + str(self.id),
        model=Chat,
        params=bot.params,
    )

    return cast(Chat, response)