示例#1
0
            def pay_my_phone(message):
                @bot.callback_query_handler(func=lambda call_pay: True)
                def callback_worker(call_pay):
                    if call_pay.data == "yep":  # call.data это callback_data, которую мы указали при объявлении кнопки
                        bot.send_message(call_pay.message.chat.id, 'Сообщение об успешном пополнении! : )')
                        bot.edit_message_reply_markup(call_pay.message.chat.id, call_pay.message.message_id)
                        bot.delete_message(message.chat.id, message_id=msg_del)
                    elif call_pay.data == "nope":
                        bot.send_message(message.chat.id, f"Операция отменена")
                        bot.edit_message_reply_markup(call_pay.message.chat.id, call_pay.message.message_id)
                        bot.delete_message(message.chat.id, message_id=msg_del)
                        pass

                print(f"Ввод суммы [{message.text}]")

                if message.text.isdigit():
                    balance_qiwi = balance(my_login, api_access_token)

                    if int(message.text) <= int(balance_qiwi):
                        keyboard_mts = types.InlineKeyboardMarkup()  # наша клавиатура
                        key_yes = types.InlineKeyboardButton(text='Подтвердить', callback_data='yep')  # кнопка «Да»
                        keyboard_mts.add(key_yes)  # добавляем кнопку в клавиатуру
                        key_no = types.InlineKeyboardButton(text='Отменить', callback_data='nope')
                        keyboard_mts.add(key_no)

                        bot.send_message(message.chat.id,
                                         f"На номер: +{my_login} \nбудет зачислена сумма: {message.text}₽",
                                         reply_markup=keyboard_mts)
                        global msg_del
                        msg_del = message.message_id + 1
                    else:
                        bot.send_message(message.chat.id,
                                         f"На вашем счёте недостаточно средств для проведения платежа. \n"
                                         f"Баланс счёта: {str(balance_qiwi)}₽")
                        msg_del = message.message_id + 1
                else:
                    bot.send_message(message.chat.id, f"Введите сумму числом. Только цифры 🤷🏻‍♂️")
                    bot.register_next_step_handler(message, pay_my_phone)
示例#2
0
    print("|-----------------------------------------------------------------|")
    print("|  CONGRATS! You have successfully created a GMU BANK account!!!  |")
    print("|-----------------------------------------------------------------|")

    deposit = input("\n\nYour current balance is $0, would you like to transfer money into your account? (\"yes\" or \"no\"): ")
    deposit = deposit.lower()
    
    while (deposit != "yes") and (deposit != "no"):
        print("Invalid response. Please try again")
        deposit = input("Your current balance is $0, would you like to transfer money into your account?  (\"yes\" or \"no\"): ")
        deposit = deposit.lower()

    if (deposit == "yes"):
        transAccount = input("Please enter the account number from which you will transfer the money: ")
        transBank = input("Please enter the bank name from where you will transfer the money: ")
        amount = float(input("Please enter the amount you wish to transfer to your account : "))
        currentBalance = functions.balance(amount)
        print("Your new balance is $" + str(currentBalance))
        print("\nTHANK YOU FOR USING GMU BANKING, HAVE A NICE DAY!!!")
    elif (deposit == "no"):
        print("\nTHANK YOU FOR USING GMU BANKING, HAVE A NICE DAY!!!")


else:
    print("\nThank you for visiting GMU Bank account services, have a nice day!")




