mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-29 02:57:22 +00:00
eed418477f
Previously, all templates were named with the .html extension, which caused problems for editors to recognize the Jinja2 syntax used in them. In this commit, all templates have been renamed to use the .jinja2 extension to better reflect their use of Jinja2 and to improve editor recognition.
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from telegram import Update
|
|
from telegram.constants import ChatAction
|
|
from telegram.ext import CallbackContext
|
|
|
|
from core.plugin import Plugin, handler
|
|
from core.services.template.services import TemplateService
|
|
from utils.log import logger
|
|
|
|
__all__ = ("HelpPlugin",)
|
|
|
|
|
|
class HelpPlugin(Plugin):
|
|
def __init__(self, template_service: TemplateService = None):
|
|
if template_service is None:
|
|
raise ModuleNotFoundError
|
|
self.template_service = template_service
|
|
|
|
@handler.command(command="help", block=False)
|
|
async def start(self, update: Update, _: CallbackContext):
|
|
message = update.effective_message
|
|
user = update.effective_user
|
|
logger.info("用户 %s[%s] 发出help命令", user.full_name, user.id)
|
|
await message.reply_chat_action(ChatAction.TYPING)
|
|
render_result = await self.template_service.render(
|
|
"bot/help/help.jinja2",
|
|
{"bot_username": self.application.bot.username},
|
|
{"width": 1280, "height": 900},
|
|
ttl=30 * 24 * 60 * 60,
|
|
)
|
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
|
await render_result.reply_photo(message, filename="help.png", allow_sending_without_reply=True)
|