From 181b767aac682094ea58f0ef529563631b25782f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Fri, 1 Jul 2022 02:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B2=A1=E6=9C=89=E6=8C=91?= =?UTF-8?q?=E6=88=98=E6=B7=B1=E6=B8=8A=E5=BC=95=E5=8F=91=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=B9=B6=E6=A3=80=E6=9F=A5=E8=B4=A6=E5=8F=B7=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/abyss.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/abyss.py b/plugins/abyss.py index d9b5123e..bfe71f16 100644 --- a/plugins/abyss.py +++ b/plugins/abyss.py @@ -5,12 +5,13 @@ from telegram.ext import CommandHandler, MessageHandler, filters from logger import Log from manager import listener_plugins_class from model.helpers import get_genshin_client, url_to_file +from plugins.base import BasePlugins from service.base import UserInfoData from utils.base import PaimonContext @listener_plugins_class() -class Abyss: +class Abyss(BasePlugins): def __init__(self, *args): """Abyss插件入口""" @@ -40,6 +41,8 @@ class Abyss: if not spiral_abyss_info.unlocked: raise ValueError("unlocked is false") ranks = spiral_abyss_info.ranks + if len(spiral_abyss_info.ranks.most_kills) == 0: + raise ValueError("本次深渊旅行者还没挑战呢") abyss_data = { "uid": uid, "max_floor": spiral_abyss_info.max_floor, @@ -85,13 +88,23 @@ class Abyss: Log.info(f"用户 {user.full_name}[{user.id}] 查深渊挑战命令请求") await message.reply_chat_action(ChatAction.TYPING) user_info = await service.user_service_db.get_user_info(user.id) + if user_info.user_id == 0: + 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, 300) + self._add_delete_message_job(context, message.chat_id, message.message_id, 300) + return try: abyss_data = await self._get_abyss_data(user_info) 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 service.template.render('genshin/abyss', "abyss.html", abyss_data, {"width": 690, "height": 504}, full_page=False) await message.reply_photo(png_data, filename=f"abyss_{user.id}.png",