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
321 stars 90 forks source link

flooding error not supported for getStoriesById #63

Closed barbamento closed 3 months ago

barbamento commented 4 months ago

Checklist

Description

I am downloading all the messages from a chat and i get this error. I think it's just missing an error handling on getSetoriesById

Steps to reproduce

I get this error using the get_chat_history method on a couple of chats. You can try on "BlogBeloso" to test this

Code example

from pyrogram import Client

app=Client(...)

with app:
    c=app.get_chat("BlogBeloso")
    for m in app.get_chat_history(c.id):
        print(m)

Logs

Traceback (most recent call last):
  File "/codedir/file1.py", line 79, in download_chat
    ) = await c.dump_all_messages_from_chat(
  File "/codedir/file2.py", line 92, in dump_all_messages_from_chat
    async for m in app.get_chat_history(target_id):
  File "/envdir/lib/python3.10/site-packages/pyrogram/methods/messages/get_chat_history.py", line 111, in get_chat_history
    messages = await get_chunk(
  File "/envdir/lib/python3.10/site-packages/pyrogram/methods/messages/get_chat_history.py", line 51, in get_chunk
    return await utils.parse_messages(client, messages, replies=0)
  File "/envdir/lib/python3.10/site-packages/pyrogram/utils.py", line 111, in parse_messages
    await types.Message._parse(
  File "/envdir/lib/python3.10/site-packages/pyrogram/types/messages_and_media/message.py", line 931, in _parse
    story = await client.get_stories(utils.get_peer_id(media.peer), media.id)
  File "/envdir/lib/python3.10/site-packages/pyrogram/methods/stories/get_stories.py", line 63, in get_stories
    r = await self.invoke(
  File "/envdir/lib/python3.10/site-packages/pyrogram/methods/advanced/invoke.py", line 94, in invoke
    r = await session.invoke(
  File "/envdir/lib/python3.10/site-packages/pyrogram/session/session.py", line 399, in invoke
    return await self.send(query, timeout=timeout)
  File "/envdir/lib/python3.10/site-packages/pyrogram/session/session.py", line 367, in send
    RPCError.raise_it(result, type(data))
  File "/envdir/lib/python3.10/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
    raise getattr(
pyrogram.errors.exceptions.flood_420.FloodWait: Telegram says: [420 FLOOD_WAIT_X] - A wait of 41 seconds is required (caused by "stories.GetStoriesByID")