Example #1
0
def open_new_option_datepicker(session, context, poll):
    """Send a text and tell the user that we expect a new option."""
    keyboard = get_add_option_datepicker_keyboard(poll, date.today())
    context.query.message.edit_text(
        text=get_datepicker_text(poll),
        parse_mode="markdown",
        reply_markup=keyboard,
    )
Example #2
0
def update_datepicker(context, poll, datepicker_context, current_date):
    """Update the creation datepicker."""
    message = get_datepicker_text(context.poll)
    if datepicker_context == DatepickerContext.creation:
        keyboard = get_creation_datepicker_keyboard(poll, current_date)
    elif datepicker_context == DatepickerContext.additional_option:
        keyboard = get_add_option_datepicker_keyboard(poll, current_date)
    elif datepicker_context == DatepickerContext.external_add_option:
        keyboard = get_external_datepicker_keyboard(poll, current_date)
    elif datepicker_context == DatepickerContext.due_date:
        message = get_settings_text(poll)
        keyboard = get_due_date_datepicker_keyboard(poll, current_date)
    else:
        raise Exception('Unknown DatepickerContext')

    context.query.message.edit_text(message,
                                    parse_mode='markdown',
                                    reply_markup=keyboard,
                                    disable_web_page_preview=True)