use array msg
This commit is contained in:
parent
76ec3a3068
commit
ee6e02961d
17 changed files with 38 additions and 22 deletions
|
@ -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",
|
||||
|
|
15
test.py
15
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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
|
@ -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] + '是啥呢~'
|
||||
|
|
|
@ -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']}]"
|
||||
|
|
|
@ -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。'
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue