From d3fbc869f2a75279af5bfc2dd88c9afb1b2723e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sat, 3 Sep 2022 12:17:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E4=BD=BF=E7=94=A8=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=BC=82=E5=B8=B8=E6=8A=9B=E5=87=BA=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=E8=BF=94=E5=9B=9E=E6=97=A0=E6=B7=B1=E6=B8=8A=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/abyss.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/plugins/genshin/abyss.py b/plugins/genshin/abyss.py index 01cc6b63..95aee163 100644 --- a/plugins/genshin/abyss.py +++ b/plugins/genshin/abyss.py @@ -16,6 +16,16 @@ from utils.plugins.manager import listener_plugins_class from utils.service.inject import inject +class AbyssUnlocked(Exception): + """根本没动""" + pass + + +class NoMostKills(Exception): + """挑战了但是数据没刷新""" + pass + + @listener_plugins_class() class Abyss(BasePlugins): """深渊数据查询""" @@ -49,10 +59,10 @@ class Abyss(BasePlugins): await client.get_record_cards() spiral_abyss_info = await client.get_spiral_abyss(uid) if not spiral_abyss_info.unlocked: - raise ValueError("unlocked is false") + raise AbyssUnlocked ranks = spiral_abyss_info.ranks if len(spiral_abyss_info.ranks.most_kills) == 0: - raise ValueError("本次深渊旅行者还没挑战呢") + raise NoMostKills abyss_data = { "uid": uid, "max_floor": spiral_abyss_info.max_floor, @@ -104,17 +114,15 @@ class Abyss(BasePlugins): except UserNotFoundError: reply_message = await message.reply_text("未查询到账号信息,请先私聊派蒙绑定账号") if filters.ChatType.GROUPS.filter(message): - self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30) - self._add_delete_message_job(context, message.chat_id, message.message_id, 30) + self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 10) + self._add_delete_message_job(context, message.chat_id, message.message_id, 10) + return + except (AbyssUnlocked, NoMostKills): + reply_message = await message.reply_text("本次深渊旅行者还没挑战呢,咕咕咕~~~") + if filters.ChatType.GROUPS.filter(message): + self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 10) + self._add_delete_message_job(context, message.chat_id, message.message_id, 10) return - except ValueError as exc: - if "unlocked is false" in str(exc): - await message.reply_text("本次深渊旅行者还没挑战呢,咕咕咕~~~") - return - if "本次深渊旅行者还没挑战呢" in str(exc): - await message.reply_text("本次深渊旅行者还没挑战呢,咕咕咕~~~") - return - raise exc await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) png_data = await self.template_service.render('genshin/abyss', "abyss.html", abyss_data, {"width": 690, "height": 504}, full_page=False)