def send_settings_message(context): """Edit the message of the current context to the settings menu.""" context.query.message.edit_text( text=get_settings_text(context.poll), parse_mode="markdown", reply_markup=get_settings_keyboard(context.poll), disable_web_page_preview=True, )
def show_settings(session, context, poll): """Show the settings tab.""" text = get_settings_text(poll) keyboard = get_settings_keyboard(poll) context.query.message.edit_text( text, parse_mode="markdown", reply_markup=keyboard, disable_web_page_preview=True, ) poll.in_settings = True
def go_back(session, context, poll): """Go back to the original step.""" if context.callback_result == CallbackResult.main_menu: text = get_poll_text(session, poll) keyboard = get_management_keyboard(poll) poll.in_settings = False elif context.callback_result == CallbackResult.settings: text = get_settings_text(poll) keyboard = get_settings_keyboard(poll) context.query.message.edit_text( text, parse_mode="markdown", reply_markup=keyboard, disable_web_page_preview=True, ) # Reset the expected input from the previous option context.user.expected_input = None
def handle_new_option(bot, update, session, user, text, poll, chat): """Add a new option after poll creation.""" added_options = add_options_multiline(session, poll, text) if len(added_options) > 0: text = i18n.t("creation.option.multiple_added", locale=user.locale) + "\n" for option in added_options: text += f"\n*{option}*" chat.send_message(text, parse_mode="markdown") else: chat.send_message(i18n.t("creation.option.no_new", locale=user.locale)) # Reset expected input user.current_poll = None user.expected_input = None text = get_settings_text(poll) keyboard = get_settings_keyboard(poll) message = chat.send_message( text, parse_mode="markdown", reply_markup=keyboard, ) remove_old_references(session, bot, poll, user) # Create new reference reference = Reference(poll, ReferenceType.admin.name, user=user, message_id=message.message_id) session.add(reference) session.commit() update_poll_messages(session, bot, poll, message.message_id, user)