2021-02-11 12:41:07 +00:00
|
|
|
import json
|
|
|
|
|
2021-07-27 17:42:47 +00:00
|
|
|
from core.elements import MessageSession, Plain, Image
|
2021-08-07 07:56:48 +00:00
|
|
|
from core.utils import get_url
|
2021-02-11 12:41:07 +00:00
|
|
|
|
|
|
|
|
2021-07-27 17:42:47 +00:00
|
|
|
async def cytoid_profile(msg: MessageSession):
|
|
|
|
profile_url = 'http://services.cytoid.io/profile/' + msg.parsed_msg['UserID']
|
2021-02-11 12:41:07 +00:00
|
|
|
profile = json.loads(await get_url(profile_url))
|
2021-02-12 16:44:53 +00:00
|
|
|
if 'statusCode' in profile:
|
|
|
|
if profile['statusCode'] == 404:
|
2021-07-27 17:42:47 +00:00
|
|
|
await msg.sendMessage('发生错误:此用户不存在。')
|
2021-02-12 16:44:53 +00:00
|
|
|
return
|
2021-02-11 12:41:07 +00:00
|
|
|
uid = profile['user']['uid']
|
|
|
|
nick = profile['user']['name']
|
|
|
|
if nick is None:
|
|
|
|
nick = False
|
|
|
|
avatar = profile['user']['avatar']['large']
|
|
|
|
basicExp = profile['exp']['basicExp']
|
|
|
|
levelExp = profile['exp']['levelExp']
|
|
|
|
totalExp = profile['exp']['totalExp']
|
|
|
|
currentLevel = profile['exp']['currentLevel']
|
|
|
|
nextLevelExp = profile['exp']['nextLevelExp']
|
2021-02-11 12:42:19 +00:00
|
|
|
rating = profile['rating']
|
2021-02-11 12:41:07 +00:00
|
|
|
grade = profile['grade']
|
|
|
|
grade = f'A: {grade["A"]}, B: {grade["B"]}, C: {grade["C"]}, D: {grade["D"]}, F: {grade["F"]}, S: {grade["S"]}, SS: {grade["SS"]}'
|
2021-02-19 12:18:47 +00:00
|
|
|
text = f'UID: {uid}\n' + \
|
|
|
|
(f'Nickname: {nick}\n' if nick else '') + \
|
|
|
|
f'BasicExp: {basicExp}\n' + \
|
|
|
|
f'LevelExp: {levelExp}\n' + \
|
|
|
|
f'TotalExp: {totalExp}\n' + \
|
|
|
|
f'CurrentLevel: {currentLevel}\n' + \
|
|
|
|
f'NextLevelExp: {nextLevelExp}\n' + \
|
|
|
|
f'Rating: {rating}\n' + \
|
|
|
|
f'Grade: {grade}'
|
2021-07-27 17:42:47 +00:00
|
|
|
msgchain = [Image(url=avatar), Plain(text)]
|
|
|
|
await msg.sendMessage(msgchain)
|