feat✨: 添加单个插件帮助图片

This commit is contained in:
HibiKier
2024-02-27 16:13:06 +08:00
parent 993ff81130
commit f6bc6f3481
2 changed files with 15 additions and 10 deletions
+8 -4
View File
@@ -2,7 +2,7 @@ import nonebot
from zhenxun.configs.path_config import IMAGE_PATH
from zhenxun.models.plugin_info import PluginInfo
from zhenxun.utils.image_utils import BuildImage
from zhenxun.utils.image_utils import BuildImage, ImageTemplate
from ._utils import HelpImageBuild
@@ -11,7 +11,7 @@ random_bk_path = IMAGE_PATH / "background" / "help" / "simple_help"
background = IMAGE_PATH / "background" / "0.png"
async def create_help_img(group_id: int | None):
async def create_help_img(group_id: str | None):
"""
说明:
生成帮助图片
@@ -21,7 +21,7 @@ async def create_help_img(group_id: int | None):
await HelpImageBuild().build_image(group_id)
async def get_plugin_help(name: str) -> str:
async def get_plugin_help(name: str) -> str | BuildImage:
"""获取功能的帮助信息
参数:
@@ -30,6 +30,10 @@ async def get_plugin_help(name: str) -> str:
if plugin := await PluginInfo.get_or_none(name=name):
_plugin = nonebot.get_plugin_by_module_name(plugin.module_path)
if _plugin and _plugin.metadata:
return _plugin.metadata.usage
items = {
"简介": _plugin.metadata.description,
"用法": _plugin.metadata.usage,
}
return await ImageTemplate.hl_page(name, items)
return "糟糕! 该功能没有帮助喔..."
return "没有查找到这个功能噢..."