zhenxun_bot/zhenxun/builtin_plugins/about.py

60 lines
1.9 KiB
Python
Raw Normal View History

2024-05-28 03:41:32 +08:00
from pathlib import Path
import aiofiles
2024-05-28 03:41:32 +08:00
from nonebot.rule import to_me
2024-10-18 18:57:55 +08:00
from nonebot_plugin_uninfo import Uninfo
from nonebot.plugin import PluginMetadata
from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
2024-05-28 03:41:32 +08:00
from zhenxun.services.log import logger
2024-08-11 15:57:33 +08:00
from zhenxun.utils.message import MessageUtils
2024-10-18 18:57:55 +08:00
from zhenxun.utils.platform import PlatformUtils
from zhenxun.configs.path_config import DATA_PATH
from zhenxun.configs.utils import PluginExtraData
2024-05-28 03:41:32 +08:00
__plugin_meta__ = PluginMetadata(
2024-08-18 22:26:53 +08:00
name="关于",
2024-05-28 03:41:32 +08:00
description="想要更加了解真寻吗",
usage="""
指令
关于
""".strip(),
extra=PluginExtraData(author="HibiKier", version="0.1", menu_type="其他").dict(),
)
_matcher = on_alconna(Alconna("关于"), priority=5, block=True, rule=to_me())
@_matcher.handle()
2024-10-18 18:57:55 +08:00
async def _(session: Uninfo, arparma: Arparma):
2024-05-28 03:41:32 +08:00
ver_file = Path() / "__version__"
version = None
if ver_file.exists():
async with aiofiles.open(ver_file, encoding="utf8") as f:
if text := await f.read():
version = text.split(":")[-1].strip()
2024-10-18 18:57:55 +08:00
if PlatformUtils.is_qbot(session):
info: list[str | Path] = [
f"""
绪山真寻Bot
版本{version}
简介基于Nonebot2开发支持多平台是一个非常可爱的Bot呀希望与大家要好好相处
""".strip()
]
path = DATA_PATH / "about.png"
if path.exists():
info.append(path)
else:
info = [
f"""
2024-05-28 03:41:32 +08:00
绪山真寻Bot
版本{version}
简介基于Nonebot2开发支持多平台是一个非常可爱的Bot呀希望与大家要好好相处
项目地址https://github.com/HibiKier/zhenxun_bot
文档地址https://hibikier.github.io/zhenxun_bot/
2024-10-18 18:57:55 +08:00
""".strip()
]
await MessageUtils.build_message(info).send() # type: ignore
2024-05-28 03:41:32 +08:00
logger.info("查看关于", arparma.header_result, session=session)