diff --git a/worker/k.py b/worker/k.py new file mode 100644 index 0000000..eb0e9c1 --- /dev/null +++ b/worker/k.py @@ -0,0 +1,40 @@ +from zzcore import StdAns +import requests + + +class Ans(StdAns): + def GETMSG(self): + try: + picurl, status = Kemomimi() + except: + print() + msg = '' + if status == 200: + # 显示图标 + # msg += f'[CQ:xml,data=' \ + # f'' \ + # f'来喽!!' \ + # f'' \ + # f'' \ + # f']' + msg = f'[CQ:xml,data=\n' \ + f'\n' \ + f'ケモミミちゃん:Kemomimi酱来了~\n' \ + f' ' \ + f']' + # 显示卡片图片 + # msg += f'[CQ:cardimage,file={picurl},maxheight=200]' + else: + msg += '图库丢了哦,不是咱的问题呀!' + return msg + + +def Kemomimi(): + url = "http://api.aya1.xyz:6/random0.php" + # 获取重定向后的地址 + imgurl = requests.get(url).url + status = requests.get(url).status_code + # print(imgurl)\ + return imgurl, status diff --git a/worker/mner.py b/worker/mner.py new file mode 100644 index 0000000..3f06d05 --- /dev/null +++ b/worker/mner.py @@ -0,0 +1,27 @@ +import requests + +from zzcore import StdAns + + +class Ans(StdAns): + def GETMSG(self): + if len(self.parms) < 2: + msg = '请输入包名 如:/mner yjun' + return msg + else: + msg = '' + req = requests.get( + url='https://aur.archlinux.org/rpc/?v=5&type=search&by=maintainer&arg=' + self.parms[1]).json() + count = req['resultcount'] + if count != 0: + msg += '工具人 ' + self.parms[1] + ' 打包了' + str(count) + '个软件\n' + soft='' + if count < 5: + # soft = list() + for i in range(count): + soft= req['results'][i]['Name'] + else: + for i in range(5): + soft+=req['results'][i]['Name']+'\n' + soft+='....' + return msg+soft diff --git a/worker/pkg.py b/worker/pkg.py new file mode 100644 index 0000000..4cca9ad --- /dev/null +++ b/worker/pkg.py @@ -0,0 +1,62 @@ +import requests +import time +from zzcore import StdAns + + +class Ans(StdAns): + # AllowGroup = [874769998,596678277,7343311] + + def GETMSG(self): + if len(self.parms) < 2: + msg = '请输入包名 如:/pkg linux testing 查询 Testing 的 linux 软件' + return msg + elif self.parms[1] == 'help': + msg = '使用 /pkg 包名 查询Core, Extra, Testing, Multilib, Multilib-Testing, ' \ + 'Community, Community-Testing仓库以及AUR的软件 ' + return msg + else: + repo = str() + try: + if len(self.parms) > 1: + repo = '&repo=' + self.parms[2].capitalize() + except: + print('repo empty') + req = requests.get( + url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] + repo).json() + if not req['results']: + req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=info&arg=' + self.parms[1]).json() + if req['resultcount'] == 0: + req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=search&arg=' + self.parms[1]).json() + # print(req) + if req['resultcount'] > 0: + name = '包名:' + req['results'][0]['Name'] + # pkgname = req['results'][0]['pkgname'] + version = '版本:' + req['results'][0]['Version'] + description = '描述:' + req['results'][0]['Description'] + maintainer = '维护:' + str(req['results'][0]['Maintainer']) + numvotes = '投票:' + str(req['results'][0]['NumVotes']) + updatetime = req['results'][0]['LastModified'] + updatetime = time.localtime(int(updatetime)) + updatetime = time.strftime("%Y-%m-%d %H:%M:%S", updatetime) + url = req['results'][0]['URL'] + if url is None: + url = '链接:None' + else: + url = '链接:' + url + msg = '仓库:AUR\n' + name + '\n' + version + '\n' + description + '\n' + maintainer \ + + '\n' + numvotes + '\n更新日期:' + updatetime + '\n' + url + return msg + else: + repo = req['results'][0]['repo'] + pkgname = req['results'][0]['pkgname'] + pkgver = req['results'][0]['pkgver'] + '\n' + pkgdesc = req['results'][0]['pkgdesc'] + url = req['results'][0]['url'] + updatetime = req['results'][0]['last_update'] + updatetime = updatetime.replace('T', ' ') + updatetime = updatetime[0:16] + '\n' + # return repo,pkgname,pkgver,pkgdesc,url + # print('仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '\n描述:' + pkgdesc + '\n上游:' + url + '\n') + msg = '仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '描述:' + pkgdesc + '\n更新日期:' \ + + updatetime + '上游:' + url + return msg 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 diff --git a/worker/xs.py b/worker/xs.py new file mode 100644 index 0000000..4830669 --- /dev/null +++ b/worker/xs.py @@ -0,0 +1,16 @@ +from zzcore import StdAns, mysakuya +import requests + +class Ans(StdAns): + def GETMSG(self): + msg='' + try: + msg += xs() + except: + msg += '可能是机器人笑死了!' + return msg + +def xs(): + url = "http://api-x.aya1.xyz:6/" + text = requests.get(url=url).text + return text