示例#3
0
def request_work():
    #request transactions
    data = request.get_json()
    global fee

    #check if user and worker transaction are present
    if "user_transaction" in data:
        user = data.get("user_transaction")
    else:
        print ("User transaction missing")
        return {"Error": "User transaction missing"}

    if "worker_transaction" in data:
        worker = data.get("worker_transaction")
    else:
        print ("Worker transaction missing")
        return {"Error": "Worker transaction missing"}


    #Read transaction and check if is valid
    user_block = block_create(user.get('block_type'), user.get('account').replace("xrb_", "nano_"), user.get('representative'), user.get('previous'), user.get("link_as_account"), int(user.get('balance')), user.get("signature"))
    if user_block == "invalid":
        print ("Invalid user transaction")
        return '{"Error": "Invalid user transaction"}'
    worker_block = block_create(worker.get('block_type'), worker.get('account').replace("xrb_", "nano_"), worker.get('representative'), worker.get('previous'), worker.get("link_as_account"), int(worker.get('balance')), worker.get("signature"))
    if worker_block == "invalid":
        print ("Invalid worker transaction")
        return {"Error": "Invalid worker transaction"}

    #If account source in both transactions is different
    if user_block.account != worker_block.account :
        print ("Different source accounts ")
        return '{"Error": "Different Accounts source"}'

    #If worker account is wrong
    if worker_block.link_as_account != worker_account:
        print("Worker account is incorrect")
        return {"Error": "Worker account is incorrect"}

    #Check if previous block in worker hash is correct
    if worker_block.previous != user_block.block_hash:
        print ("Incorrect previous block in worker block")
        return {"Error": "Incorrect previous block in worker block" }

    #Recalculate the Fee with active_difficulty with 10% tolerance
    if use_active_difficulty == True:
        multiplier = get_difficulty()
        if (multiplier > max_multiplier):
            return {"Error": "Maximum difficulty exceded"}
        else:
            print ("Using active difficulty: " + str(multiplier))
        if multiplier * 0.9 > 1.0:
            fee *= (multiplier * 0.9) #multiplier fee with tolerance
        else:
            fee *= 1.0
    else:
        multiplier = 1.0

    #Check if fee is right
    user_fee = user_block.balance - worker_block.balance
    if user_fee < fee:
        print ( "Fee " + str(user_fee) + " is less than minimum " + str(fee))
        return {"Error": "Fee is less than minimum"}

    #Check previous block
    if frontier(user_block.account) == user_block.previous:
        print ("Block is valid: " + user_block.block_hash)
    else:
        print ("Gap previous block")
        return {"Error": "Gap previous block"}

    #Check if account source has sufficient funds for both transactions
    if balance(user_block.account) < int(worker_block.balance):
        print ("Insufficient funds")
        return {"Error": "Insuficient funds"}
    else:
        print ("Account has sufficient funds")

    #If all is right, check active_difficulty and PoW both transactions
    print ("Solving Works...")
    user_block.work = solve_work(user_block.previous, multiplier)
    print ("User transaction: work done")
    worker_block.work = solve_work(worker_block.previous, multiplier)
    print ("Worker transaction: work done")

    #Broadcast
    r_user = broadcast(user_block.json())
    r_worker = broadcast(worker_block.json())

    #response
    if 'hash' in r_user:
        print ("User transaction successful! Block:" + r_user.get("hash"))
        response = {"Successful": r_user["hash"]}

        if 'hash' in r_worker:
            print ("Worker transaction successful! Block:" + r_worker["hash"])
            print ("Your reward has arrived!")
        else:
            print ("Worker transaction fail. Details: " + json.dumps(r_worker))
    else:
        print ("User transaction fail. Details: " + json.dumps(r_user) + "\n")
        response = {"Error": "User transaction fail. Details: " + json.dumps(r_user)}

    print ("\n")
    return response
示例#4
0
from functions import balance

for choice in range(1, 5):
    if choice == '1' and balance().score == '200':
        assert balance().score == '200'
    elif choice == '2' and balance().purchase_question_score == '300':
        assert balance(
        ).purchase_question_score == 'У Вас недостаточно средств на счете'
    elif choice == '2' and balance().purchase_question_score == '200':
        assert balance().score == '0'
    elif choice == '2' and balance().purchase_question == 'Банан':
        assert balance().purchase_question == 'Банан'
