diff --git a/exmple.json b/exmple.json index bd8d1df..b06162b 100644 --- a/exmple.json +++ b/exmple.json @@ -2,7 +2,14 @@ "anonymous": "None", "font": 1501544, "group_id": 959613000, - "message": "/ping", + "message": [ + { + "data": { + "text": "/ping" + }, + "type": "text" + } + ], "message_id": 2071, "message_type": "group", "post_type": "message", diff --git a/test.py b/test.py index 8902ccc..665b303 100644 --- a/test.py +++ b/test.py @@ -1,10 +1,12 @@ from worker import emmm debug = True + def de(e): if debug: print('DEBUG '+str(e)) + print("开始测试咯,在 '>' 后面输入n你的消息,不用加 '/'") inp = input('>') while(inp): @@ -12,14 +14,21 @@ while(inp): worker = parms[0] try: - package = __import__(name='worker.'+ worker, fromlist=worker) - Ans_ = getattr(package,'Ans') + package = __import__(name='worker.' + worker, fromlist=worker) + Ans_ = getattr(package, 'Ans') except Exception as e: de(e) Ans_ = emmm.Ans de(Ans_) try: - Ans = Ans_(parms,uid=0,gid=0,role='owner',mid=1001, raw_msg={'message':'/' + inp, 'message_id' : '1001'}) + Ans = Ans_(parms, uid=0, gid=0, role='owner', mid=1001, raw_msg={'message': [ + { + "data": { + "text": f"/{inp}" + }, + "type": "text" + } + ], 'message_id': '1001', 'raw_message': f"/{inp}"}) Message = Ans.GETMSG() except Exception as e: Message = ' Error:\n'+str(e) diff --git a/worker/bbc.py b/worker/bbc.py index b654691..064d4f8 100644 --- a/worker/bbc.py +++ b/worker/bbc.py @@ -5,7 +5,7 @@ class Ans(StdAns): if len(self.parms) < 2: return '不加参数是坏文明!' try: - msg = str(bc(self.raw_msg['message'][5:])) + msg = str(bc(self.raw_msg['raw_message'][5:])) except Exception as e: msg = str(e) return msg diff --git a/worker/bing.py b/worker/bing.py index 0626aed..23fdd8f 100644 --- a/worker/bing.py +++ b/worker/bing.py @@ -10,7 +10,7 @@ class Ans(StdAns): url = 'https://api.cognitive.microsoft.com/bing/v7.0/search' params = { - 'q':self.raw_msg['message'][5:], + 'q':self.raw_msg['raw_message'][5:], 'count': 1, 'mkt': 'zh-CN' } diff --git a/worker/broadcast.py b/worker/broadcast.py index 3a993e5..87bbd8e 100644 --- a/worker/broadcast.py +++ b/worker/broadcast.py @@ -5,7 +5,7 @@ class Ans(StdAns): def GETMSG(self): groups = self.getgroups() - text = self.raw_msg['message'][11:] + text = self.raw_msg['raw_message'][11:] gid = self.gid for g in groups: diff --git a/worker/echo.py b/worker/echo.py index 4ac5437..859050a 100644 --- a/worker/echo.py +++ b/worker/echo.py @@ -6,14 +6,14 @@ class Ans(StdAns): if len(self.parms) < 2: return '不加参数是坏文明!' - if mysakuya(self,self.raw_msg['message']) == False: + if mysakuya(self,self.raw_msg['raw_message']) == False: return "不许你们说咲夜!!" r = random.randint(1,3) if r == 1: - msg = self.raw_msg['message'][6:] + msg = self.raw_msg['raw_message'][6:] elif r == 2: - msg = "汝以为咱会复读的嘛!\n(╯' - ')╯︵ ┻━┻\n" + self.raw_msg['message'][5:] + msg = "汝以为咱会复读的嘛!\n(╯' - ')╯︵ ┻━┻\n" + self.raw_msg['raw_message'][5:] elif r == 3: msg = '咱才不做复读机。→_→' return msg \ No newline at end of file diff --git a/worker/emmm.py b/worker/emmm.py index 614494f..3d94263 100644 --- a/worker/emmm.py +++ b/worker/emmm.py @@ -12,7 +12,7 @@ class Ans(StdAns): def GETMSG(self): if self.parms: - if mysakuya(self, self.raw_msg['message']) == False: + if mysakuya(self, self.raw_msg['raw_message']) == False: return "咲夜是最完美的!!" return '咱也不知道' + self.parms[0] + '是啥呢~' diff --git a/worker/hhsh.py b/worker/hhsh.py index 97df0ef..16af5c2 100644 --- a/worker/hhsh.py +++ b/worker/hhsh.py @@ -6,7 +6,7 @@ class Ans(StdAns): if len(self.parms) < 2: return '不加参数是坏文明!' - if mysakuya(self, self.raw_msg['message']) == False: + if mysakuya(self, self.raw_msg['raw_message']) == False: return "不许你们说咲夜!!" msg = f"[CQ:reply,id={self.raw_msg['message_id']}]" diff --git a/worker/mc.py b/worker/mc.py index 5a36c1a..92a847c 100644 --- a/worker/mc.py +++ b/worker/mc.py @@ -18,7 +18,7 @@ class Ans(StdAns): elif cmd == 'list': msg = getList() elif cmd == 'say': - saywhat = self.raw_msg['message'][8:] + saywhat = self.raw_msg['raw_message'][8:] msg = say(saywhat) else: msg = '汝是不是在mc后面添加了奇怪的参数,咱可只知道 status list 和 say。' diff --git a/worker/music.py b/worker/music.py index 6cb0b54..4119840 100644 --- a/worker/music.py +++ b/worker/music.py @@ -12,7 +12,7 @@ class Ans(StdAns): url = 'http://inuyasha.love:8001/search' params = { 'limit': 1, - 'keywords':self.raw_msg['message'][6:], + 'keywords':self.raw_msg['raw_message'][6:], } try: resp = requests.get(url=url,params=params).json() diff --git a/worker/ns.py b/worker/ns.py index 99e2764..44c3dc4 100644 --- a/worker/ns.py +++ b/worker/ns.py @@ -6,7 +6,7 @@ class Ans(StdAns): if len(self.parms) < 2: return '不加参数是坏文明!' - domain = self.raw_msg['message'][4:] + domain = self.raw_msg['raw_message'][4:] try: answer = check_output(['nslookup',domain],shell=False,timeout=4) msg = bytes.decode(answer) diff --git a/worker/pcr.py b/worker/pcr.py index d9a9d4d..dc1bd58 100644 --- a/worker/pcr.py +++ b/worker/pcr.py @@ -76,7 +76,7 @@ class Ans(StdAns): return '初始化完成!请使用\n /pcr 血量 xxxx \n 来设置第一周目第一个Boss的总血量。' if cmd == '登记': - nickname = self.raw_msg['message'][8:] + nickname = self.raw_msg['raw_message'][8:] if nickname: player = { 'id':nickname, diff --git a/worker/qymusic.py b/worker/qymusic.py index a616040..f22a38a 100644 --- a/worker/qymusic.py +++ b/worker/qymusic.py @@ -21,7 +21,7 @@ class Ans(StdAns): 'flag_qc': 0, 'p': 1, 'n': 20, - 'w':self.raw_msg['message'][8:], + 'w':self.raw_msg['raw_message'][8:], } try: resp = requests.get(url=url,params=params).text diff --git a/worker/run.py b/worker/run.py index 4fd1af6..ab41c91 100644 --- a/worker/run.py +++ b/worker/run.py @@ -54,7 +54,7 @@ class Ans(StdAns): ''' lang = self.parms[1] i = 6 + len(lang) - content = self.raw_msg['message'][i:] + content = self.raw_msg['raw_message'][i:] try : langconfig = LANGS[lang] name = langconfig['filename'] diff --git a/worker/talk.py b/worker/talk.py index 43e2580..ec0f305 100644 --- a/worker/talk.py +++ b/worker/talk.py @@ -9,7 +9,7 @@ class Ans(StdAns): if len(self.parms) < 2: text = "想让我说点什么呢?" else: - text = self.raw_msg['message'][5:] + text = self.raw_msg['raw_message'][5:] try: b = tts(text) diff --git a/worker/wait.py b/worker/wait.py index 3da9244..ab5eff4 100644 --- a/worker/wait.py +++ b/worker/wait.py @@ -13,10 +13,10 @@ class Ans(StdAns): return "There something wrong." video_url = f"https://media.trace.moe/video/{resp['anilist_id']}/{resp['filename']}?t={resp['at']}&token={resp['tokenthumb']}" - + video_url = video_url.replace("&","&").replace("[","[").replace("]","]").replace(",",",") m, s = divmod(float(resp['at']), 60) h, m = divmod(m, 60) - print("%02d:%02d:%02d" % (h, m, s)) + # 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}" diff --git a/worker/wolfram.py b/worker/wolfram.py index 9a0cdda..32769ce 100644 --- a/worker/wolfram.py +++ b/worker/wolfram.py @@ -13,7 +13,7 @@ class Ans(StdAns): return '不加参数是坏文明!' try: - res = wolframsearch(self.raw_msg['message'][9:]) + res = wolframsearch(self.raw_msg['raw_message'][9:]) msg = next(res.results).text except Exception as e: print(e)