コード例 #1
0
ファイル: orders.py プロジェクト: VID-STUDY/ElectroBot
def _to_the_confirmation(chat_id, current_order, language):
    total = _total_order_sum(current_order.order_items.all())
    summary_order_message = strings.from_order(current_order, language, total)
    confirmation_keyboard = keyboards.get_keyboard('order.confirmation', language)
    if current_order.payment_method == Order.PaymentMethods.PAYME:
        title = strings.get_string('order.payment.title', language).format(current_order.id)
        description = strings.get_string('order.payment.description', language)
        payload = str(total)
        start_parameter = secrets.token_hex(20)
        currency = 'UZS'
        prices = strings.from_order_items_to_labeled_prices(current_order.order_items.all(), language)
        confirmation_keyboard = keyboards.get_keyboard('order.payment_confirmation', language)
        bot.send_message(chat_id, summary_order_message, parse_mode='HTML', reply_markup=confirmation_keyboard)
        invoice = bot.send_invoice(chat_id, title, description, payload, Config.PAYMENT_PROVIDER_TOKEN, currency, prices,
                         start_parameter)
        bot.register_next_step_handler_by_chat_id(chat_id, confirmation_processor, total=total, message_id=invoice.message_id)
        return
    elif current_order.payment_method == Order.PaymentMethods.CLICK:
        title = strings.get_string('order.payment.title', language).format(current_order.id)
        description = strings.get_string('order.payment.description', language)
        payload = str(total)
        start_parameter = secrets.token_hex(20)
        currency = 'UZS'
        prices = strings.from_order_items_to_labeled_prices(current_order.order_items.all(), language)
        confirmation_keyboard = keyboards.get_keyboard('order.payment_confirmation', language)
        bot.send_message(chat_id, summary_order_message, parse_mode='HTML', reply_markup=confirmation_keyboard)
        invoice = bot.send_invoice(chat_id, title, description, payload, Config.PAYMENT_PROVIDER_TOKEN_CLICK, currency, prices,
                         start_parameter)
        bot.register_next_step_handler_by_chat_id(chat_id, confirmation_processor, total=total, message_id=invoice.message_id)
        return
    else:
        bot.send_message(chat_id, summary_order_message, parse_mode='HTML', reply_markup=confirmation_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, confirmation_processor, total=total)
コード例 #2
0
def _to_main_menu(chat_id, language, message_text=None):
    if message_text:
        main_menu_message = message_text
    else:
        main_menu_message = strings.get_string('main_menu.choose_option', language)
    main_menu_keyboard = keyboards.get_keyboard('main_menu', language)
    bot.send_message(chat_id, main_menu_message, reply_markup=main_menu_keyboard)
コード例 #3
0
def choose_dish_processor(message: Message, **kwargs):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    def error():
        error_message = strings.get_string('catalog.dish_error', language)
        bot.send_message(chat_id, error_message)
        bot.register_next_step_handler_by_chat_id(chat_id,
                                                  choose_dish_processor)

    if not message.text:
        error()
        return
    if strings.get_string('go_back', language) in message.text:
        if 'category' in kwargs:
            category = kwargs.get('category')
            back_to_the_catalog(chat_id, language, parent_category=category)
            return
        back_to_the_catalog(chat_id, language)
    elif strings.get_string('catalog.cart', language) in message.text:
        cart.cart_processor(message, choose_dish_processor)
    else:
        dish_name = message.text
        dish = dishservice.get_dish_by_name(dish_name, language,
                                            kwargs.get('category'))
        if not dish:
            error()
            return
        userservice.set_current_user_dish(user_id, dish.id)
        dish_info = strings.from_dish(dish, language)
        dish_keyboard = keyboards.get_keyboard('catalog.dish_keyboard',
                                               language)
        if dish.image_id or dish.image_path:
            if dish.image_path and not dish.image_id:
                try:
                    image = open(dish.image_path, 'rb')
                except FileNotFoundError:
                    bot.send_message(chat_id,
                                     dish_info,
                                     reply_markup=dish_keyboard)
                else:
                    sent_message = bot.send_photo(chat_id,
                                                  image,
                                                  caption=dish_info,
                                                  reply_markup=dish_keyboard)
                    dishservice.set_dish_image_id(
                        dish, sent_message.photo[-1].file_id)
            elif dish.image_id:
                bot.send_photo(chat_id,
                               dish.image_id,
                               caption=dish_info,
                               reply_markup=dish_keyboard)
        else:
            bot.send_message(chat_id, dish_info, reply_markup=dish_keyboard)
        dish_action_helper = strings.get_string('catalog.dish_action_helper',
                                                language)
        bot.send_message(chat_id, dish_action_helper)
        bot.register_next_step_handler_by_chat_id(chat_id,
                                                  dish_action_processor)