示例#5
0
def all_messages(message):
    # Получаем сообщение пользователя
    print(f"Пользователь написал {message.text}")
    # Отправка в канал zireael
    # bot.send_message(-1001166585345, f"!")

    # Получение статуса прав пользователя
    rules = check_rules(message.chat.id)

    if rules == "True":
        # Получаем total_say_ban от 0 до 1.
        total_say_ban = t_say_ban(message.text, say_ban)
        total_say_unban = t_say_unban(message.text, say_unban)

        # Оплата мобильного телефона
        if message.text == '📲' and message.chat.id == 441945234:
            def pay_my_phone(message):
                @bot.callback_query_handler(func=lambda call_pay: True)
                def callback_worker(call_pay):
                    if call_pay.data == "yep":  # call.data это callback_data, которую мы указали при объявлении кнопки
                        bot.send_message(call_pay.message.chat.id, 'Сообщение об успешном пополнении! : )')
                        bot.edit_message_reply_markup(call_pay.message.chat.id, call_pay.message.message_id)
                        bot.delete_message(message.chat.id, message_id=msg_del)
                    elif call_pay.data == "nope":
                        bot.send_message(message.chat.id, f"Операция отменена")
                        bot.edit_message_reply_markup(call_pay.message.chat.id, call_pay.message.message_id)
                        bot.delete_message(message.chat.id, message_id=msg_del)
                        pass

                print(f"Ввод суммы [{message.text}]")

                if message.text.isdigit():
                    balance_qiwi = balance(my_login, api_access_token)

                    if int(message.text) <= int(balance_qiwi):
                        keyboard_mts = types.InlineKeyboardMarkup()  # наша клавиатура
                        key_yes = types.InlineKeyboardButton(text='Подтвердить', callback_data='yep')  # кнопка «Да»
                        keyboard_mts.add(key_yes)  # добавляем кнопку в клавиатуру
                        key_no = types.InlineKeyboardButton(text='Отменить', callback_data='nope')
                        keyboard_mts.add(key_no)

                        bot.send_message(message.chat.id,
                                         f"На номер: +{my_login} \nбудет зачислена сумма: {message.text}₽",
                                         reply_markup=keyboard_mts)
                        global msg_del
                        msg_del = message.message_id + 1
                    else:
                        bot.send_message(message.chat.id,
                                         f"На вашем счёте недостаточно средств для проведения платежа. \n"
                                         f"Баланс счёта: {str(balance_qiwi)}₽")
                        msg_del = message.message_id + 1
                else:
                    bot.send_message(message.chat.id, f"Введите сумму числом. Только цифры 🤷🏻‍♂️")
                    bot.register_next_step_handler(message, pay_my_phone)

            bot.send_message(message.chat.id, f"Введите сумму:")
            # send_mobile(api_access_token, '1', '9187289906', 'Оплата телефона с помощью бота', '1')
            bot.register_next_step_handler(message, pay_my_phone)

        # Узнать баланс кошелька
        elif message.text == '💰' and message.chat.id == 441945234:
            # все балансы
            balances = balance(my_login, api_access_token)
            bot.send_message(message.chat.id, f"Ваш баланс: {balances} ₽")

        # Числа Фибоначчи
        elif message.text == '🌻':
            def get_fibonacci_number(message):  # получаем число
                global number
                number = message.text

                if number.isdigit():
                    result_fibonacci = fibonacci(int(number))
                    fib_number = list(result_fibonacci)[0]
                    fib_number = str(fib_number).replace('[', '').replace(']', '')
                    print(fib_number)
                    fib_sequence = list(result_fibonacci)[1]
                    fib_sequence = str(fib_sequence).replace('[', '').replace(']', '')
                    print(fib_sequence)

                    bot.send_message(message.chat.id, f"{number} - имеет следующую последовательность Фибоначчи: \n"
                                                      f"{fib_number}\n"
                                                      f"Золотым сечением данной последовательности является число: "
                                                      f"{fib_sequence}")

                    keyboard = types.InlineKeyboardMarkup()
                    key_yes = types.InlineKeyboardButton(text='❤️', callback_data='yes')  # кнопка «Да»
                    keyboard.add(key_yes)
                    key_no = types.InlineKeyboardButton(text='😡', callback_data='no')
                    keyboard.add(key_no)
                    bot.send_message(message.from_user.id, text=f"Вам понравилось качество нашего обслуживания?",
                                     reply_markup=keyboard)

                    @bot.callback_query_handler(func=lambda call: True)
                    def callback_worker(call):
                        if call.data == "yes":  # call.data это callback_data, которую мы указали при объявлении кнопки
                            bot.send_sticker(message.chat.id,
                                             'CAACAgIAAxkBAAID0l9BbMxW6Q0_yRZ7ahHsU8CQO6c7AALHAAMWHfwLeXVXmujsd1AbBA')

                            msg_id = message.message_id + 2
                            bot.delete_message(message.chat.id, msg_id)

                        elif call.data == "no":
                            bot.send_sticker(message.chat.id,
                                             'CAACAgIAAxkBAAID0F9BbHvp_tcecJxgEApxkT3ZEnIIAAKsAAM60N8BRmmum8GHZ5wbBA')

                            msg_id = message.message_id + 2
                            bot.delete_message(message.chat.id, msg_id)

                else:
                    bot.send_message(message.chat.id, f"Введите число")
                    bot.register_next_step_handler(message, get_fibonacci_number)

                    # следующий шаг – функция get_name



            # Фибоначчи

            bot.send_message(message.chat.id, "Введите число, чтобы получить последовельность чисел Фибоначчи"
                                              " и его золотое сечение 🙂")
            bot.register_next_step_handler(message, get_fibonacci_number)

        # Бан пользователя
        elif (total_say_ban > 0.80) and message.chat.id == 441945234:
            user_name = user_ban(message.text)
            bot.send_message(message.chat.id, f"Пользователь @{user_name} забанен.")

        # Разбан пользователя
        elif (total_say_unban > 0.80) and message.chat.id == 441945234:
            user_name = user_unban(message.text)
            bot.send_message(message.chat.id, f"Пользователь @{user_name} разбанен.")

        else:
            bot.send_message(message.chat.id, f"Вы написали: {message.text}")

    else:
        print("У пользователя нет прав")
        bot.send_message(message.chat.id, "Вы забанены администратором. \nДля разбана, свяжитесь с @sabolch")
示例#6
0
    elif panel == '3':
        print('1. Папка')
        print('2. Файл')
        copy = input('Что Вы хотите скопировать? ')
        if copy == 1:
            functions.copy_directory()
        elif copy == 2:
            functions.copy_file()
    elif panel == '4':
        functions.show_directory()
    elif panel == '4.1':
        functions.write_directory()
    elif panel == '5':
        functions.dir_info()
    elif panel == '6':
        functions.file_info()
    elif panel == '7':
        functions.system_info()
    elif panel == '8':
        print('Эту прогрпмму написал Банчев Александр')
    elif panel == '9':
        functions.victory()
    elif panel == '10':
        functions.balance()
    elif panel == '11':
        functions.change_directory()
    elif panel == '12':
        break
    else:
        print('Неверный пункт меню')