add error handling and cooldown
This commit is contained in:
parent
bf2c4f18d5
commit
1234a36c4e
|
|
@ -4,6 +4,7 @@ import requests
|
|||
import json
|
||||
import traceback
|
||||
import os
|
||||
from time import sleep
|
||||
from telegram import Bot, ParseMode
|
||||
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
|
||||
from pathlib import Path
|
||||
|
|
@ -74,15 +75,24 @@ Type: *{'🔴 Short' if position['amount'] < 0 else '🟢 Long'}*
|
|||
Amount: *{abs(position['amount'])}*"""
|
||||
send_all(text)
|
||||
|
||||
first = requests.post("https://www.binance.com/bapi/futures/v1/public/future/leaderboard/getOtherPosition", json=payload)
|
||||
first_r = first.json()
|
||||
data = get_data(first_r["data"]["otherPositionRetList"])
|
||||
while True:
|
||||
try:
|
||||
first = requests.post("https://www.binance.com/bapi/futures/v1/public/future/leaderboard/getOtherPosition", json=payload)
|
||||
first_r = first.json()
|
||||
data = get_data(first_r["data"]["otherPositionRetList"])
|
||||
|
||||
send_all("Bot restarted")
|
||||
for position in data:
|
||||
send_msg_formatted(position)
|
||||
break
|
||||
except Exception:
|
||||
send_all(traceback.format_exc())
|
||||
sleep(1)
|
||||
continue
|
||||
|
||||
send_all("Bot restarted")
|
||||
for position in data:
|
||||
send_msg_formatted(position)
|
||||
|
||||
while True:
|
||||
sleep(1)
|
||||
try:
|
||||
r = requests.post("https://www.binance.com/bapi/futures/v1/public/future/leaderboard/getOtherPosition", json=payload)
|
||||
resp = r.json()
|
||||
|
|
|
|||
Loading…
Reference in New Issue