netease_comment 随机一条网易云音乐评论

Co-authored-by: KorenKrita <spczd@hrbeu.edu.cn>
This commit is contained in:
xtaodada 2022-07-21 20:50:49 +08:00
parent 30e50f50d5
commit c146254bb6
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 29 additions and 0 deletions

View File

@ -389,6 +389,16 @@
"supported": true,
"des-short": "每日问候。",
"des": "每日问候。\n指令,everyday_greet"
},
{
"name": "netease_comment",
"version": "1.0",
"section": "chat",
"maintainer": "xtaodada、KorenKrita",
"size": "0.89 kb",
"supported": true,
"des-short": "随机一条网易云音乐评论。",
"des": "随机一条网易云音乐评论。\n指令,netease_comment"
}
]
}

19
netease_comment/main.py Normal file
View File

@ -0,0 +1,19 @@
from pagermaid.listener import listener
from pagermaid.single_utils import Message
@listener(command="netease_comment",
description="随机一条网易云音乐评论。")
async def netease(message: Message):
for _ in range(5):
try:
req = await message.request.get("https://api.66mz8.com/api/music.163.php?format=json")
assert req.status_code == 200
data = req.json()
res = data['comments'] + '\n\n来自 @' + data[
'nickname'] + ' 在鸽曲 <a href="' + str(data['music_url']) + '">' + \
data['name'] + ' --by' + data['artists_name'] + '</a>' + ' 下方的评论。'
return await message.edit(res, disable_web_page_preview=False)
except Exception:
continue
await message.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")