diff --git a/worker/song.py b/worker/song.py new file mode 100644 index 0000000..02e4368 --- /dev/null +++ b/worker/song.py @@ -0,0 +1,29 @@ +from zzcore import StdAns +import requests +import urllib3 +urllib3.disable_warnings() + +class Ans(StdAns): + def GETMSG(self): + # self.parms[] + if len(self.parms) < 2: + return '不加参数是坏文明!' + url = 'https://music.xmengnet.cn/api' + + try: + # print(self.parms[1]) + getid = requests.get(url + '/search?keywords=' + self.raw_msg['raw_message'][5:], verify=False).json() + id = getid['result']['songs'][0]['id'] + # print(id) + downurl = requests.get(url + '/song/url?id=' + str(id), verify=False).json() + # print(downurl) + down = downurl['data'][0]['url'] + song = getid['result']['songs'][0]['name'] + '-' \ + + getid['result']['songs'][0]['artists'][0]['name'] + msg = f"[CQ:reply,id={self.raw_msg['message_id']}]" + return msg+song+'的下载地址为:'+down + # msg = f'[CQ:music,type=163,id={id}]' + except Exception as e: + print(e) + msg = '什么东西坏掉了,大概是网易云吧...不可能是咱!' + return msg diff --git a/worker/tiangou.py b/worker/tiangou.py new file mode 100644 index 0000000..06e2193 --- /dev/null +++ b/worker/tiangou.py @@ -0,0 +1,20 @@ +from zzcore import StdAns, mysakuya +import requests + +class Ans(StdAns): + #AllowGroup = [874769998,596678277] + def GETMSG(self): + msg = f"[CQ:reply,id={self.raw_msg['message_id']}]" + try: + msg += tiangou() + except: + msg += '可能是api坏掉了,可不是咱!' + return msg + +def tiangou(): + r = requests.get(url='https://api.muxiaoguo.cn/api/tiangourj').json() + # print(r) + msg = None + if r['msg'] == 'success': + msg = r['data']['comment'] + return msg