Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Telegram code help
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 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(''+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(''+api+'&addresses='+adres).json()
        avbal = bal["data"]["balances"]["available_balance"]
        penbal = bal["data"]["balances"]["pending_received_balance"]
        if (avbal > 0.00000001):
        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/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...

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to make a telegram bot respond to the specific word in a sentence? Metodolog 1 147 Dec-02-2019, 11:19 PM
Last Post: stullis
  Question about telegram bot Romank 0 607 Mar-29-2018, 09:36 PM
Last Post: Romank

Forum Jump:

Users browsing this thread: 1 Guest(s)