Exemplo n.º 1
0
def handle_set_description(bot, update, session, user, text, poll, chat):
    """Set the description of the poll."""
    poll.description = text
    user.expected_input = ExpectedInput.options.name
    chat.send_message(i18n.t('creation.option.first', locale=user.locale),
                      reply_markup=get_open_datepicker_keyboard(poll),
                      parse_mode='markdown')
Exemplo n.º 2
0
def skip_description(session, context, poll):
    """Skip description creation step."""
    context.user.expected_input = ExpectedInput.options.name
    session.commit()
    context.query.message.edit_text(
        i18n.t('creation.option.first', locale=context.user.locale),
        reply_markup=get_open_datepicker_keyboard(poll))
Exemplo n.º 3
0
def skip_description(session, context, poll):
    """Skip description creation step."""
    if len(poll.options) == 0:
        context.user.expected_input = ExpectedInput.options.name
        session.commit()
        context.query.message.edit_text(
            i18n.t("creation.option.first", locale=context.user.locale),
            reply_markup=get_open_datepicker_keyboard(poll),
        )
    else:  # options were already prefilled e.g. by native poll
        # TODO: what if user changed poll type?
        create_poll(session, poll, context.user, context.tg_chat, context.query.message)
Exemplo n.º 4
0
def handle_set_description(bot, update, session, user, text, poll, chat):
    """Set the description of the poll."""
    poll.description = text

    if len(poll.options) == 0:
        user.expected_input = ExpectedInput.options.name
        chat.send_message(
            i18n.t("creation.option.first", locale=user.locale),
            reply_markup=get_open_datepicker_keyboard(poll),
            parse_mode="markdown",
        )
    else:  # options were already prefilled e.g. by native poll
        create_poll(session, poll, user, update.effective_chat)
Exemplo n.º 5
0
def close_creation_datepicker(session, context, poll):
    """Close the datepicker during the creation of a poll."""
    user = context.user
    if len(poll.options) == 0:
        text = i18n.t("creation.option.first", locale=user.locale)
        keyboard = get_open_datepicker_keyboard(poll)
    else:
        text = i18n.t("creation.option.next", locale=user.locale)
        keyboard = get_options_entered_keyboard(poll)

    message = context.query.message
    # Replace the message completely, since all options have already been entered
    if user.expected_input != ExpectedInput.date.name:
        message.edit_text(i18n.t("creation.option.finished", locale=user.locale))
        return

    user.expected_input = ExpectedInput.options.name
    message.edit_text(text, parse_mode="markdown", reply_markup=keyboard)