Пример #1
0
def on_switch_pack_type(update: Update, context: CallbackContext):
    logger.info('swicth pack type inline keyboard')

    if not context.user_data.get('pack', None):
        update.callback_query.answer(Strings.PACK_TYPE_BUTTONS_EXPIRED)
        update.callback_query.message.edit_reply_markup(
            reply_markup=InlineKeyboard.REMOVE)
        return

    match = context.matches[0].group(1)
    reply_markup = InlineKeyboard.static_animated_switch(
        animated=match == 'animated')

    if match == 'animated':
        context.user_data['pack']['animated'] = True
    else:
        context.user_data['pack']['animated'] = False

    try:
        update.callback_query.message.edit_reply_markup(
            reply_markup=reply_markup)
    except BadRequest:
        pass

    update.callback_query.answer(Strings.PACK_TYPE_CHANGED.format(match))
Пример #2
0
def on_create_static_pack_command(update: Update, context: CallbackContext):
    logger.info('/create')

    context.user_data['pack'] = dict(animated=False)

    update.message.reply_html(
        Strings.PACK_CREATION_WAITING_TITLE,
        reply_markup=InlineKeyboard.static_animated_switch())

    return Status.CREATE_WAITING_TITLE