Exemplo n.º 1
0
    def buy_2(message):
        try:
            product = product_dict[message.chat.id]
            if int(message.text) == product.code:
                check = func.check_balance(
                    product.user_id,
                    (float(product.price) * int(product.amount)))

                if check == 1:

                    func.buy(product)

                    if func.check_settings()[0][1] == '1':

                        msg = bot.send_message(
                            chat_id=message.chat.id,
                            text=
                            f'⚠️ Введите адрес доставки или напишите в поддержку о встрече с дропом'
                        )

                        bot.register_next_step_handler(msg, address)
                    else:

                        bot.send_message(chat_id=message.chat.id,
                                         text=f'✅ Вы успешно купили товар',
                                         reply_markup=menu.main_menu)

                    bot.send_message(
                        chat_id=settings.admin_id,
                        text=f'✅ Куплен товар\n\n'
                        f'❕ Купил - {message.chat.id}/{message.from_user.username}/{message.from_user.first_name}\n'
                        f'❕ Сумма покупки - {float(product.price) * int(product.amount)}\n'
                        f'❕ Дата покупки - {datetime.datetime.now()}\n')

                    try:
                        bot.send_message(
                            chat_id=f'-100{settings.CHANNEL_ID}',
                            text=f'✅ Куплен товар\n\n'
                            f'❕ Купил - {message.chat.id}/{message.from_user.username}/{message.from_user.first_name}\n'
                            f'❕ Сумма покупки - {float(product.price) * int(product.amount)}\n'
                            f'❕ Дата покупки - {datetime.datetime.now()}\n')

                    except:
                        pass

                if check == 0:
                    bot.send_message(chat_id=message.chat.id,
                                     text='❌ На балансе недостаточно средств',
                                     reply_markup=menu.main_menu)

            else:
                bot.send_message(chat_id=message.chat.id,
                                 text='❌ Покупка отменина',
                                 reply_markup=menu.main_menu)
        except:
            bot.send_message(chat_id=message.chat.id,
                             text='⚠️ Что-то пошло не по плану',
                             reply_markup=menu.main_menu)
Exemplo n.º 2
0
    def buy_2(message):
        try:
            product = product_dict[message.chat.id]
            if int(message.text) == product.code:
                check = func.check_balance(
                    product.user_id,
                    (float(product.price) * int(product.amount)))

                if check == 1:

                    list = func.buy(product)
                    bot.send_message(
                        chat_id=message.chat.id,
                        text=f'✅ Вы успешно купили товар\n\n{list}',
                        reply_markup=menu.main_menu)

                    bot.send_message(
                        chat_id=settings.admin_id,
                        text=f'✅ Куплен товар\n\n'
                        f'❕ Купил - {message.chat.id}\n'
                        f'❕ Сумма покупки - {float(product.price) * int(product.amount)}\n'
                        f'❕ Дата покупки - {datetime.datetime.now()}\n'
                        f'❕ Купленный товар ⬇️\n\n{list}')

                    try:
                        bot.send_message(
                            chat_id=f'-100{settings.CHANNEL_ID}',
                            text=f'✅ Куплен товар\n\n'
                            f'❕ Купил - {message.chat.id}\n'
                            f'❕ Сумма покупки - {float(product.price) * int(product.amount)}\n'
                            f'❕ Дата покупки - {datetime.datetime.now()}\n'
                            f'❕ Купленный товар ⬇️\n\n{list}')

                    except:
                        pass

                if check == 0:
                    bot.send_message(chat_id=message.chat.id,
                                     text='❌ На балансе недостаточно средств')

            else:
                bot.send_message(chat_id=message.chat.id,
                                 text='❌ Покупка отменена',
                                 reply_markup=menu.main_menu)
        except:
            bot.send_message(chat_id=message.chat.id,
                             text='⚠️ Что-то пошло не по плану',
                             reply_markup=menu.main_menu)
Exemplo n.º 3
0
while True:
    checker = 0
    for j in range(len(storage.products_price_quantity)):
        if storage.products_price_quantity[j][3] != 0:
            checker += 1
    if storage.total == 0 and storage.change_available == [0, 0, 0, 0] or \
            checker == 0:
        print("NEED MAINTENANCE")
        n = input()
        if n == 'srvop17':
            functions.maintenance()
    else:
        command = input("Choose a menu option (Enter a command):\n"
                        "1. Insert a banknote\n"
                        "2. Show available products\n"
                        "3. Select a product\n"
                        "4. Get the change\n")
        if command == '1':
            functions.insert_banknote()
        elif command == '2':
            functions.show_available_products()
        elif command == '3':
            functions.buy()
        elif command == '4':
            functions.get_change()
        elif command == 'srvop17':
            functions.maintenance()
        else:
            print("Error: incorrect command")