2021-02-11 12:41:07 +00:00
|
|
|
|
import re
|
2021-02-19 12:20:00 +00:00
|
|
|
|
|
2021-02-12 16:44:53 +00:00
|
|
|
|
from graia.application import MessageChain
|
2021-02-19 12:20:00 +00:00
|
|
|
|
from graia.application.message.elements.internal import Image
|
|
|
|
|
|
|
|
|
|
from core.template import sendMessage
|
2021-02-12 18:22:24 +00:00
|
|
|
|
from database import write_time, check_time
|
2021-02-19 12:20:00 +00:00
|
|
|
|
from .profile import cytoid_profile
|
|
|
|
|
from .rating import get_rating
|
2021-02-12 16:44:53 +00:00
|
|
|
|
|
2021-02-11 12:41:07 +00:00
|
|
|
|
|
|
|
|
|
async def cytoid(kwargs: dict):
|
|
|
|
|
command = kwargs['trigger_msg']
|
|
|
|
|
command = re.sub('cytoid ', '', command)
|
|
|
|
|
command_split = command.split(' ')
|
|
|
|
|
if command_split[0] == 'profile':
|
2021-02-12 16:44:53 +00:00
|
|
|
|
kwargs['trigger_msg'] = re.sub(r'^profile ', '', command)
|
2021-02-11 12:41:07 +00:00
|
|
|
|
await cytoid_profile(kwargs)
|
2021-02-12 16:44:53 +00:00
|
|
|
|
if command_split[0] in ['b30', 'r30']:
|
2021-02-12 18:22:24 +00:00
|
|
|
|
c = check_time(kwargs, 'cytoidrank', 300)
|
|
|
|
|
if not c:
|
|
|
|
|
write_time(kwargs, 'cytoidrank')
|
|
|
|
|
uid = re.sub(r'^.*?30 ', '', command)
|
|
|
|
|
img = await get_rating(uid, command_split[0])
|
|
|
|
|
if 'path' in img:
|
|
|
|
|
await sendMessage(kwargs, MessageChain.create([Image.fromLocalFile(img['path'])]))
|
|
|
|
|
if 'text' in img:
|
|
|
|
|
await sendMessage(kwargs, img['text'])
|
|
|
|
|
else:
|
2021-02-12 18:25:39 +00:00
|
|
|
|
await sendMessage(kwargs, f'距离上次执行已过去{int(-c)}秒,本命令的冷却时间为300秒。')
|
2021-02-11 12:41:07 +00:00
|
|
|
|
|
|
|
|
|
|
2021-02-12 16:44:53 +00:00
|
|
|
|
command = {'cytoid': cytoid}
|
2021-02-14 15:25:39 +00:00
|
|
|
|
help = {'cytoid': {'help': '~cytoid profile <uid> - 获取一个用户的Cytoid账号信息。\n' +
|
|
|
|
|
'~cytoid b30 <uid> - 获取一个用户的Best30信息。\n' +
|
|
|
|
|
'~cytoid r30 <uid> - 获取一个用户的Recent30信息。'}}
|