コード例 #4
0
def budget_processor(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    def error():
        _to_budget(chat_id, language, include_keyboard=False)

    if not message.text:
        error()
        return
    if strings.get_string('go_back', language) in message.text:
        _to_audience_age(chat_id, language)
    elif strings.get_string('main_menu', language) in message.text:
        _to_main_menu(chat_id, language)
    else:
        budget_enum_value = strings.text_to_budget_enum(message.text, language)
        if not budget_enum_value:
            error()
            return
        coverage = advertservice.get_coverages_by_budget(budget_enum_value)
        coverage_msg = strings.from_coverage_to_text(coverage, language)
        coverage_keyboard = keyboards.get_keyboard('campaign.coverage', language)
        bot.send_message(chat_id, coverage_msg, parse_mode='Markdown', reply_markup=coverage_keyboard)
        bot.register_next_step_handler_by_chat_id(chat_id, coverage_processor, budget=budget_enum_value)
コード例 #5
0
ファイル: registration.py プロジェクト: VID-STUDY/ElectroBot
def welcome(message):
    chat_id = message.chat.id

    def error():
        accept_policy = types.ReplyKeyboardMarkup(resize_keyboard=True)
        item1 = types.KeyboardButton('🤝 Я согласен(сна) / Rozilik beraman')
        accept_policy.add(item1)
        error_msg = (
            'Примите пользовательское соглашение!  \n\nFoydalanuvchi shartnomasini qabul qiling!'
        )
        telegram_bot.send_message(chat_id,
                                  error_msg,
                                  reply_markup=accept_policy,
                                  parse_mode='HTML')
        telegram_bot.register_next_step_handler_by_chat_id(chat_id, welcome)

    if message.text.startswith('🤝'):
        accept_policy = True
        welcome_message = strings.get_string('welcome')
        language_keyboard = keyboards.get_keyboard('welcome.language')
        telegram_bot.send_message(chat_id,
                                  welcome_message,
                                  reply_markup=language_keyboard,
                                  parse_mode='HTML')
        telegram_bot.register_next_step_handler_by_chat_id(
            chat_id, process_user_language, accept_policy=accept_policy)
    else:
        error()
        return
コード例 #6
0
ファイル: packageoffers.py プロジェクト: VID-STUDY/IMS-Bot
def channel_processor(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    def error():
        error_msg = strings.get_string('package_offers.channel', language)
        bot.send_message(chat_id, error_msg)
        bot.register_next_step_handler_by_chat_id(chat_id, channel_processor)

    if not message.text:
        error()
        return
    if strings.get_string('go_back', language) in message.text:
        main_menu_message = strings.get_string('main_menu.choose_option', language)
        main_menu_keyboard = keyboards.get_keyboard('main_menu', language)
        bot.send_message(chat_id, main_menu_message, reply_markup=main_menu_keyboard)
        return
    try:
        package_offers = channelservice.get_package_offers_by_channel(message.text)
    except channelservice.ChannelNotFound:
        error()
        return
    for package_offer in package_offers:
        if package_offer.telegram_id:
            bot.send_document(chat_id, package_offer.telegram_id)
        else:
            bot.send_chat_action(chat_id, 'upload_document')
            file = open(package_offer.file_path, 'rb')
            sent_file = bot.send_document(chat_id, file)
            tg_id = sent_file.document.file_id
            channelservice.set_telegram_id_for_price_file(package_offer.id, tg_id)
    bot.register_next_step_handler_by_chat_id(chat_id, channel_processor)
コード例 #7
0
def request_registration_handler(message: Message, language: str, accept_policy: bool):
    chat_id = message.chat.id

    welcome_message = strings.get_string('registration.request.welcome', language)
    remove_keyboard = keyboards.get_keyboard('remove')
    telegram_bot.send_message(chat_id, welcome_message, reply_markup=remove_keyboard)
    telegram_bot.register_next_step_handler_by_chat_id(chat_id, request_registration_name_handler, language=language, accept_policy=accept_policy)
コード例 #8
0
def phone_number_processor(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    def error():
        error_msg = strings.get_string('calls.number', language)
        bot.send_message(chat_id, error_msg, parse_mode='HTML')
        bot.register_next_step_handler_by_chat_id(chat_id,
                                                  phone_number_processor)

    if message.contact:
        callservice.set_call_phone_number(user_id,
                                          message.contact.phone_number)
    else:
        if not message.text:
            error()
            return
        if strings.get_string('go_back', language) in message.text:
            _to_main_menu(chat_id, language)
            return
        match = re.match(r'\+*998\s*\d{2}\s*\d{3}\s*\d{2}\s*\d{2}',
                         message.text)
        if not match:
            error()
            return
        phone_number = match.group()
        callservice.set_call_phone_number(user_id, phone_number)
    time_message = strings.get_string('call.time', language)
    time_keyboard = keyboards.get_keyboard('call.time', language)
    bot.send_message(chat_id, time_message, reply_markup=time_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, call_time_processor)
コード例 #9
0
def _to_product_name(chat_id, language, include_keyboard=True):
    product_name_msg = strings.get_string('campaign.product_name', language)
    if include_keyboard:
        go_back_keyboard = keyboards.get_keyboard('go_back', language)
        bot.send_message(chat_id, product_name_msg, reply_markup=go_back_keyboard)
    else:
        bot.send_message(chat_id, product_name_msg)
    bot.register_next_step_handler_by_chat_id(chat_id, product_name_processor)
コード例 #10
0
def _to_phone_number(chat_id, language):
    calls_message = strings.get_string('calls.number', language)
    calls_keyboard = keyboards.get_keyboard('call.number', language)
    bot.send_message(chat_id,
                     calls_message,
                     parse_mode='HTML',
                     reply_markup=calls_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, phone_number_processor)
コード例 #11
0
def back_to_the_settings_menu(chat_id, language, message_txt=None):
    if not message_txt:
        settings_message = strings.get_string('main_menu.settings', language)
    else:
        settings_message = message_txt
    settings_keyboard = keyboards.get_keyboard('settings', language)
    telegram_bot.send_message(chat_id, settings_message, reply_markup=settings_keyboard)
    telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_choose_option)
コード例 #12
0
def main_menu_settings(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)
    settings_message = strings.get_string('main_menu.settings', language)
    settings_keyboard = keyboards.get_keyboard('settings', language)
    telegram_bot.send_message(chat_id, settings_message, reply_markup=settings_keyboard)
    telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_choose_option)
コード例 #13
0
ファイル: orders.py プロジェクト: VID-STUDY/ElectroBot
def _to_the_address(chat_id, language):
    cart = userservice.get_user_cart(chat_id)
    total = _total_cart_sum(cart)
    cart_contains_message = strings.from_cart_items(cart, language, total)
    address_message = strings.get_string('order.address', language).format(cart_contains_message)
    address_keyboard = keyboards.get_keyboard('order.address', language)
    bot.send_message(chat_id, address_message, parse_mode='HTML', reply_markup=address_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, address_processor)
コード例 #14
0
ファイル: __init__.py プロジェクト: VID-STUDY/IMS-Bot
def empty_message(message: telebot.types.Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)
    if userservice.is_user_registered(user_id):
        main_menu_message = strings.get_string('main_menu.choose_option', language)
        main_menu_keyboard = keyboards.get_keyboard('main_menu', language)
        telegram_bot.send_message(chat_id, main_menu_message, reply_markup=main_menu_keyboard)
コード例 #15
0
def _to_the_address(chat_id, language):
    address_message = strings.get_string('order.address', language)
    address_keyboard = keyboards.get_keyboard('order.address', language)
    bot.send_message(chat_id,
                     address_message,
                     parse_mode='HTML',
                     reply_markup=address_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, address_processor)
コード例 #16
0
def _to_budget(chat_id, language, include_keyboard=True):
    budget_msg = strings.get_string('campaign.budget', language)
    if include_keyboard:
        budget_keyboard = keyboards.get_keyboard('campaign.budget', language)
        bot.send_message(chat_id, budget_msg, reply_markup=budget_keyboard)
    else:
        bot.send_message(chat_id, budget_msg)
    bot.register_next_step_handler_by_chat_id(chat_id, budget_processor)
コード例 #17
0
def _to_target_audience(chat_id, language, include_keyboard=True):
    target_audience_msg = strings.get_string('campaign.target_audience', language)
    if include_keyboard:
        target_audience_keyboard = keyboards.get_keyboard('campaign.target_audience', language)
        bot.send_message(chat_id, target_audience_msg, reply_markup=target_audience_keyboard)
    else:
        bot.send_message(chat_id, target_audience_msg)
    bot.register_next_step_handler_by_chat_id(chat_id, target_audience_processor)
コード例 #18
0
def rating_handler(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    rating_message = strings.get_string('rating.welcome', language)
    ratings_keyboard = keyboards.get_keyboard('rating', language)
    bot.send_message(chat_id, rating_message, reply_markup=ratings_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, rating_processor)
コード例 #19
0
def catalog(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)
    bot.send_chat_action(chat_id, 'typing')
    dishes_keyboard = keyboards.get_keyboard('catalog.dish_keyboard')
    dish_message = strings.get_string('catalog.dish_action_helper', language)
    bot.send_message(chat_id, dish_message, reply_markup=dishes_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, count_processor)
コード例 #20
0
ファイル: orders.py プロジェクト: VID-STUDY/ElectroBot
def _to_the_payment_method(chat_id, language, user_id: int):
    current_order = orderservice.get_current_order_by_user(user_id)
    if current_order.shipping_method == Order.ShippingMethods.PICK_UP:
        payment_message = strings.get_string('order.payment_pickup', language)
    else:
        payment_message = strings.get_string('order.payment_delivery', language)
    payment_keyboard = keyboards.get_keyboard('order.payment', language)
    bot.send_message(chat_id, payment_message, reply_markup=payment_keyboard, parse_mode='HTML')
    bot.register_next_step_handler_by_chat_id(chat_id, payment_method_processor)
コード例 #21
0
def welcome(message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    if userservice.is_user_registered(user_id):
        language = userservice.get_user_language(user_id)
        main_menu_message = strings.get_string('main_menu.choose_option',
                                               language)
        main_menu_keyboard = keyboards.get_keyboard('main_menu', language)
        telegram_bot.send_message(chat_id,
                                  main_menu_message,
                                  reply_markup=main_menu_keyboard)
        return
    welcome_text = strings.get_string('welcome')
    language_keyboard = keyboards.get_keyboard('welcome.language')
    msg = telegram_bot.send_message(chat_id,
                                    welcome_text,
                                    parse_mode='HTML',
                                    reply_markup=language_keyboard)
    telegram_bot.register_next_step_handler(msg, process_user_language)
コード例 #22
0
ファイル: comments.py プロジェクト: maxwell882000/HomeCooking
def comments(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    comments_message = strings.get_string('comments.send_comment', language)
    comments_keyboard = keyboards.get_keyboard('comments.send_comment',
                                               language)
    bot.send_message(chat_id, comments_message, reply_markup=comments_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id, comments_processor)
コード例 #23
0
ファイル: orders.py プロジェクト: maxwell882000/CosmeticBot
def _to_the_shipping_method(chat_id, language):
    order_shipping_method_message = strings.get_string('order.shipping_method',
                                                       language)
    order_shipping_method_keyboard = keyboards.get_keyboard(
        'order.shipping_methods', language)
    bot.send_message(chat_id,
                     order_shipping_method_message,
                     parse_mode='HTML',
                     reply_markup=order_shipping_method_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id,
                                              shipping_method_processor)
コード例 #24
0
ファイル: bot.py プロジェクト: maxwell882000/SausageBot
def to_main_menu(chat_id, language, message_text=None):
    telegram_bot.clear_step_handler_by_chat_id(chat_id)
    if message_text:
        main_menu_message = message_text
    else:
        main_menu_message = strings.get_string('main_menu.choose_option',
                                               language)
    main_menu_keyboard = keyboards.get_keyboard('main_menu', language)
    telegram_bot.send_message(chat_id,
                              main_menu_message,
                              reply_markup=main_menu_keyboard)
コード例 #25
0
def _to_the_confirmation(chat_id, current_order, language):
    total = _total_order_sum(current_order.order_items.all())
    summary_order_message = strings.from_order(current_order, language, total)
    confirmation_keyboard = keyboards.get_keyboard('order.confirmation',
                                                   language)
    bot.send_message(chat_id,
                     summary_order_message,
                     parse_mode='HTML',
                     reply_markup=confirmation_keyboard)
    bot.register_next_step_handler_by_chat_id(chat_id,
                                              confirmation_processor,
                                              total=total)
コード例 #26
0
def process_choose_option(message: Message):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    def error():
        error_msg = strings.get_string('main_menu.choose_option', language)
        telegram_bot.send_message(chat_id, error_msg)
        telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_choose_option)

    if not message.text:
        error()
        return
    if strings.get_string('go_back', language) in message.text:
        main_menu_message = strings.get_string('main_menu.choose_option', language)
        main_menu_keyboard = keyboards.get_keyboard('main_menu', language)
        telegram_bot.send_message(chat_id, main_menu_message, reply_markup=main_menu_keyboard)
    elif strings.get_string('settings.change_user_name', language) in message.text:
        send_name_message = strings.get_string('settings.send_name', language)
        go_back_keyboard = keyboards.get_keyboard('go_back', language)
        telegram_bot.send_message(chat_id, send_name_message, reply_markup=go_back_keyboard)
        telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_change_user_name)
    elif strings.get_string('settings.change_phone_number', language) in message.text:
        send_phone_message = strings.get_string('settings.send_phone_number', language)
        phone_number_keyboard = keyboards.get_keyboard('settings.change_phone', language)
        telegram_bot.send_message(chat_id, send_phone_message, reply_markup=phone_number_keyboard, parse_mode='HTML')
        telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_change_user_phone_number)
    elif strings.get_string('settings.change_company_name', language) in message.text:
        send_company_name_message = strings.get_string('settings.send_company_name', language)
        go_back_keyboard = keyboards.get_keyboard('go_back', language)
        telegram_bot.send_message(chat_id, send_company_name_message, reply_markup=go_back_keyboard)
        telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_change_user_company_name)
    elif strings.get_string('settings.change_language', language) in message.text:
        choose_language_message = strings.get_string('settings.choose_language', language)
        choose_language_keyboard = keyboards.get_keyboard('settings.choose_language', language)
        telegram_bot.send_message(chat_id, choose_language_message, reply_markup=choose_language_keyboard)
        telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_change_user_language)
    else:
        error()
