Search code examples
pythonpython-3.xtelegramtelegram-botpy-telegram-bot-api

How to get all the pinned messages in a telegram chat using pytelegrambotapi?


I'm trying to retrieve all the pinned messages in telegram chat for my bot. From the following code

prev_message = bot.get_chat(chat_id).pinned_message.text

I am able to retrieve the recent pinned messages. Is there a way to obtain all of the pinned messages as an array?. I'm using pytelegrambotapi for writing my bot.


Solution

  • According to official telegram bot api docs, in chat.pinned_message there is only the the last pinned message.

    The most recent pinned message (by sending date). Returned only in getChat.

    Source: https://core.telegram.org/bots/api#chat

    So, since pyTelegramBotApi uses these http apis, I don't think you can get all the pinned messages.