From 844bd56a5bed1293329299c8b0562558a0d2d907 Mon Sep 17 00:00:00 2001 From: Kyomotoi Date: Fri, 1 Oct 2021 08:56:42 +0800 Subject: =?UTF-8?q?=F0=9F=90=9B=E2=9A=A1=EF=B8=8F=F0=9F=94=A5=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复: - `setu`、`saucenao`搜图时失败报错 更新: - 弃用`aiohttp`,改用`httpx` 删除: - 临时删除暂未完成的`console` --- ATRI/plugins/setu/__init__.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'ATRI/plugins/setu/__init__.py') diff --git a/ATRI/plugins/setu/__init__.py b/ATRI/plugins/setu/__init__.py index d67d75b..eec5281 100644 --- a/ATRI/plugins/setu/__init__.py +++ b/ATRI/plugins/setu/__init__.py @@ -25,10 +25,15 @@ async def _random_setu(bot: Bot, event: MessageEvent): if not _setu_dlmt.check(user_id): await random_setu.finish() - setu, title, p_id = await Setu().random_setu() - repo = f"Title: {title}\n" f"Pid: {p_id}" + repo, setu = await Setu().random_setu() await bot.send(event, repo) - msg_1 = await bot.send(event, Message(setu)) + + msg_1 = dict() + try: + msg_1 = await bot.send(event, Message(setu)) + except Exception: + await random_setu.finish("hso(发不出") + event_id = msg_1["message_id"] _setu_flmt.start_cd(user_id) _setu_dlmt.increase(user_id) @@ -50,13 +55,18 @@ async def _tag_setu(bot: Bot, event: MessageEvent): msg = str(event.message).strip() pattern = r"来[张点丶份](.*?)的[涩色🐍]图" tag = re.findall(pattern, msg)[0] - setu, title, p_id, is_ok = await Setu().tag_setu(tag) - if not is_ok: - await tag_setu.finish(f"没有 {tag} 的涩图呢...") - repo_0 = f"Title: {title}\n" f"Pid: {p_id}" + repo, setu = await Setu().tag_setu(tag) + if not setu: + await tag_setu.finish(repo) + + await bot.send(event, repo) + + msg_1 = dict() + try: + msg_1 = await bot.send(event, Message(setu)) + except Exception: + await random_setu.finish("hso(发不出") - await bot.send(event, repo_0) - msg_1 = await bot.send(event, Message(setu)) event_id = msg_1["message_id"] _setu_flmt.start_cd(user_id) _setu_dlmt.increase(user_id) @@ -71,10 +81,13 @@ async def _scheduler_setu(bot): lucky_group = choice(group_list) group_id = lucky_group["group_id"] setu = await Setu().scheduler() + if not setu: + return + msg_0 = await bot.send_group_msg(group_id=int(group_id), message=Message(setu)) message_id = msg_0["message_id"] await asyncio.sleep(60) await bot.delete_msg(message_id=message_id) - except BaseException: + except Exception: pass -- cgit v1.2.3