pyrogram icon indicating copy to clipboard operation
pyrogram copied to clipboard

Infinite iteration for "get_chat_history" with negative offset

Open slavnycoder opened this issue 3 years ago • 0 comments

Checklist

  • [X] I am sure the error is coming from Pyrogram's code and not elsewhere
  • [X] I have searched in the issue tracker for similar bug reports, including closed ones
  • [X] I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

When i set offset -1 i get infinite iteration with timeout at the end. First message repeats infinitly.

Steps to reproduce

  1. Create test chat
  2. Get chat history with negative offset

Code example

async def main():
    async with app:
        message: types.Message
        async for message in app.get_chat_history(TEST_CHAT_ID, offset=-1):
            print(message.date)

Logs

(.venv) PS C:\src\convyfeed> python.exe .\main.py
2022-09-16 19:39:25
2022-09-16 19:39:15
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
2022-09-16 19:38:45
[convyfeed] Waiting for 28 seconds before continuing (required by "messages.GetHistory")

slavnycoder avatar Sep 16 '22 17:09 slavnycoder