forked from lulu666lulu/pcrjjc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueryapi.py
26 lines (21 loc) · 1.01 KB
/
queryapi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from hoshino.aiorequests import get
import time
import json
apiroot = 'https://help.tencentbot.top'
async def getprofile(viewer_id: int, interval: int = 1, full: bool = False) -> dict:
reqid = json.loads((await (await get(f'{apiroot}/enqueue?full={full}&target_viewer_id={viewer_id}', timeout=5)).content).decode('utf8'))['reqeust_id']
if reqid is None:
return "id err"
while True:
query = json.loads((await (await get(f'{apiroot}/query?request_id={reqid}', timeout=5)).content).decode('utf8'))
status = query['status']
if status == 'done':
return query['data']
elif status == 'queue':
time.sleep(interval)
else: # notfound or else
return "queue"
'''
def queryarena(defs: list, page: int) -> dict:
return json.loads(requests.get(f'{apiroot}/arena?def={",".join([str(x) for x in defs])}&page={page}').content.decode('utf8'))
print(queryarena([101001,102601,107601,102101,100701], 0))#page must under 9'''