KurimuzonAkuma / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
268 stars 72 forks source link

Error on get_chat caused by pinned messages #44

Open barbamento opened 3 months ago

barbamento commented 3 months ago

Checklist

Description

I found a single chat where the pinned messages has, for some reason unknown to me, a wrong id.

The problem is that, for that reason I'm unable to interact with the chat. It is possible to use a try except block for the pinned message retrieval?

Steps to reproduce

I simply get this error using the get chat on a chat called "vezzoblog". Up until now it's the only chat i had this problem

Code example

from pyrogram import Client

app=Client(...)

with app:
        app.get_chat("vezzoblog")

Logs

Traceback (most recent call last):
  File "mydir/test_pyrogram.py", line 56, in <module>
    app.get_chat("vezzoblog")
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/sync.py", line 66, in async_to_sync_wrap
    return loop.run_until_complete(coroutine)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/methods/chats/get_chat.py", line 87, in get_chat
    return await types.Chat._parse_full(self, r)
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/types/user_and_chats/chat.py", line 511, in _parse_full
    parsed_chat.pinned_message = await client.get_messages(
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/methods/messages/get_messages.py", line 117, in get_messages
    messages = await utils.parse_messages(self, r, replies=replies)
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/utils.py", line 155, in parse_messages
    reply_messages = await client.get_messages(
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/methods/messages/get_messages.py", line 115, in get_messages
    r = await self.invoke(rpc, sleep_threshold=-1)
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/methods/advanced/invoke.py", line 94, in invoke
    r = await session.invoke(
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/session/session.py", line 399, in invoke
    return await self.send(query, timeout=timeout)
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/session/session.py", line 367, in send
    RPCError.raise_it(result, type(data))
  File "/.cache/pypoetry/virtualenvs/envname/lib/python3.10/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
    raise getattr(
pyrogram.errors.exceptions.bad_request_400.MessageIdsEmpty: Telegram says: [400 MESSAGE_IDS_EMPTY] - The requested message doesn't exist or you provided no message id (caused by "channels.GetMessages")