mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
修改 Weapon
的 service
传入方式
This commit is contained in:
parent
a982f69a68
commit
d9fa9cd466
@ -8,10 +8,11 @@ from metadata.shortname import weaponToName
|
||||
from model.helpers import url_to_file
|
||||
from plugins.base import BasePlugins, restricts
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
from service import BaseService
|
||||
from utils.base import PaimonContext
|
||||
|
||||
|
||||
@listener_plugins_class()
|
||||
@listener_plugins_class(need_service=True)
|
||||
class Weapon(BasePlugins):
|
||||
"""
|
||||
武器查询
|
||||
@ -19,9 +20,12 @@ class Weapon(BasePlugins):
|
||||
|
||||
KEYBOARD = [[InlineKeyboardButton(text="查看武器列表并查询", switch_inline_query_current_chat="查看武器列表并查询")]]
|
||||
|
||||
def __init__(self, service: BaseService):
|
||||
self.service = service
|
||||
|
||||
@classmethod
|
||||
def create_handlers(cls) -> list:
|
||||
weapon = cls()
|
||||
def create_handlers(cls, service: BaseService) -> list:
|
||||
weapon = cls(service)
|
||||
return [
|
||||
CommandHandler("weapon", weapon.command_start, block=False),
|
||||
MessageHandler(filters.Regex("^武器查询(.*)"), weapon.command_start, block=False)
|
||||
@ -34,7 +38,6 @@ class Weapon(BasePlugins):
|
||||
user = update.effective_user
|
||||
args = context.args
|
||||
match = context.match
|
||||
service = context.service
|
||||
weapon_name: str = ""
|
||||
if args is None:
|
||||
if match is not None:
|
||||
@ -91,8 +94,8 @@ class Weapon(BasePlugins):
|
||||
return _template_data
|
||||
|
||||
template_data = await input_template_data(weapon_data)
|
||||
png_data = await service.template.render('genshin/weapon', "weapon.html", template_data,
|
||||
{"width": 540, "height": 540})
|
||||
png_data = await self.service.template.render('genshin/weapon', "weapon.html", template_data,
|
||||
{"width": 540, "height": 540})
|
||||
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
||||
await message.reply_photo(png_data, filename=f"{template_data['weapon_name']}.png",
|
||||
allow_sending_without_reply=True)
|
||||
|
Loading…
Reference in New Issue
Block a user