コード例 #27
0
def welcome(message, **kwargs):
    user_id = message.from_user.id
    chat_id = message.chat.id

    def not_allowed():
        not_allowed_message = strings.get_string('registration.not_allowed')
        remove_keyboard = keyboards.get_keyboard('remove')
        telegram_bot.send_message(chat_id, not_allowed_message, reply_markup=remove_keyboard)
    current_user = userservice.get_user_by_telegram_id(user_id)
    if current_user:
        botutils.to_main_menu(chat_id, current_user.language)
        return
    welcome_message = strings.get_string('welcome')
    language_keyboard = keyboards.get_keyboard('welcome.language')
    telegram_bot.send_message(chat_id, welcome_message, reply_markup=language_keyboard, parse_mode='HTML')
    telegram_bot.register_next_step_handler_by_chat_id(chat_id, process_user_language)
コード例 #28
0
def coverage_processor(message: Message, **kwargs):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    def error():
        bot.register_next_step_handler_by_chat_id(chat_id, coverage_processor)

    if not message.text:
        error()
        return
    if strings.get_string('go_back', language) in message.text:
        _to_budget(chat_id, language)
    elif strings.get_string('main_menu', language) in message.text:
        _to_main_menu(chat_id, language)
    elif strings.get_string('campaign.show', language) in message.text:
        budget = kwargs.get('budget')
        current_ad_order = advertservice.set_budget(user_id, budget)
        total_order_msg = strings.total_ad_order(current_ad_order, language)
        total_order_keyboard = keyboards.get_keyboard('campaign.confirmation', language)
        bot.send_message(chat_id, total_order_msg, parse_mode='Markdown', reply_markup=total_order_keyboard)
        bot.register_next_step_handler_by_chat_id(chat_id, confirmation_processor)
    else:
        error()
