Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Telegram code help
#1
I am working on a Telegram bot, where people can invest in my bitcoin trading program. Well, I don't really know what I did wrong at the /invest command. It gets the bitcoin address with the block.io api, but it doesn't get the balance of the btc address.

Here is my code:
def invest(bot, update):
    update.message.reply_text('Getting address...')
    dictionary = requests.get('https://block.io/api/v2/get_new_address/?api_key='+api).json()
    adres = dictionary["data"]["address"]
    update.message.reply_text('Send the amount of bitcoin u like to invest to: '+adres)
    while True:
        bal = requests.get('https://block.io/api/v2/get_address_balance/?api_key='+api+'&addresses='+adres).json()
        avbal = bal["data"]["balances"]["available_balance"]
        update.message.reply_text(avbal)
        penbal = bal["data"]["balances"]["pending_received_balance"]
        update.message.reply_text(penbal)
        if (avbal > 0.00000001):
            break
        if (penbal > 0.00000001):
            update.message.reply_text('Ah, we are seeing your money at pending balance, please wait untill we have enough confirms')
        update.message.reply_text('We have just checked your payment, we still didnt get anything. Please wait...')
    check = requests.get('http://SNIP/check.php?username={}'.format(update.message.from_user.username)) //Checking if username is already in the database
    if (check == "NO"): //If not create new account
        requests.get('http://SNIP/create.php?username={}'.format(update.message.from_user.username))
        requests.get('http://SNIP/update.php?username={}' + '&1=balance&2=' + bal["data"]["balances"]["available_balance"].format(update.message.from_user.username))
    else: //Just update the balance else
        allbal = requests.get('http://SNIP/check.php?username={}'.format(update.message.from_user.username)).json()
        albal = allbal["balance"]
        requests.get('http://SNIP/update.php?username={}' + '&1=balance&2=' + bal["data"]["balances"]["available_balance"].format(update.message.from_user.username))
    update.message.reply_text('We have received your money! do "/balance" to check your balance!')
I really don't know what I do here wrong. I let the avbal and penbal sending to me. But that didn't work. I tested if I could send bitcoins to there. But it doesn't work. But when I check the balance manually, I see the money there. So I don't know what I did wrong...
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020