56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
|
from requests import post
|
||
|
from json import dumps, loads
|
||
|
|
||
|
global url_pre
|
||
|
url_pre = 'https://cdm-api.del.pw/'
|
||
|
|
||
|
|
||
|
def call(api_url, data, pre=True, fix=True):
|
||
|
if pre:
|
||
|
response = post(url_pre + api_url, data=dumps(data))
|
||
|
else:
|
||
|
response = post(api_url, data=dumps(data))
|
||
|
#print(response.status_code)
|
||
|
#print(response.text)
|
||
|
try:
|
||
|
if fix:
|
||
|
return response.text.replace('"', '')
|
||
|
else:
|
||
|
return response.text
|
||
|
except:
|
||
|
return response.text
|
||
|
|
||
|
def check_token(nick, token):
|
||
|
data = {'nick': nick, 'token': token}
|
||
|
return call('api/check_token/', data)
|
||
|
|
||
|
def check_bal(nick, token):
|
||
|
data = {'nick': nick, 'token': token}
|
||
|
return call('api/check_bal/', data)
|
||
|
|
||
|
def get_time2cdm(nick, token):
|
||
|
data = {'nick': nick, 'token': token}
|
||
|
return call('api/get_time2cdm/', data)
|
||
|
|
||
|
def get_stat(nick, token, date = None):
|
||
|
data = {'nick': nick, 'token': token}
|
||
|
if date:
|
||
|
data['date'] = date
|
||
|
return loads(call('api/get_stat/', data, fix=False))
|
||
|
|
||
|
def transfer_coins(nick, token, dst_nick, amount):
|
||
|
data = {'nick': nick, 'token': token, 'dst_nick': dst_nick, 'amount': amount}
|
||
|
return call('api/transfer_coins/', data)
|
||
|
|
||
|
def gen_fp(nick, token, amount, chat_id):
|
||
|
data = {'nick': nick, 'token': token, 'amount': amount, 'chat_id': chat_id}
|
||
|
return call('api/gen_fp/', data)
|
||
|
|
||
|
def list_fp(nick, token):
|
||
|
data = {'nick': nick, 'token': token}
|
||
|
return call('api/list_fp/', data)
|
||
|
|
||
|
def del_fp(nick, token, fp_id):
|
||
|
data = {'nick': nick, 'token': token, 'fp_id': fp_id}
|
||
|
return call('api/del_fp/', data)
|