2021-12-06 15:32:27 +00:00
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
from config import Config
|
|
|
|
|
from core.elements import Plain, Image
|
|
|
|
|
|
|
|
|
|
from core.utils.bot import get_url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets_path = os.path.abspath('./assets/arcaea')
|
|
|
|
|
api_url = Config("arcapi_url")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def get_info(usercode):
|
2021-12-21 11:08:17 +00:00
|
|
|
|
headers = {"User-Agent": Config('arcapi_agent')}
|
2021-12-07 11:28:59 +00:00
|
|
|
|
try:
|
|
|
|
|
get_ = await get_url(api_url + "user/info?usercode=" + usercode + '&recent=1', headers=headers, fmt='json')
|
|
|
|
|
except Exception:
|
|
|
|
|
return [Plain('查询失败。')]
|
2021-12-06 15:32:27 +00:00
|
|
|
|
print(get_)
|
|
|
|
|
if get_["status"] == 0:
|
|
|
|
|
recent = get_['content']["recent_score"]
|
|
|
|
|
if len(recent) < 0:
|
|
|
|
|
return [Plain('此用户无游玩记录。')]
|
|
|
|
|
recent = recent[0]
|
2021-12-07 11:28:59 +00:00
|
|
|
|
try:
|
|
|
|
|
get_songinfo = await get_url(api_url + "song/info?songname=" + recent['song_id'], headers=headers, fmt='json')
|
|
|
|
|
except:
|
|
|
|
|
return [Plain('查询失败。')]
|
2021-12-06 15:32:27 +00:00
|
|
|
|
difficulty = '???'
|
|
|
|
|
if recent['difficulty'] == 0:
|
|
|
|
|
difficulty = 'PST'
|
|
|
|
|
if recent['difficulty'] == 1:
|
|
|
|
|
difficulty = 'PRS'
|
|
|
|
|
if recent['difficulty'] == 2:
|
|
|
|
|
difficulty = 'FTR'
|
|
|
|
|
if recent['difficulty'] == 3:
|
|
|
|
|
difficulty = 'BYD'
|
|
|
|
|
trackname = get_songinfo['content']['title_localized']['en']
|
|
|
|
|
imgpath = f'{assets_path}/songimg/{recent["song_id"]}.jpg'
|
|
|
|
|
realptt = get_songinfo['content']['difficulties'][recent['difficulty']]['ratingReal']
|
|
|
|
|
ptt = recent['rating']
|
|
|
|
|
score = recent['score']
|
|
|
|
|
shiny_pure = recent['shiny_perfect_count']
|
|
|
|
|
pure = recent['perfect_count']
|
|
|
|
|
far = recent['near_count']
|
|
|
|
|
lost = recent['miss_count']
|
2021-12-07 11:28:59 +00:00
|
|
|
|
try:
|
|
|
|
|
get_userinfo = await get_url(api_url + "user/info?usercode=" + usercode, headers=headers, fmt='json')
|
|
|
|
|
except:
|
|
|
|
|
return [Plain('查询失败。')]
|
2021-12-06 15:32:27 +00:00
|
|
|
|
username = get_userinfo['content']['name']
|
|
|
|
|
usrptt = int(get_userinfo['content']['rating']) / 100
|
|
|
|
|
return [Plain(f'{username}({usrptt})的最近游玩记录:\n'
|
|
|
|
|
f'{trackname}({difficulty})\n'
|
2021-12-22 12:48:02 +00:00
|
|
|
|
f'Score:{score}\n'
|
2021-12-06 15:32:27 +00:00
|
|
|
|
f'Pure:{pure}({shiny_pure})\n'
|
|
|
|
|
f'Far:{far}\n'
|
|
|
|
|
f'Lost:{lost}\n'
|
|
|
|
|
f'Potential:{realptt} -> {ptt}'), Image(imgpath)]
|
|
|
|
|
elif get_["status"] == -1:
|
|
|
|
|
return [Plain('[-1] 非法的好友码。')]
|
|
|
|
|
elif get_["status"] == -4:
|
|
|
|
|
return [Plain('[-4] 查询失败。')]
|
|
|
|
|
elif get_["status"] == -6:
|
|
|
|
|
return [Plain('[-6] 没有游玩记录。')]
|
|
|
|
|
else:
|
2021-12-06 15:41:13 +00:00
|
|
|
|
return [Plain('查询失败。' + str(get_))]
|