コード例 #29
0
def choose_dish_processor(message: Message, **kwargs):
    chat_id = message.chat.id
    user_id = message.from_user.id
    language = userservice.get_user_language(user_id)

    def error():
        if message.text == '/start':
            registration.welcome(message)
            return
        error_message = strings.get_string('catalog.dish_error', language)
        bot.send_message(chat_id, error_message)
        bot.register_next_step_handler_by_chat_id(chat_id,
                                                  choose_dish_processor)

    if not message.text:
        error()
        return
    if strings.get_string('go_back', language) in message.text:
        if 'category_id' in kwargs:
            category_id = kwargs.get('category_id')
            back_to_the_catalog(chat_id,
                                language,
                                parent_category_id=category_id)
            return
        back_to_the_catalog(chat_id, language)

    elif strings.get_string('go_to_menu', language) in message.text:
        botutils.to_main_menu(chat_id, language)  ##MENU

    elif strings.get_string('catalog.cart', language) in message.text:
        user_cart.cart_processor(message, choose_dish_processor)
    else:
        dish_name = message.text
        dish = dishservice.get_dish_by_name(
            dish_name, language,
            dishservice.get_category_by_id(kwargs.get('category_id')))
        if not dish:
            error()
            return
        userservice.set_current_user_dish(user_id, dish.id)
        dish_info = strings.from_dish(dish, language)
        dish_keyboard = keyboards.get_keyboard('catalog.dish_keyboard',
                                               language)
        msg_id = None
        if dish.image_id or dish.image_path:
            if dish.image_path and not dish.image_id:
                try:
                    image = open(dish.image_path, 'rb')
                except FileNotFoundError:
                    bot.send_message(chat_id,
                                     dish_info,
                                     reply_markup=dish_keyboard,
                                     parse_mode='HTMLS')
                else:
                    sent_message = bot.send_photo(chat_id,
                                                  image,
                                                  caption=dish_info,
                                                  reply_markup=dish_keyboard,
                                                  parse_mode='HTML')
                    dishservice.set_dish_image_id(
                        dish, sent_message.photo[-1].file_id)
                    msg_id = sent_message.message_id
            elif dish.image_id:
                msg_id = bot.send_photo(chat_id,
                                        dish.image_id,
                                        caption=dish_info,
                                        reply_markup=dish_keyboard,
                                        parse_mode='HTML').message_id
        else:
            msg_id = bot.send_message(chat_id,
                                      dish_info,
                                      reply_markup=dish_keyboard,
                                      parse_mode='HTML').message_id
        bot.register_next_step_handler_by_chat_id(chat_id,
                                                  dish_action_processor,
                                                  message_id=msg_id)
コード例 #30
0
 def not_allowed():
     not_allowed_message = strings.get_string('registration.not_allowed')
     remove_keyboard = keyboards.get_keyboard('remove')
     telegram_bot.send_message(chat_id,
                               not_allowed_message,
                               reply_markup=remove_keyboard)