2021-04-14 20:40:01 +08:00
|
|
|
|
import requests
|
2021-05-22 10:43:26 +08:00
|
|
|
|
import time
|
2021-04-14 20:40:01 +08:00
|
|
|
|
from zzcore import StdAns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Ans(StdAns):
|
2021-05-22 10:43:26 +08:00
|
|
|
|
# AllowGroup = [874769998,596678277,7343311]
|
2021-04-14 20:40:01 +08:00
|
|
|
|
|
|
|
|
|
def GETMSG(self):
|
2021-05-31 20:41:09 +08:00
|
|
|
|
if len(self.parms) < 2:
|
|
|
|
|
msg = '请输入包名 如:/pkg linux testing 查询 Testing 的 linux 软件'
|
2021-04-14 20:40:01 +08:00
|
|
|
|
return msg
|
2021-05-31 20:41:09 +08:00
|
|
|
|
elif self.parms[1] == 'help':
|
2021-04-14 20:40:01 +08:00
|
|
|
|
msg = '使用 /pkg 包名 查询Core, Extra, Testing, Multilib, Multilib-Testing, ' \
|
2021-05-31 20:41:09 +08:00
|
|
|
|
'Community, Community-Testing仓库以及AUR的软件 '
|
2021-04-14 20:40:01 +08:00
|
|
|
|
return msg
|
|
|
|
|
else:
|
2021-05-31 20:41:09 +08:00
|
|
|
|
repo = str()
|
|
|
|
|
try:
|
|
|
|
|
if len(self.parms) > 1:
|
|
|
|
|
repo = '&repo=' + self.parms[2].capitalize()
|
|
|
|
|
except:
|
|
|
|
|
print('repo empty')
|
2021-04-14 20:40:01 +08:00
|
|
|
|
req = requests.get(
|
2021-05-31 20:41:09 +08:00
|
|
|
|
url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] + repo).json()
|
|
|
|
|
if not req['results']:
|
2021-05-22 10:43:26 +08:00
|
|
|
|
req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=info&arg=' + self.parms[1]).json()
|
2021-05-19 18:05:30 +08:00
|
|
|
|
if req['resultcount'] == 0:
|
|
|
|
|
req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=search&arg=' + self.parms[1]).json()
|
2021-04-14 20:40:01 +08:00
|
|
|
|
# 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']
|
2021-05-22 10:43:26 +08:00
|
|
|
|
maintainer = '维护:' + str(req['results'][0]['Maintainer'])
|
2021-04-14 20:40:01 +08:00
|
|
|
|
numvotes = '投票:' + str(req['results'][0]['NumVotes'])
|
2021-05-22 10:43:26 +08:00
|
|
|
|
updatetime = req['results'][0]['LastModified']
|
|
|
|
|
updatetime = time.localtime(int(updatetime))
|
|
|
|
|
updatetime = time.strftime("%Y-%m-%d %H:%M:%S", updatetime)
|
2021-04-14 20:40:01 +08:00
|
|
|
|
url = req['results'][0]['URL']
|
|
|
|
|
if url is None:
|
|
|
|
|
url = '链接:None'
|
|
|
|
|
else:
|
|
|
|
|
url = '链接:' + url
|
|
|
|
|
msg = '仓库:AUR\n' + name + '\n' + version + '\n' + description + '\n' + maintainer \
|
2021-05-31 20:41:09 +08:00
|
|
|
|
+ '\n' + numvotes + '\n更新日期:' + updatetime + '\n' + url
|
2021-04-14 20:40:01 +08:00
|
|
|
|
return msg
|
|
|
|
|
else:
|
|
|
|
|
repo = req['results'][0]['repo']
|
|
|
|
|
pkgname = req['results'][0]['pkgname']
|
2021-05-31 20:41:09 +08:00
|
|
|
|
pkgver = req['results'][0]['pkgver'] + '\n'
|
2021-04-14 20:40:01 +08:00
|
|
|
|
pkgdesc = req['results'][0]['pkgdesc']
|
|
|
|
|
url = req['results'][0]['url']
|
2021-05-22 10:43:26 +08:00
|
|
|
|
updatetime = req['results'][0]['last_update']
|
|
|
|
|
updatetime = updatetime.replace('T', ' ')
|
2021-05-31 20:41:09 +08:00
|
|
|
|
updatetime = updatetime[0:16] + '\n'
|
2021-04-14 20:40:01 +08:00
|
|
|
|
# return repo,pkgname,pkgver,pkgdesc,url
|
|
|
|
|
# print('仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '\n描述:' + pkgdesc + '\n上游:' + url + '\n')
|
2021-05-22 10:43:26 +08:00
|
|
|
|
msg = '仓库:' + repo + '\n包名:' + pkgname + '\n版本:' + pkgver + '描述:' + pkgdesc + '\n更新日期:' \
|
2021-05-31 20:41:09 +08:00
|
|
|
|
+ updatetime + '上游:' + url
|
2021-05-08 19:27:03 +08:00
|
|
|
|
return msg
|