39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
|
|
import requests
|
|
import settings
|
|
from datetime import datetime, timedelta
|
|
import time
|
|
import tg
|
|
import traceback
|
|
import logging
|
|
|
|
|
|
def strategy_run():
|
|
try:
|
|
start_time = datetime.now() - timedelta(minutes=settings.whaleAlert_minutes)
|
|
start_ts = int(start_time.timestamp())
|
|
|
|
url = f'https://api.whale-alert.io/v1/transactions?api_key={settings.whaleAlert_apikey}&start={start_ts}&min_value={settings.whaleAlert_max_limit}'
|
|
headers = {'Accept': 'application/json'}
|
|
|
|
resp = requests.get(url, headers=headers).json()
|
|
|
|
print(resp)
|
|
if resp['result'] == "success":
|
|
if 'transactions' in resp:
|
|
data = resp['transactions']
|
|
|
|
for ts in data:
|
|
if ts['to']['owner_type'] == 'exchange':
|
|
from_text = 'unknown wallet'
|
|
content = f"🚨大额转入提醒🚨\r\n\r\n {ts['amount']} #{ts['symbol']} ({ts['amount_usd']} USD) 从 {from_text} 转入 #{ts['to']['owner']}"
|
|
|
|
print(content)
|
|
tg.send_message(settings.chat_id, content)
|
|
|
|
else:
|
|
print(resp['message'])
|
|
tg.send_message(settings.chat_id, resp['message'])
|
|
except:
|
|
logging.error(traceback.format_exc())
|
|
tg.send_message(settings.chat_id, traceback.format_exc()) |