Skip to content

Instantly share code, notes, and snippets.

@agasiev
Created March 28, 2018 13:02
Show Gist options
  • Save agasiev/496d001b73592cc3efaca37391cbe053 to your computer and use it in GitHub Desktop.
Save agasiev/496d001b73592cc3efaca37391cbe053 to your computer and use it in GitHub Desktop.
pages = [x.strip() for x in texts.get('register.start_welcome').split('--break--')]
if page_id < 0:
page_id = 0
if page_id >= len(pages):
page_id = len(pages) - 1
if page_id == 0 or from_scratch:
if page_id != len(pages) - 1:
button_list = [[InlineKeyboardButton(texts.get('button.next'),
callback_data='register-button.next-{}'.format(
page_id + 1
))]]
else:
button_list = [[]]
else:
button_list = [
[
InlineKeyboardButton(texts.get('button.back'),
callback_data='register-button.back-{}'.format(
page_id - 1
)),
]
]
if page_id != len(pages) - 1:
button_list[0].append(InlineKeyboardButton(texts.get('button.next'),
callback_data='register-button.next-{}'.format(
page_id + 1
)))
if page_id == len(pages) - 1:
button_list.append([
InlineKeyboardButton(texts.get('button.register'), callback_data='register-button.register')
])
reply_markup = InlineKeyboardMarkup(button_list)
if from_scratch:
update.message.reply_text(pages[0],
reply_markup=ReplyKeyboardRemove(),
parse_mode="Markdown")
update.message.edit_message_reply_markup(
reply_markup=reply_markup,
parse_mode="Markdown")
else:
update.message.edit_text(pages[page_id],
reply_markup=reply_markup,
parse_mode="Markdown")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment