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