Archived
1
0
Fork 0

changed cytoid module's cooldown function

This commit is contained in:
yzhh 2021-06-27 22:56:45 +08:00
parent e865cd6b49
commit beabce83f7
2 changed files with 5 additions and 4 deletions

View file

@ -19,13 +19,14 @@ async def cytoid(kwargs: dict):
if command_split[0] in ['b30', 'r30']:
c = database.check_time(kwargs, 'cytoidrank', 300)
if not c:
database.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'])
if img['status']:
database.write_time(kwargs, 'cytoidrank')
else:
await sendMessage(kwargs, f'距离上次执行已过去{int(-c)}本命令的冷却时间为300秒。')

View file

@ -25,7 +25,7 @@ async def get_rating(uid, query_type):
Profile_json = json.loads(await get_url(Profile_url))
if 'statusCode' in Profile_json:
if Profile_json['statusCode'] == 404:
return {'text': '发生错误:此用户不存在。'}
return {'status': False, 'text': '发生错误:此用户不存在。'}
ProfileId = Profile_json['user']['id']
ProfileRating = Profile_json['rating']
ProfileLevel = Profile_json['exp']['currentLevel']
@ -182,10 +182,10 @@ async def get_rating(uid, query_type):
savefilename = os.path.abspath(f'./cache/{str(uuid.uuid4())}.jpg')
b30img.convert("RGB").save(savefilename)
shutil.rmtree(workdir)
return {'path': savefilename}
return {'status': True, 'path': savefilename}
except Exception as e:
traceback.print_exc()
return {'text': '发生错误:' + str(e)}
return {'status': False, 'text': '发生错误:' + str(e)}
async def download_cover_thumb(uid):