增加查询指定仓库软件功能!

This commit is contained in:
xmengnet 2021-05-31 20:41:09 +08:00
parent 4712ce4e87
commit 17f3365e6f

View file

@ -7,17 +7,23 @@ class Ans(StdAns):
# AllowGroup = [874769998,596678277,7343311]
def GETMSG(self):
if len(self.parms) <= 1:
msg = '请输入包名 如:/pkg linux'
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] ).json()
if req['results'] == []:
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()