def phone_number_processor(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('order.phone_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 is not None: current_order = orderservice.set_phone_number( user_id, message.contact.phone_number) else: if message.text is None: error() return else: if strings.get_string('go_back', language) in message.text: _to_the_payment_method(chat_id, language, user_id) return match = re.match(r'\+*998\s*\d{2}\s*\d{3}\s*\d{2}\s*\d{2}', message.text) if match is None: error() return phone_number = match.group() current_order = orderservice.set_phone_number( user_id, phone_number) _to_the_confirmation(chat_id, current_order, language)
def count_processor(message): 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_action_error', language) bot.send_message(chat_id, error_message) bot.register_next_step_handler_by_chat_id(chat_id, count_processor) if strings.get_string('go_back', language) in message.text: botutils.to_main_menu(chat_id, language) return if not message.text.isdigit() or int(message.text) >= 11 or int( message.text) <= 0: error() return userservice.clear_user_cart(user_id) userservice.add_dish_to_cart(user_id, dishservice.get_dish_by_id(1), int(message.text)) orderservice.make_an_order(user_id) orderservice.set_shipping_method(user_id, Order.ShippingMethods.PICK_UP) orderservice.set_payment_method(user_id, Order.PaymentMethods.CASH) orderservice.set_phone_number(user_id) current_order = orderservice.get_current_order_by_user(user_id) _to_the_confirmation(chat_id, current_order, language)
def order_processor(message: Message): chat_id = message.chat.id user_id = message.from_user.id language = userservice.get_user_language(user_id) orderservice.make_an_order(user_id) orderservice.set_shipping_method(user_id, Order.ShippingMethods.PICK_UP) orderservice.set_payment_method(user_id, Order.PaymentMethods.CASH) orderservice.set_phone_number(user_id) current_order = orderservice.get_current_order_by_user(user_id) _to_the_confirmation(chat_id, current_order, language)
def phone_number(): current_order = orderservice.set_phone_number(user_id) _to_the_confirmation(chat_id, current_order, language)