use array msg
This commit is contained in:
parent
00b9425921
commit
816e0ef2c3
17 changed files with 38 additions and 22 deletions
|
@ -2,7 +2,14 @@
|
||||||
"anonymous": "None",
|
"anonymous": "None",
|
||||||
"font": 1501544,
|
"font": 1501544,
|
||||||
"group_id": 959613000,
|
"group_id": 959613000,
|
||||||
"message": "/ping",
|
"message": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text": "/ping"
|
||||||
|
},
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
],
|
||||||
"message_id": 2071,
|
"message_id": 2071,
|
||||||
"message_type": "group",
|
"message_type": "group",
|
||||||
"post_type": "message",
|
"post_type": "message",
|
||||||
|
|
15
test.py
15
test.py
|
@ -1,10 +1,12 @@
|
||||||
from worker import emmm
|
from worker import emmm
|
||||||
debug = True
|
debug = True
|
||||||
|
|
||||||
|
|
||||||
def de(e):
|
def de(e):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG '+str(e))
|
print('DEBUG '+str(e))
|
||||||
|
|
||||||
|
|
||||||
print("开始测试咯,在 '>' 后面输入n你的消息,不用加 '/'")
|
print("开始测试咯,在 '>' 后面输入n你的消息,不用加 '/'")
|
||||||
inp = input('>')
|
inp = input('>')
|
||||||
while(inp):
|
while(inp):
|
||||||
|
@ -12,14 +14,21 @@ while(inp):
|
||||||
worker = parms[0]
|
worker = parms[0]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
package = __import__(name='worker.'+ worker, fromlist=worker)
|
package = __import__(name='worker.' + worker, fromlist=worker)
|
||||||
Ans_ = getattr(package,'Ans')
|
Ans_ = getattr(package, 'Ans')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
de(e)
|
de(e)
|
||||||
Ans_ = emmm.Ans
|
Ans_ = emmm.Ans
|
||||||
de(Ans_)
|
de(Ans_)
|
||||||
try:
|
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()
|
Message = Ans.GETMSG()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Message = ' Error:\n'+str(e)
|
Message = ' Error:\n'+str(e)
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Ans(StdAns):
|
||||||
if len(self.parms) < 2:
|
if len(self.parms) < 2:
|
||||||
return '不加参数是坏文明!'
|
return '不加参数是坏文明!'
|
||||||
try:
|
try:
|
||||||
msg = str(bc(self.raw_msg['message'][5:]))
|
msg = str(bc(self.raw_msg['raw_message'][5:]))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
return msg
|
return msg
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Ans(StdAns):
|
||||||
|
|
||||||
url = 'https://api.cognitive.microsoft.com/bing/v7.0/search'
|
url = 'https://api.cognitive.microsoft.com/bing/v7.0/search'
|
||||||
params = {
|
params = {
|
||||||
'q':self.raw_msg['message'][5:],
|
'q':self.raw_msg['raw_message'][5:],
|
||||||
'count': 1,
|
'count': 1,
|
||||||
'mkt': 'zh-CN'
|
'mkt': 'zh-CN'
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Ans(StdAns):
|
||||||
|
|
||||||
def GETMSG(self):
|
def GETMSG(self):
|
||||||
groups = self.getgroups()
|
groups = self.getgroups()
|
||||||
text = self.raw_msg['message'][11:]
|
text = self.raw_msg['raw_message'][11:]
|
||||||
gid = self.gid
|
gid = self.gid
|
||||||
|
|
||||||
for g in groups:
|
for g in groups:
|
||||||
|
|
|
@ -6,14 +6,14 @@ class Ans(StdAns):
|
||||||
if len(self.parms) < 2:
|
if len(self.parms) < 2:
|
||||||
return '不加参数是坏文明!'
|
return '不加参数是坏文明!'
|
||||||
|
|
||||||
if mysakuya(self,self.raw_msg['message']) == False:
|
if mysakuya(self,self.raw_msg['raw_message']) == False:
|
||||||
return "不许你们说咲夜!!"
|
return "不许你们说咲夜!!"
|
||||||
|
|
||||||
r = random.randint(1,3)
|
r = random.randint(1,3)
|
||||||
if r == 1:
|
if r == 1:
|
||||||
msg = self.raw_msg['message'][6:]
|
msg = self.raw_msg['raw_message'][6:]
|
||||||
elif r == 2:
|
elif r == 2:
|
||||||
msg = "汝以为咱会复读的嘛!\n(╯' - ')╯︵ ┻━┻\n" + self.raw_msg['message'][5:]
|
msg = "汝以为咱会复读的嘛!\n(╯' - ')╯︵ ┻━┻\n" + self.raw_msg['raw_message'][5:]
|
||||||
elif r == 3:
|
elif r == 3:
|
||||||
msg = '咱才不做复读机。→_→'
|
msg = '咱才不做复读机。→_→'
|
||||||
return msg
|
return msg
|
|
@ -12,7 +12,7 @@ class Ans(StdAns):
|
||||||
def GETMSG(self):
|
def GETMSG(self):
|
||||||
if self.parms:
|
if self.parms:
|
||||||
|
|
||||||
if mysakuya(self, self.raw_msg['message']) == False:
|
if mysakuya(self, self.raw_msg['raw_message']) == False:
|
||||||
return "咲夜是最完美的!!"
|
return "咲夜是最完美的!!"
|
||||||
|
|
||||||
return '咱也不知道' + self.parms[0] + '是啥呢~'
|
return '咱也不知道' + self.parms[0] + '是啥呢~'
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Ans(StdAns):
|
||||||
if len(self.parms) < 2:
|
if len(self.parms) < 2:
|
||||||
return '不加参数是坏文明!'
|
return '不加参数是坏文明!'
|
||||||
|
|
||||||
if mysakuya(self, self.raw_msg['message']) == False:
|
if mysakuya(self, self.raw_msg['raw_message']) == False:
|
||||||
return "不许你们说咲夜!!"
|
return "不许你们说咲夜!!"
|
||||||
|
|
||||||
msg = f"[CQ:reply,id={self.raw_msg['message_id']}]"
|
msg = f"[CQ:reply,id={self.raw_msg['message_id']}]"
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Ans(StdAns):
|
||||||
elif cmd == 'list':
|
elif cmd == 'list':
|
||||||
msg = getList()
|
msg = getList()
|
||||||
elif cmd == 'say':
|
elif cmd == 'say':
|
||||||
saywhat = self.raw_msg['message'][8:]
|
saywhat = self.raw_msg['raw_message'][8:]
|
||||||
msg = say(saywhat)
|
msg = say(saywhat)
|
||||||
else:
|
else:
|
||||||
msg = '汝是不是在mc后面添加了奇怪的参数,咱可只知道 status list 和 say。'
|
msg = '汝是不是在mc后面添加了奇怪的参数,咱可只知道 status list 和 say。'
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Ans(StdAns):
|
||||||
url = 'http://inuyasha.love:8001/search'
|
url = 'http://inuyasha.love:8001/search'
|
||||||
params = {
|
params = {
|
||||||
'limit': 1,
|
'limit': 1,
|
||||||
'keywords':self.raw_msg['message'][6:],
|
'keywords':self.raw_msg['raw_message'][6:],
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
resp = requests.get(url=url,params=params).json()
|
resp = requests.get(url=url,params=params).json()
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Ans(StdAns):
|
||||||
if len(self.parms) < 2:
|
if len(self.parms) < 2:
|
||||||
return '不加参数是坏文明!'
|
return '不加参数是坏文明!'
|
||||||
|
|
||||||
domain = self.raw_msg['message'][4:]
|
domain = self.raw_msg['raw_message'][4:]
|
||||||
try:
|
try:
|
||||||
answer = check_output(['nslookup',domain],shell=False,timeout=4)
|
answer = check_output(['nslookup',domain],shell=False,timeout=4)
|
||||||
msg = bytes.decode(answer)
|
msg = bytes.decode(answer)
|
||||||
|
|
|
@ -76,7 +76,7 @@ class Ans(StdAns):
|
||||||
return '初始化完成!请使用\n /pcr 血量 xxxx \n 来设置第一周目第一个Boss的总血量。'
|
return '初始化完成!请使用\n /pcr 血量 xxxx \n 来设置第一周目第一个Boss的总血量。'
|
||||||
|
|
||||||
if cmd == '登记':
|
if cmd == '登记':
|
||||||
nickname = self.raw_msg['message'][8:]
|
nickname = self.raw_msg['raw_message'][8:]
|
||||||
if nickname:
|
if nickname:
|
||||||
player = {
|
player = {
|
||||||
'id':nickname,
|
'id':nickname,
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Ans(StdAns):
|
||||||
'flag_qc': 0,
|
'flag_qc': 0,
|
||||||
'p': 1,
|
'p': 1,
|
||||||
'n': 20,
|
'n': 20,
|
||||||
'w':self.raw_msg['message'][8:],
|
'w':self.raw_msg['raw_message'][8:],
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
resp = requests.get(url=url,params=params).text
|
resp = requests.get(url=url,params=params).text
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Ans(StdAns):
|
||||||
'''
|
'''
|
||||||
lang = self.parms[1]
|
lang = self.parms[1]
|
||||||
i = 6 + len(lang)
|
i = 6 + len(lang)
|
||||||
content = self.raw_msg['message'][i:]
|
content = self.raw_msg['raw_message'][i:]
|
||||||
try :
|
try :
|
||||||
langconfig = LANGS[lang]
|
langconfig = LANGS[lang]
|
||||||
name = langconfig['filename']
|
name = langconfig['filename']
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Ans(StdAns):
|
||||||
if len(self.parms) < 2:
|
if len(self.parms) < 2:
|
||||||
text = "想让我说点什么呢?"
|
text = "想让我说点什么呢?"
|
||||||
else:
|
else:
|
||||||
text = self.raw_msg['message'][5:]
|
text = self.raw_msg['raw_message'][5:]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
b = tts(text)
|
b = tts(text)
|
||||||
|
|
|
@ -13,10 +13,10 @@ class Ans(StdAns):
|
||||||
return "There something wrong."
|
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 = 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)
|
m, s = divmod(float(resp['at']), 60)
|
||||||
h, m = divmod(m, 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"
|
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}"
|
msg = f"[CQ:video,file={video_url}]\n{text}"
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Ans(StdAns):
|
||||||
return '不加参数是坏文明!'
|
return '不加参数是坏文明!'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = wolframsearch(self.raw_msg['message'][9:])
|
res = wolframsearch(self.raw_msg['raw_message'][9:])
|
||||||
msg = next(res.results).text
|
msg = next(res.results).text
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
Loading…
Reference in a new issue