From 47300c0fb6d65e46206833fd828ca93399031a7c Mon Sep 17 00:00:00 2001 From: xlf1024 <33392024+xlf1024@users.noreply.github.com> Date: Wed, 21 Mar 2018 22:17:41 +0100 Subject: [PATCH 1/2] Update bot.py --- bot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index cdd2ae48..aa87d4bf 100644 --- a/bot.py +++ b/bot.py @@ -635,9 +635,11 @@ def reply_to_query(bot, update): if players and game and len(players) > 1: switch = _('Current game: {game}').format(game=game.chat.title) - + + offset = int(update.inline_query.offset) if update.inline_query.offset != None and update.inline_query.offset.isnumeric() else 0 + results = results[offset : offset+42] answer_async(bot, update.inline_query.id, results, cache_time=0, - switch_pm_text=switch, switch_pm_parameter='select') + switch_pm_text=switch, switch_pm_parameter='select', next_offset=str(offset+42)) @game_locales From bb41fa4e46369ff046dac0cc4178aba8453fb64e Mon Sep 17 00:00:00 2001 From: xlf1024 <33392024+xlf1024@users.noreply.github.com> Date: Wed, 21 Mar 2018 22:24:28 +0100 Subject: [PATCH 2/2] Update bot.py --- bot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index aa87d4bf..aa052ca8 100644 --- a/bot.py +++ b/bot.py @@ -636,10 +636,13 @@ def reply_to_query(bot, update): if players and game and len(players) > 1: switch = _('Current game: {game}').format(game=game.chat.title) + # Pagination. This is necessary as the Telegram servers discard inline query answers with more than 50 entries. offset = int(update.inline_query.offset) if update.inline_query.offset != None and update.inline_query.offset.isnumeric() else 0 - results = results[offset : offset+42] + next_offset = offset + 42 + results = results[offset : next_offset] + answer_async(bot, update.inline_query.id, results, cache_time=0, - switch_pm_text=switch, switch_pm_parameter='select', next_offset=str(offset+42)) + switch_pm_text=switch, switch_pm_parameter='select', next_offset=str(next_offset)) @game_locales