🔧 修复部分插件依赖无法找到的问题

This commit is contained in:
洛水居室 2022-07-31 16:17:27 +08:00
parent 980244a704
commit dcadbf14b1
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
2 changed files with 15 additions and 3 deletions

View File

@ -10,6 +10,8 @@ from app.user.repositories import UserNotFoundError
from logger import Log from logger import Log
from plugins.base import BasePlugins from plugins.base import BasePlugins
from utils.app.inject import inject 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.helpers import get_genshin_client, url_to_file
from utils.plugins.manager import listener_plugins_class from utils.plugins.manager import listener_plugins_class
@ -19,7 +21,8 @@ class Abyss(BasePlugins):
"""深渊数据查询""" """深渊数据查询"""
@inject @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.template_service = template_service
self.cookies_service = cookies_service self.cookies_service = cookies_service
self.user_service = user_service self.user_service = user_service
@ -87,7 +90,8 @@ class Abyss(BasePlugins):
abyss_data["most_played_list"].append(temp) abyss_data["most_played_list"].append(temp)
return abyss_data return abyss_data
@inject @restricts
@error_callable
async def command_start(self, update: Update, context: CallbackContext) -> None: async def command_start(self, update: Update, context: CallbackContext) -> None:
user = update.effective_user user = update.effective_user
message = update.message message = update.message
@ -112,7 +116,7 @@ class Abyss(BasePlugins):
raise exc raise exc
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
png_data = await self.template_service.render('genshin/abyss', "abyss.html", abyss_data, 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", await message.reply_photo(png_data, filename=f"abyss_{user.id}.png",
allow_sending_without_reply=True) allow_sending_without_reply=True)
return return

View File

@ -5,9 +5,12 @@ from genshin import Game, GenshinException, AlreadyClaimed, Client
from telegram import Update from telegram import Update
from telegram.ext import CommandHandler, MessageHandler, ConversationHandler, filters, CallbackContext 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 app.user.repositories import UserNotFoundError
from logger import Log from logger import Log
from plugins.base import BasePlugins from plugins.base import BasePlugins
from utils.app.inject import inject
from utils.decorators.error import error_callable from utils.decorators.error import error_callable
from utils.decorators.restricts import restricts from utils.decorators.restricts import restricts
from utils.helpers import get_genshin_client from utils.helpers import get_genshin_client
@ -20,6 +23,11 @@ class Sign(BasePlugins):
CHECK_SERVER, COMMAND_RESULT = range(10400, 10402) 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 @classmethod
def create_handlers(cls): def create_handlers(cls):
sign = cls() sign = cls()