From a9c9845ddda6ceeba02eac50bca00beccaf6292f Mon Sep 17 00:00:00 2001 From: xmengnet <51263043+xmengnet@users.noreply.github.com> Date: Sat, 15 May 2021 15:17:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4x86=E6=9E=B6=E6=9E=84?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worker/pkg.py | 69 ++++----------------------------------------------- 1 file changed, 5 insertions(+), 64 deletions(-) diff --git a/worker/pkg.py b/worker/pkg.py index 87047e4..93ca57c 100644 --- a/worker/pkg.py +++ b/worker/pkg.py @@ -16,7 +16,7 @@ class Ans(StdAns): return msg else: req = requests.get( - url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] + '&arch=x86_64').json() + url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] ).json() if req['results'] == []: req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=search&arg=' + self.parms[1]).json() # print(req) @@ -41,73 +41,14 @@ class Ans(StdAns): else: repo = req['results'][0]['repo'] pkgname = req['results'][0]['pkgname'] - pkgver = req['results'][0]['pkgver'] + 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] + 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 + '\n描述:' + pkgdesc + '\n更新日期:' \ - + updatetime[0:10] + '\n' + '\n上游:' + url - return msg -import requests -import time -from zzcore import StdAns - - -class Ans(StdAns): - # AllowGroup = [874769998,596678277,7343311] - - def GETMSG(self): - if len(self.parms) < 1: - msg = '请输入包名 如:/pkg linux' - return msg - elif self.parms[1] == 'help': - msg = '使用 /pkg 包名 查询Core, Extra, Testing, Multilib, Multilib-Testing, ' \ - 'Community, Community-Testing仓库的软件' - return msg - else: - req = requests.get( - url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] + '&arch=x86_64').json() - if 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'] - if req['results'][0]['Maintainer'] is None: - maintainer='' - else: - maintainer = '维护:' + 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 + '\n' - return msg - else: - repo = req['results'][0]['repo'] - pkgname = req['results'][0]['pkgname'] - pkgver = req['results'][0]['pkgver'] - pkgdesc = req['results'][0]['pkgdesc'] - url = req['results'][0]['url'] - updatetime = req['results'][0]['last_update'] - updatetime = updatetime.replace('T', ' ') - updatetime = updatetime[0:16] - # return repo,pkgname,pkgver,pkgdesc,url - # print('仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '\n描述:' + pkgdesc + '\n上游:' + url + '\n') - msg = '仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '\n描述:' + pkgdesc + '\n更新日期:' \ - + updatetime[0:10] + '\n上游:' + url + msg = '仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '描述:' + pkgdesc + '\n更新日期:' \ + + updatetime[0:10] + '\n上游:' + url return msg