2020-08-11 17:05:21 +00:00
|
|
|
import json
|
|
|
|
from requests import get
|
|
|
|
from pagermaid.listener import listener
|
2021-06-16 07:09:40 +00:00
|
|
|
from pagermaid.utils import alias_command
|
2020-08-11 17:05:21 +00:00
|
|
|
|
|
|
|
|
2021-06-16 07:09:40 +00:00
|
|
|
@listener(is_plugin=True, outgoing=True, command=alias_command("netease"),
|
2020-08-11 17:05:21 +00:00
|
|
|
description="随机一条网易云音乐评论。")
|
|
|
|
async def netease(context):
|
|
|
|
await context.edit("获取中 . . .")
|
2021-04-04 06:09:38 +00:00
|
|
|
try:
|
|
|
|
req = get("https://api.66mz8.com/api/music.163.php?format=json")
|
|
|
|
except:
|
|
|
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
|
|
|
return
|
2020-08-11 17:05:21 +00:00
|
|
|
if req.status_code == 200:
|
|
|
|
data = json.loads(req.text)
|
2021-06-16 07:09:40 +00:00
|
|
|
try:
|
|
|
|
res = data['comments'] + '\n\n来自 @' + data[
|
|
|
|
'nickname'] + ' 在鸽曲 <a href="' + str(data['music_url']) + '">' + \
|
|
|
|
data['name'] + ' --by' + data['artists_name'] + '</a>' + ' 下方的评论。'
|
|
|
|
except:
|
|
|
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
|
|
|
return
|
2020-08-11 17:05:21 +00:00
|
|
|
await context.edit(res, parse_mode='html', link_preview=True)
|
|
|
|
else:
|
2020-08-12 01:36:17 +00:00
|
|
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|