Merge branch 'xmengnet-master'

This commit is contained in:
SiHuan 2021-06-14 14:09:58 +08:00
commit 2972758837
6 changed files with 194 additions and 0 deletions

40
worker/k.py Normal file
View file

@ -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=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' \
# f'<msg serviceID="1">' \
# f'<item><title>来喽!!</title></item>' \
# f'<source name="K!" icon="{picurl}" action="web" appid="-1" />' \
# f'</msg>' \
# f']'
msg = f'[CQ:xml,data=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' \
f'<msg serviceID="1"\n' \
f'action="web" url="\n' \
f'https://brx86.gitee.io/kemomimi/202.jpg">\n' \
f'<item><title>ケモミミちゃん:</title><summary>Kemomimi酱来了</summary><picture cover="https://brx86.gitee.io/kemomimi/202.jpg"/></item>\n' \
f'</msg> ' \
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

27
worker/mner.py Normal file
View file

@ -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

62
worker/pkg.py Normal file
View file

@ -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

29
worker/song.py Normal file
View file

@ -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

20
worker/tiangou.py Normal file
View file

@ -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

16
worker/xs.py Normal file
View file

@ -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