Merge branch 'master' of github.com:Si-Huan/XZZ into master

This commit is contained in:
SiHuan 2020-08-22 22:20:32 +08:00
commit a4ea487c8e

View file

@ -1,10 +1,11 @@
from zzcore import StdAns
import requests
import json
class Ans(StdAns):
def GETMSG(self):
if len(self.parms) < 2:
return '歌名都不指定就能搜到歌了?'
return '不加参数是坏文明!'
url = 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp'
params = {
'ct': 24,
@ -23,14 +24,15 @@ class Ans(StdAns):
'w':self.raw_msg['message'][8:],
}
try:
resp = requests.get(url=url,params=params)
resp = re.match("callback%((.+)%)", resp).json()
resp = requests.get(url=url,params=params).text
resp = json.loads(list(resp.split('callback('))[1][:-1])
# print(resp)
if resp['data']['song']['totalnum'] == 0:
return '辣鸡曲库没这首,或者你的关键词有问题'
return '啊嘞嘞好像没有诶qaq'
mid = resp['data']['song']['list'][0]['mid']
mname = resp['data']['song']['list'][0]['name']
msg = '[CQ:share,url=https://y.qq.com/n/yqq/song/' + str(mid) + '.html,title=' + str(mname) + ']'
except Exception as e:
print(e)
msg = '辣鸡q音太弟弟了'
msg = '什么东西坏掉了,大概是疼讯吧...不可能是咱!'
return msg