def ask_for_conclusion(update, context, highlight=None):
    ud = context.user_data
    query = update.callback_query
    ud['last_query'] = query
    epilog = ('Now I will send a message to people if you want' +
              ' to add a text message just send it to me. ' +
              'Press confirm when you\'re ready!')
    context.user_data['confirmation_stage'] = True
    text = get_message(context, epilog=epilog, highlight=highlight)

    if (update.message is
            None):  # reply doesn't work if there is no message to reply to
        update.callback_query.edit_message_text(
            text=text,
            reply_markup=last_keyboard,
            parse_mode=ParseMode.MARKDOWN,
        )
    else:
        update.message.reply_text(
            text=text,
            reply_markup=last_keyboard,
            parse_mode=ParseMode.MARKDOWN,
        )

    return ConversationStage.CONFIRMATION
Example #2
0
def ask_for_cost(update, context):
    epilog = emojize(
        'How much is it going to cost in total?\nFor :question_mark: €')

    update.callback_query.edit_message_text(
        text=get_message(context, epilog=epilog, highlight='cost'),
        reply_markup=telegram_number.number_keyboard,
        parse_mode=ParseMode.MARKDOWN,
    )

    return ConversationStage.SELECTING_COST
def ask_for_number_of_person(update, context):
    epilog = emojize(
        'For how many people (including yourself)?\nFor :question_mark: '
        'persons')

    update.callback_query.edit_message_text(
        text=get_message(context, epilog=epilog, highlight='time'),
        reply_markup=telegram_number.number_keyboard,
        parse_mode=ParseMode.MARKDOWN,
    )

    return ConversationStage.SELECTING_NB_OF_PERSON
Example #4
0
def ask_for_reminder(update, context):
    epilog = 'How much time in advance do you want to know who\'s coming?'
    ud = context.user_data
    selected_datetime = datetime.combine(ud['date'], ud['time'])
    time_left = hours_until_meal(selected_datetime)
    update.callback_query.edit_message_text(
        text=get_message(context, epilog=epilog, highlight='reminder'),
        reply_markup=reminder_keyboard_build(time_left),
        parse_mode=ParseMode.MARKDOWN,
    )

    return ConversationStage.SELECTING_REMINDER
Example #5
0
def ask_for_time(update, context, selected_time_in_the_past=False):
    if selected_time_in_the_past:
        epilog = (
            'The chosen time was in the past, please select a time in the '
            'future:'
        )
    else:
        epilog = 'At what time?'

    update.callback_query.edit_message_text(
        text=get_message(context, epilog=epilog, highlight='date'),
        reply_markup=telegram_hour.hour_keyboard,
        parse_mode=ParseMode.MARKDOWN,
    )

    return ConversationStage.SELECTING_HOUR
def additional_message(update, context):
    bot = context.bot
    ud = context.user_data
    ud['message2others'] = update.message.text
    bot.deleteMessage(update.message.chat_id, update.message.message_id)
    query = ud['last_query']
    epilog = ('Now I will send a message to people if you want' +
              ' to add a text message just send it to me. ' +
              'Press confirm when you\'re ready!')
    text = get_message(context, epilog=epilog)

    bot.edit_message_text(
        text=text,
        chat_id=query.message.chat_id,
        message_id=query.message.message_id,
        reply_markup=last_keyboard,
        parse_mode=ParseMode.MARKDOWN,
    )
    return ConversationStage.CONFIRMATION
def modify_infos(update, context):
    ud = context.user_data
    query = update.callback_query
    ud['last_query'] = query
    epilog = 'Chose what information you want to modify!'
    context.user_data['confirmation_stage'] = True
    text = get_message(context, epilog=epilog)

    if (update.message is
            None):  # reply doesn't work if there is no message to reply to
        update.callback_query.edit_message_text(
            text=text,
            reply_markup=confirmation_keyboard,
            parse_mode=ParseMode.MARKDOWN,
        )
    else:
        update.message.reply_text(
            text=text,
            reply_markup=confirmation_keyboard,
            parse_mode=ParseMode.MARKDOWN,
        )
    return ConversationStage.MODIFICATION
Example #8
0
def hour_to_text(time, index, context):
    emojies = [to_emojy(pattern) for pattern in time]
    general_message = get_message(context, epilog='Please select a time')
    index_message = pos[index] * ' ' + '⬆️'
    hour_message = f'{emojies[0]}{emojies[1]}:{emojies[2]}{emojies[3]}'
    return '\n'.join((general_message, hour_message, index_message))