修复bug

This commit is contained in:
xmengnet 2021-05-19 18:05:30 +08:00 committed by GitHub
parent 4e5c765d06
commit 39a76b7992

View file

@ -1,10 +1,10 @@
import requests import requests
import time
from zzcore import StdAns from zzcore import StdAns
class Ans(StdAns): class Ans(StdAns):
# AllowGroup = [874769998,596678277,7343311] #AllowGroup = [874769998,596678277,7343311]
def GETMSG(self): def GETMSG(self):
if len(self.parms) < 1: if len(self.parms) < 1:
@ -16,39 +16,36 @@ class Ans(StdAns):
return msg return msg
else: else:
req = requests.get( req = requests.get(
url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] ).json() url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] + '&arch=x86_64').json()
if req['results'] == []: if req['results'] == []:
req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=info&arg=' + self.parms[1]).json() req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=search&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) # print(req)
if req['resultcount'] > 0: if req['resultcount'] > 0:
name = '包名:' + req['results'][0]['Name'] name = '包名:' + req['results'][0]['Name']
# pkgname = req['results'][0]['pkgname'] # pkgname = req['results'][0]['pkgname']
version = '版本:' + req['results'][0]['Version'] version = '版本:' + req['results'][0]['Version']
description = '描述:' + req['results'][0]['Description'] description = '描述:' + req['results'][0]['Description']
maintainer = '维护:' + str(req['results'][0]['Maintainer']) maintainer = '维护:' + req['results'][0]['Maintainer']
numvotes = '投票:' + str(req['results'][0]['NumVotes']) 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'] url = req['results'][0]['URL']
if url is None: if url is None:
url = '链接None' url = '链接None'
else: else:
url = '链接:' + url url = '链接:' + url
msg = '仓库AUR\n' + name + '\n' + version + '\n' + description + '\n' + maintainer \ msg = '仓库AUR\n' + name + '\n' + version + '\n' + description + '\n' + maintainer \
+ '\n' + numvotes + '\n更新日期' + updatetime[0:10] + '\n' + url + '\n' + '\n' + numvotes + '\n' + url + '\n'
return msg return msg
else: else:
repo = req['results'][0]['repo'] repo = req['results'][0]['repo']
pkgname = req['results'][0]['pkgname'] pkgname = req['results'][0]['pkgname']
pkgver = req['results'][0]['pkgver']+'\n' pkgver = req['results'][0]['pkgver']
pkgdesc = req['results'][0]['pkgdesc'] pkgdesc = req['results'][0]['pkgdesc']
url = req['results'][0]['url'] 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 # return repo,pkgname,pkgver,pkgdesc,url
# print('仓库:' + repo + '\n包名' + pkgname + '\n版本' + pkgver + '\n描述' + pkgdesc + '\n上游' + url + '\n') # print('仓库:' + repo + '\n包名' + pkgname + '\n版本' + pkgver + '\n描述' + pkgdesc + '\n上游' + url + '\n')
msg = '仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '描述:' + pkgdesc + '\n更新日期:' \ msg = '仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '\n描述:' + pkgdesc + '\n上游:' + url + '\n'
+ updatetime[0:10] + '\n上游:' + url
return msg return msg