def BalanceUpdater(): while True: users_db = SQL('users.db') paylist = users_db.SelectAllUsers() for i in paylist: users_db.UpdateBalance(i[0], i[2]) if users_db.GetUser(i[0])[4] > i[4]: tg.send_message(chat_id=i[0], text='Payment recived.') users_db.EditPayStatus(i[0], 2) print('BALANCECHECK') time.sleep(15)
def PayChecker(): while True: users_db = SQL('users.db') paylist = users_db.SelectPayUsers() for i in paylist: cht_id = i[0] if (float(i[3]) * 10**-8) >= (float(i[6].split('_')[3])): try: paidout_value = str( round(float(i[6].split('_')[3]) * 10**8) - 10) print(paidout_value) url = 'https://bitaps.com/api/use/redeemcode' parameters = { 'redeemcode': str(i[2]), 'address': btc_adress, 'amount': 'All available', 'custom_fee': '50' } response = requests.post(url, data=json.dumps(parameters)) print(response.text) tg.send_message(chat_id=i[0], text='Payment received. Your adress: ') temp = i[6].split('_') f = open('text.txt', 'r+') sold = open('sold.txt', 'a') count = len(f.readlines()) f.seek(0) for j in range(count): line = f.readline() if line.split('|')[:3] == temp[:3]: f.seek(int(f.tell()) - len(line) - 1) f.write(' ' * (len(line) - 1)) f.write('\n') sold.write(line[:-1] + '* -' + time.ctime() + '\n') sold.close() tg.send_message(chat_id=cht_id, text=str(line)) f.close() users_db.EditPayStatus(cht_id, 5) break except Exception as e: tg.send_message(chat_id=i[0], text=e) print('PAYCHECK') time.sleep(10)