示例#1
0
def callback_detect(call):
    user_id = call.message.chat.id
    try:
        user_img = bot.captured_data_img(user_id)
        if user_img is not None:
            bot.edit_message_media(
                chat_id=user_id,
                message_id=call.message.message_id,
                media=InputMediaPhoto(
                    user_img, caption=MsgTemplate.prediction_start_notice()))
            processed_photo = predict(user_id)
            bot.edit_message_media(
                chat_id=user_id,
                message_id=call.message.message_id,
                media=InputMediaPhoto(
                    processed_photo,
                    caption=MsgTemplate.prediction_end_notice()))
            bot.answer_callback_query(callback_query_id=call.id,
                                      show_alert=False)
        else:
            bot.send_message(user_id,
                             MsgTemplate.captured_image_error(success=False))
    except Exception:
        bot.send_message(
            user_id, MsgTemplate.captured_image_error(exception_occurred=True))
示例#2
0
def run_carousel_template(call, step):
    user_id = call.message.chat.id
    try:
        carousel_img = bot.user_carousel_img(user_id, step)
        if carousel_img is not None:
            bot.edit_message_media(chat_id=user_id, message_id=call.message.message_id,
                                   media=InputMediaPhoto(carousel_img), reply_markup=keyboard_carousel())
            bot.answer_callback_query(callback_query_id=call.id, show_alert=False)
        else:
            bot.send_message(user_id, MsgTemplate.carousel_error(success=False))
    except Exception:
        bot.send_message(user_id, MsgTemplate.carousel_error(exception_occurred=True))
示例#3
0
def process(message):
    """
    Wrapper for command_examples
    Provide carousel of precomputed examples
    """
    user_id = message.chat.id
    try:
        carousel_img = bot.user_carousel_img(user_id)
        if carousel_img is not None:
            bot.send_photo(user_id, carousel_img,
                           reply_to_message_id=message.message_id,
                           reply_markup=keyboard_carousel())
        else:
            bot.send_message(user_id, MsgTemplate.carousel_error(success=False))
    except Exception:
        bot.send_message(user_id, MsgTemplate.carousel_error(exception_occurred=True))
示例#4
0
def process(message):
    """
    Wrapper for command_captured_image,
    It start detector usage scenario
    """
    user_id = message.chat.id
    try:
        user_img = bot.captured_data_img(user_id)
        if user_img is not None:
            bot.send_photo(user_id,
                           user_img,
                           reply_to_message_id=message.message_id,
                           reply_markup=keyboard_scan())
        else:
            bot.send_message(user_id,
                             MsgTemplate.captured_image_error(success=False))
    except Exception:
        bot.send_message(
            user_id, MsgTemplate.captured_image_error(exception_occurred=True))
示例#5
0
def other_messages(message):
    bot.send_message(message.chat.id, MsgTemplate.default_respond())
示例#6
0
def command_help(message):
    bot.reply_to(message,
                 MsgTemplate.help_respond(),
                 parse_mode='HTML',
                 disable_web_page_preview=True)