From 5e117c53488d46a241e40fab836255b84594d103 Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Fri, 28 Aug 2020 17:36:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E8=AF=8D=E9=94=99=E8=AF=AF=E6=97=B6=E6=8A=A5=E9=94=99?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=B8=80=E4=BA=9B=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 4 ++-- neteasemusic.py | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/list.json b/list.json index cab3f44..c04baea 100644 --- a/list.json +++ b/list.json @@ -282,10 +282,10 @@ }, { "name": "neteasemusic", - "version": "2.1", + "version": "2.2", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "22.4 kb", + "size": "22.9 kb", "supported": true, "des-short": "网易云点歌", "des": "可以在线搜索并且快速点歌,歌曲信息齐全,支持直接回复点歌。命令:nem。" diff --git a/neteasemusic.py b/neteasemusic.py index 27588b2..2c5aa10 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -41,7 +41,11 @@ async def nem(context): req = requests.request("GET", url, headers=headers) if req.status_code == 200: req = json.loads(req.content) - if req['result']: + if req['code'] == 200: + result = req['result'] + else: + result = False + if result: info = defaultdict() for i in range(len(req['result']['songs'])): info[i] = {'id': '', 'title': '', 'alias': '', @@ -64,23 +68,24 @@ async def nem(context): info[i]['album'] + '' text += f"专辑: {res} \n" text += f"作者: {info[i]['artist']}\n歌曲ID{info[i]['id']}\n————————\n" - text += "回复此消息 -nem p <歌曲序号> 即可点歌" + text += "回复此消息 -nem p <歌曲序号> 即可点歌" await context.edit(text, parse_mode='html', link_preview=True) status = True break else: await context.edit("**未搜索到结果**") + sleep(3) + await context.delete() status = True break else: continue if status is False: await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。") - sleep(2) + sleep(3) await context.delete() return - - if context.parameter[0] == "p": # 播放功能 + elif context.parameter[0] == "p": # 播放功能 try: reply = await context.get_reply_message() except ValueError: @@ -395,6 +400,8 @@ async def nem(context): break else: await context.edit("**未搜索到结果**") + sleep(3) + await context.delete() status = True break else: @@ -402,5 +409,8 @@ async def nem(context): if status is False: await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。") - sleep(2) + sleep(3) await context.delete() + else: #错误输入 + await context.edit("使用方法:`-nem` `<指令>` `<关键词>`\n(指令s为搜索,指令p为播放\n关键词可填歌曲ID,或直接回复搜索结果 `-nem` `p` `<歌曲数字序号>`)") + return \ No newline at end of file