Almost telegram integration + Bybit started

This commit is contained in:
2025-04-24 21:19:59 +03:00
parent af240b9acb
commit 4bb472a57e
6 changed files with 271 additions and 68 deletions

78
src/arbus.py Normal file
View File

@ -0,0 +1,78 @@
import json
import options
async def parseParams(params):
paramsList = params.split()
paramsDict = {}
for i in range(len(options.paramsLines)):
paramsDict[options.paramsLines[i]] = paramsList[i]
return paramsDict
async def toDictPairParams(pair: str, params):
paramsList = params.split()
if len(paramsList) != len(options.paramsLines):
return -1
paramsDict = {pair: {}}
for i in range(len(options.paramsLines)):
paramsDict[pair][options.paramsLines[i]] = paramsList[i]
return paramsDict
async def checkPair(pair: str):
currentData = {}
try:
with open('data.json', 'r') as f:
currentData = json.load(f)
except json.decoder.JSONDecodeError as e:
print('WARNING: JSON file is empty! Ignore if your installation is fresh.')
if pair in currentData:
print(pair, ' exists in data file.')
return 1
else:
print(pair, ' not found in data file.')
return 0
async def deletePair(pair: str):
currentData = {}
try:
with open('data.json', 'r') as f:
currentData = json.load(f)
except json.decoder.JSONDecodeError as e:
print('WARNING: JSON file is empty! Ignore if your installation is fresh.')
if pair in currentData:
print(pair, ' exists in data file.')
del currentData[pair]
with open('data.json', 'w', encoding = 'utf-8') as f:
json.dump(currentData, f, ensure_ascii = False, indent = 4)
return 0
else:
print(pair, ' not found in data file.')
return -1
async def mainWrapper(pair: str, params):
newData = await toDictPairParams(pair, params)
if newData == -1:
return -1
currentData = {}
try:
with open('data.json', 'r') as f:
currentData = json.load(f)
except json.decoder.JSONDecodeError as e:
print('WARNING: JSON file is empty! Ignore if your installation is fresh.')
if pair in currentData:
print(pair, ' already exists.')
return -2
else:
with open('data.json', 'w', encoding = 'utf-8') as f:
currentData.update(newData)
json.dump(currentData, f, ensure_ascii = False, indent = 4)
print(pair, ' was added!')
return 0