-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Is your feature request related to a problem? Please describe.
TG requires pagination for inline results using the next_offset parameter. Currently this has to be implemented manually, but the logic is always the same, so it's basically copy paste.
I think it would fit well into PTBs "more than just a wrapper" credo to provide a convenience method for that.
Describe the solution you'd like
Add a parameters pagination and current_offset to answer_inline_query to make PTB take care of that automically. it should be along the lines
offset = current_offset
max_length = 50
next_offset = None
if not offset:
if len(results) > max_length :
next_offset = len(results) - max_length
next_offset = next_offset or None
results = results[:max_length]
elif len(results) > offset:
results = results[offset:offset + max_length]
if len(results) > offset + max_length:
next_offset = offset + max_length
else:
next_offset = ''Describe alternatives you've considered
If we don't want to integrate this directly into answer_inline_query, we could at least add a function to utils.helpers , along the lines
def paginate_inline_results(reslts: List[InlineQueryResult], current_offset: int) -> {'results': …, 'next_offset': …}so one could call it like
answer_inline_query(**paginate_inline_results(results, offset), …)Metadata
Metadata
Assignees
Labels
No labels