Ejemplo n.º 1
0
def open_new_option_datepicker(session, context, poll):
    """Send a text and tell the user that we expect a new option."""
    context.query.message.edit_text(
        text=get_datepicker_text(poll),
        parse_mode='markdown',
        reply_markup=get_add_option_datepicker_keyboard(poll),
    )
Ejemplo n.º 2
0
def update_datepicker(context, poll):
    """Update the creation datepicker."""
    user = context.user
    if poll.created and poll.user != user:
        keyboard = get_external_datepicker_keyboard(context.poll)
    elif poll.created and poll.user == user:
        if poll.user.expected_input == ExpectedInput.due_date.name:
            context.query.message.edit_reply_markup(
                reply_markup=get_due_date_datepicker_keyboard(context.poll))
            return
        else:
            keyboard = get_add_option_datepicker_keyboard(context.poll)
    elif not poll.created:
        keyboard = get_creation_datepicker_keyboard(context.poll)
    else:
        raise Exception('Unknown update constellation in datepicker')

    context.query.message.edit_text(get_datepicker_text(context.poll),
                                    parse_mode='markdown',
                                    reply_markup=keyboard)