XZZ/worker/music.py

24 lines
727 B
Python
Raw Normal View History

2020-02-29 14:58:14 +08:00
from zzcore import StdAns
import requests
class Ans(StdAns):
def GETMSG(self):
if len(self.parms) < 2:
return '不加参数是坏文明!'
2020-03-16 15:42:57 +08:00
url = 'https://api.imjad.cn/cloudmusic/'
2020-02-29 14:58:14 +08:00
params = {
2020-03-16 15:42:57 +08:00
'type': 'search',
'search_type': 1,
2020-02-29 14:58:14 +08:00
'limit': 1,
2020-03-16 15:42:57 +08:00
's':self.raw_msg['message'][6:],
2020-02-29 14:58:14 +08:00
}
try:
resp = requests.get(url=url,params=params).json()
musicid = resp['result']['songs'][0]['id']
msg = '[CQ:music,type=163,id='+ str(musicid)+']'
except Exception as e:
print(e)
msg = '什么东西坏掉了,大概是网易云吧...不可能是咱!'
return msg