From dcadbf14b1d970914e78554e86d0b3dd8f6e727e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sun, 31 Jul 2022 16:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=8F=92=E4=BB=B6=E4=BE=9D=E8=B5=96=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=89=BE=E5=88=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/abyss.py | 10 +++++++--- plugins/sign.py | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/plugins/abyss.py b/plugins/abyss.py index 91f4af9a..80ff78f3 100644 --- a/plugins/abyss.py +++ b/plugins/abyss.py @@ -10,6 +10,8 @@ from app.user.repositories import UserNotFoundError from logger import Log from plugins.base import BasePlugins from utils.app.inject import inject +from utils.decorators.error import error_callable +from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client, url_to_file from utils.plugins.manager import listener_plugins_class @@ -19,7 +21,8 @@ class Abyss(BasePlugins): """深渊数据查询""" @inject - def __init__(self, user_service: UserService, cookies_service: CookiesService, template_service: TemplateService): + def __init__(self, user_service: UserService = None, cookies_service: CookiesService = None, + template_service: TemplateService = None): self.template_service = template_service self.cookies_service = cookies_service self.user_service = user_service @@ -87,7 +90,8 @@ class Abyss(BasePlugins): abyss_data["most_played_list"].append(temp) return abyss_data - @inject + @restricts + @error_callable async def command_start(self, update: Update, context: CallbackContext) -> None: user = update.effective_user message = update.message @@ -112,7 +116,7 @@ class Abyss(BasePlugins): 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) + {"width": 690, "height": 504}, full_page=False) await message.reply_photo(png_data, filename=f"abyss_{user.id}.png", allow_sending_without_reply=True) return diff --git a/plugins/sign.py b/plugins/sign.py index eb2b82fe..2f620809 100644 --- a/plugins/sign.py +++ b/plugins/sign.py @@ -5,9 +5,12 @@ from genshin import Game, GenshinException, AlreadyClaimed, Client from telegram import Update from telegram.ext import CommandHandler, MessageHandler, ConversationHandler, filters, CallbackContext +from app.cookies.service import CookiesService +from app.user import UserService from app.user.repositories import UserNotFoundError from logger import Log from plugins.base import BasePlugins +from utils.app.inject import inject from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client @@ -20,6 +23,11 @@ class Sign(BasePlugins): CHECK_SERVER, COMMAND_RESULT = range(10400, 10402) + @inject + def __init__(self, user_service: UserService = None, cookies_service: CookiesService = None): + self.cookies_service = cookies_service + self.user_service = user_service + @classmethod def create_handlers(cls): sign = cls()