pythonpyrogram

What does mean parameter offset in function get_inline_bot_results?


I cannot understand what parameter offset did in this function and what's kind of values accept? I try use integers but there is no effect.

from pyrogram import Client, filters
import time


app = Client(
    "my_account",
    api_id=api_id, api_hash=api_hash,
)


async def main():
    async with app:
        bot_results = await app.get_inline_bot_results(
            "some_bot_name",
            query="some_query",
            offset="???"
        )


app.run(main())

Solution

  • The documentation states:

    offset (str, optional) – Offset of the results to be returned.

    Which is not super helpful but from the Telegram Docs shows that it is used for pagination:

    offset - If the user scrolls past the first len(results) results, and next_offset field is set, the inline query should be repeated with this offset.

    Checking the string documentation and [this] GitHub issue, it seems that the offset should be a string of an int like: "0" or "100". Make sure the returned results' length is more than 1 and set the offset to "1".