This commit is contained in:
SiHuan 2021-01-26 23:58:00 +08:00
parent 6d0c37351d
commit 059f067505
2 changed files with 24 additions and 1 deletions

View file

@ -6,7 +6,7 @@ def ZZRouter(data):
gid = data['group_id']
role = data['sender']['role']
mid = data['message_id']
parms = str.split(data['message'][1:])
parms = str.split(data['message'][0]['data']['text'][1:])
print(uid, gid, role, parms)
if parms == []:
parms[0] = 'help'

23
worker/wait.py Normal file
View file

@ -0,0 +1,23 @@
from zzcore import StdAns
import re
import requests
class Ans(StdAns):
def GETMSG(self):
try:
url = self.raw_msg['message'][1]['data']['url']
resp = requests.get(
f"https://trace.moe/api/search?url={url}").json()['docs'][0]
except:
return "There something wrong."
video_url = f"https://media.trace.moe/video/{resp['anilist_id']}/{resp['filename']}?t={resp['at']}&token={resp['tokenthumb']}"
m, s = divmod(float(resp['at']), 60)
h, m = divmod(m, 60)
print("%02d:%02d:%02d" % (h, m, s))
text = f"{resp['title_native']}\n{resp['title_chinese']}\nEP#{resp['episode']} {h:02.0f}:{m:02.0f}:{s:02.0f}\n{resp['similarity'][:5]} similarity"
msg = f"[CQ:video,file={video_url}]\n{text}"
return msg