diff --git a/route.py b/route.py index 1faa2d4..06c8257 100644 --- a/route.py +++ b/route.py @@ -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' diff --git a/worker/wait.py b/worker/wait.py new file mode 100644 index 0000000..3da9244 --- /dev/null +++ b/worker/wait.py @@ -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 \ No newline at end of file