From c146254bb6da83614a990a6e443f7dce17ebdde1 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 21 Jul 2022 20:50:49 +0800 Subject: [PATCH] =?UTF-8?q?netease=5Fcomment=20=E9=9A=8F=E6=9C=BA=E4=B8=80?= =?UTF-8?q?=E6=9D=A1=E7=BD=91=E6=98=93=E4=BA=91=E9=9F=B3=E4=B9=90=E8=AF=84?= =?UTF-8?q?=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: KorenKrita --- list.json | 10 ++++++++++ netease_comment/main.py | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 netease_comment/main.py diff --git a/list.json b/list.json index f4927f7..2ac4038 100644 --- a/list.json +++ b/list.json @@ -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" } ] } diff --git a/netease_comment/main.py b/netease_comment/main.py new file mode 100644 index 0000000..d34d2db --- /dev/null +++ b/netease_comment/main.py @@ -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'] + ' 在鸽曲 ' + \ + data['name'] + ' --by' + data['artists_name'] + '' + ' 下方的评论。' + return await message.edit(res, disable_web_page_preview=False) + except Exception: + continue + await message.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")