-
-
Save rssnyder/dd543590ae48e45b4e6ab410c01710a0 to your computer and use it in GitHub Desktop.
load bots into service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from sqlite3 import connect | |
import logging | |
from json import dumps | |
from time import sleep | |
import sys | |
import os | |
from requests import get, post | |
os.environ['http_proxy'] = '' | |
os.environ['https_proxy'] = '' | |
os.environ['HTTP_PROXY'] = '' | |
os.environ['HTTPS_PROXY'] = '' | |
if len(sys.argv) < 3: | |
print('pass db file and url') | |
sys.exit(1) | |
db_client = connect(sys.argv[1]) | |
get_cur = db_client.cursor() | |
get_cur.execute( | |
'SELECT token, ticker, type, bitcoin, activity, currency, extend_activity, decimals, decorator, currency_symbol, client_id FROM tickers' | |
) | |
item = get_cur.fetchone() | |
while item: | |
if not item[1]: | |
item = get_cur.fetchone() | |
continue | |
token = item[0] | |
ticker = item[1] | |
typ = item[2] | |
pair = item[3] | |
activity = item[4] | |
currency = item[5] | |
extend_activity = item[6] | |
decimals = item[7] | |
decorator = item[8] | |
currency_symbol = item[9] | |
cid = item[10] | |
print(f'{typ}: {ticker}') | |
# GAS | |
if typ == "gas": | |
data = { | |
"network": ticker, | |
"frequency": 10, | |
"set_nickname": True, | |
"discord_bot_token": token | |
} | |
if activity: | |
data['activity'] = activity | |
if cid: | |
data['client_id'] = cid | |
resp = post( | |
f'http://{sys.argv[2]}/gas', | |
data=dumps(data) | |
) | |
# TOKEN | |
elif typ.startswith('token'): | |
data = { | |
"network": ticker.rsplit("-", 1)[0], | |
"contract": ticker.rsplit("-", 1)[1], | |
"name": typ.split('token-', 1).pop(), | |
"frequency": 10, | |
"set_nickname": True, | |
"discord_bot_token": token | |
} | |
if activity: | |
data['activity'] = activity | |
if cid: | |
data['client_id'] = cid | |
resp = post( | |
f'http://{sys.argv[2]}/token', | |
data=dumps(data) | |
) | |
# HODLER | |
elif typ.startswith('holders'): | |
data = { | |
"network": ticker.rsplit("-", 1)[0], | |
"address": ticker.rsplit("-", 1)[1], | |
"name": typ.split('holders-', 1).pop(), | |
"frequency": 10, | |
"set_nickname": True, | |
"discord_bot_token": token | |
} | |
if activity: | |
data['activity'] = activity | |
if cid: | |
data['client_id'] = cid | |
resp = post( | |
f'http://{sys.argv[2]}/holders', | |
data=dumps(data) | |
) | |
# TICKER | |
else: | |
data = { | |
"ticker": ticker, | |
"frequency": 60, | |
"discord_bot_token": token | |
} | |
if currency: | |
data['currency'] = currency | |
if extend_activity: | |
data['extend_activity'] = True | |
if decimals: | |
data['decimals'] = int(decimals) | |
if decorator: | |
data['decorator'] = decorator | |
if currency_symbol: | |
data['currency_symbol'] = currency_symbol | |
if pair: | |
if pair.startswith('flip-'): | |
data['pair_flip'] = True | |
data['pair'] = pair.split('flip-', 1).pop() | |
else: | |
data['pair'] = pair | |
if typ.startswith('crypto'): | |
data['crypto'] = True | |
data['name'] = ticker | |
if typ.startswith('crypto-'): | |
data['ticker'] = typ.split('crypto-', 1).pop() | |
else: | |
data['ticker'] = '' | |
else: | |
data['crypto'] = False | |
if typ != 'stock': | |
data['name'] = typ | |
if len(sys.argv) == 4: | |
data['frequency'] = 10 | |
data['set_nickname'] = True | |
data['set_color'] = True | |
if activity: | |
data['activity'] = activity | |
if cid: | |
data['client_id'] = cid | |
resp = post( | |
f'http://{sys.argv[2]}/ticker', | |
data=dumps(data) | |
) | |
print(resp.status_code) | |
print(resp.text) | |
item = get_cur.fetchone() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment