Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
94ed4cd
:sparkles: 添加全局优先级hook
HibiKier Mar 9, 2025
da1ccff
:sparkles: 添加基础配置api
HibiKier Mar 10, 2025
c263c58
:sparkles: 添加数据库连接测试
HibiKier Mar 10, 2025
b0070c8
:speech_balloon: 提示重启
HibiKier Mar 10, 2025
0416b46
:adhesive_bandage: 填充过配置时友好提示
HibiKier Mar 10, 2025
2830497
:bug: 首次生成简易配置后自动加载
HibiKier Mar 10, 2025
c7a33c7
:sparkles: 添加配置后重启接口
HibiKier Mar 11, 2025
033792c
:sparkles: 添加重启标志文件
HibiKier Mar 11, 2025
82a3527
:sparkles: 添加重启脚本命令
HibiKier Mar 11, 2025
9935e98
:sparkles: 添加重启系统限制
HibiKier Mar 11, 2025
a1990e8
:sparkles: 首次配置判断是否为win系统
HibiKier Mar 12, 2025
11d04ef
:fire: 移除bat
HibiKier Mar 12, 2025
cffc376
:sparkles: 添加关于菜单
HibiKier Mar 12, 2025
be52ec2
:sparkles: 支持整合包插件安装和添加整合包文档
HibiKier Mar 13, 2025
c0539cf
:adhesive_bandage: 检测数据库路径
HibiKier Mar 16, 2025
d598e1c
:adhesive_bandage: 修改数据库路径检测
HibiKier Mar 16, 2025
12660df
:adhesive_bandage: 修改数据库路径检测
HibiKier Mar 16, 2025
cc1b199
:adhesive_bandage: 修复路径注入
HibiKier Mar 18, 2025
7f5f689
Merge branch 'main' into feature/webui-config
HibiKier Mar 27, 2025
e84fc89
:art: 显示添加优先级
HibiKier Apr 3, 2025
b10b277
:bug: 修改PriorityLifecycle字典类名称
HibiKier Apr 11, 2025
d861e1c
:zap: 修复路径问题
HibiKier May 10, 2025
f583306
Merge branch 'feature/webui-config' of https://github.com/HibiKier/zh…
HibiKier May 10, 2025
005cafb
:zap: 修复路径检测
HibiKier May 10, 2025
07ba035
✨ 新增路径验证功能,确保用户输入的路径安全并在项目根目录内
HibiKier May 10, 2025
4d6d47b
✨ 优化路径验证功能,增加对非法字符和路径长度的检查,确保用户输入的路径更加安全
HibiKier May 12, 2025
f676327
Merge branch 'main' into feature/webui-config
HibiKier May 15, 2025
49b60aa
:rotating_light: auto fix by pre-commit hooks
pre-commit-ci[bot] May 15, 2025
1012542
✨ 优化获取文件列表的代码格式
HibiKier May 15, 2025
f6f4ff1
:memo: 修改README中webui示例图
HibiKier May 16, 2025
b2f0292
✨ 更新PriorityLifecycle.on_startup装饰器
HibiKier May 17, 2025
922ca71
Merge branch 'main' into feature/webui-config
HibiKier Jun 4, 2025
13b690c
✨ 简化安装依赖的命令构建逻辑
HibiKier Jun 4, 2025
d657f47
Merge branch 'main' into feature/webui-config
HibiKier Jun 13, 2025
166a4e8
:rotating_light: auto fix by pre-commit hooks
pre-commit-ci[bot] Jun 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@ AccessToken: PUBLIC_ZHENXUN_TEST
- 提供了 cd,阻塞,每日次数等限制,仅仅通过简单的属性就可以生成一个限制,例如:`PluginCdBlock` 等
- **更多详细请通过 [传送门](https://hibikier.github.io/zhenxun_bot/) 查看文档!**

## 🐣 小白整合

如果你系统是 **Windows** 且不想下载 Python
可以使用整合包(Python3.10+zhenxun+webui)

文档地址:[整合包文档](https://hibikier.github.io/zhenxun_bot/beginner/)

<details>
<summary>下载地址</summary>

- **百度云:**
https://pan.baidu.com/s/1ph4yzx1vdNbkxm9VBKDdgQ?pwd=971j

- **天翼云:**
https://cloud.189.cn/web/share?code=jq67r2i2E7Fb
访问码:8wxm

- **Google Drive:**
https://drive.google.com/file/d/1cc3Dqjk0x5hWGLNeMkrFwWl8BvsK6KfD/view?usp=drive_link

</details>

## 🛠️ 简单部署

```bash
Expand Down
4 changes: 2 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# driver.register_adapter(DoDoAdapter)
# driver.register_adapter(DiscordAdapter)

from zhenxun.services.db_context import disconnect, init
from zhenxun.services.db_context import disconnect

driver.on_startup(init)
# driver.on_startup(init)
driver.on_shutdown(disconnect)

# nonebot.load_builtin_plugins("echo")
Expand Down
3 changes: 2 additions & 1 deletion zhenxun/builtin_plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from zhenxun.models.user_console import UserConsole
from zhenxun.services.log import logger
from zhenxun.utils.decorator.shop import shop_register
from zhenxun.utils.manager.priority_manager import PriorityLifecycle
from zhenxun.utils.manager.resource_manager import ResourceManager
from zhenxun.utils.platform import PlatformUtils

Expand Down Expand Up @@ -70,7 +71,7 @@ async def _(bot: Bot):
"""


@driver.on_startup
@PriorityLifecycle.on_startup()
async def _():
await ResourceManager.init_resources()
"""签到与用户的数据迁移"""
Expand Down
3 changes: 2 additions & 1 deletion zhenxun/builtin_plugins/admin/welcome_message/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from zhenxun.utils._build_image import BuildImage
from zhenxun.utils._image_template import ImageTemplate
from zhenxun.utils.http_utils import AsyncHttpx
from zhenxun.utils.manager.priority_manager import PriorityLifecycle
from zhenxun.utils.platform import PlatformUtils

BASE_PATH = DATA_PATH / "welcome_message"
Expand Down Expand Up @@ -91,7 +92,7 @@ def migrate(path: Path):
json.dump(new_data, f, ensure_ascii=False, indent=4)


@driver.on_startup
@PriorityLifecycle.on_startup()
def _():
"""数据迁移

Expand Down
4 changes: 3 additions & 1 deletion zhenxun/builtin_plugins/init/init_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from zhenxun.configs.path_config import DATA_PATH
from zhenxun.configs.utils import RegisterConfig
from zhenxun.services.log import logger
from zhenxun.utils.manager.priority_manager import PriorityLifecycle

_yaml = YAML(pure=True)
_yaml.allow_unicode = True
Expand Down Expand Up @@ -102,7 +103,7 @@ def _generate_simple_config(exists_module: list[str]):
temp_file.unlink()


@driver.on_startup
@PriorityLifecycle.on_startup(priority=0)
def _():
"""
初始化插件数据配置
Expand All @@ -125,3 +126,4 @@ def _():
with plugins2config_file.open("w", encoding="utf8") as wf:
_yaml.dump(_data, wf)
_generate_simple_config(exists_module)
Config.reload()
3 changes: 2 additions & 1 deletion zhenxun/builtin_plugins/init/init_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
PluginLimitType,
PluginType,
)
from zhenxun.utils.manager.priority_manager import PriorityLifecycle

from .manager import manager

Expand Down Expand Up @@ -95,7 +96,7 @@ async def _handle_setting(
)


@driver.on_startup
@PriorityLifecycle.on_startup()
async def _():
"""
初始化插件数据配置
Expand Down
3 changes: 2 additions & 1 deletion zhenxun/builtin_plugins/init/init_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from zhenxun.models.task_info import TaskInfo
from zhenxun.services.log import logger
from zhenxun.utils.common_utils import CommonUtils
from zhenxun.utils.manager.priority_manager import PriorityLifecycle

driver: Driver = nonebot.get_driver()

Expand Down Expand Up @@ -132,7 +133,7 @@ async def create_schedule(task: Task):
logger.error(f"动态创建定时任务 {task.name}({task.module}) 失败", e=e)


@driver.on_startup
@PriorityLifecycle.on_startup()
async def _():
"""
初始化插件数据配置
Expand Down
22 changes: 21 additions & 1 deletion zhenxun/builtin_plugins/plugin_store/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from .config import BASE_PATH, DEFAULT_GITHUB_URL, EXTRA_GITHUB_URL

BAT_FILE = Path() / "win启动.bat"


def row_style(column: str, text: str) -> RowStyle:
"""被动技能文本风格
Expand Down Expand Up @@ -50,8 +52,26 @@ def install_requirement(plugin_path: Path):
return

try:
if BAT_FILE.exists():
command = [
"./Python310/python.exe",
"-m",
"pip",
"install",
"-r",
str(existing_requirements),
]
else:
command = [
"poetry",
"run",
"pip",
"install",
"-r",
str(existing_requirements),
]
result = subprocess.run(
["poetry", "run", "pip", "install", "-r", str(existing_requirements)],
command,
check=True,
capture_output=True,
text=True,
Expand Down
5 changes: 3 additions & 2 deletions zhenxun/builtin_plugins/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from zhenxun.models.group_console import GroupConsole
from zhenxun.services.log import logger
from zhenxun.utils.http_utils import AsyncHttpx
from zhenxun.utils.manager.priority_manager import PriorityLifecycle

driver: Driver = nonebot.get_driver()


@driver.on_startup
@PriorityLifecycle.on_startup()
async def update_city():
"""
部分插件需要中国省份城市
Expand Down Expand Up @@ -61,7 +62,7 @@ async def _():
await update_city()


@driver.on_startup
@PriorityLifecycle.on_startup()
async def _():
"""开启/禁用插件格式修改"""
_, is_create = await GroupConsole.get_or_create(group_id=133133133)
Expand Down
3 changes: 1 addition & 2 deletions zhenxun/builtin_plugins/sign_in/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
store_true,
)
from nonebot_plugin_apscheduler import scheduler
from nonebot_plugin_uninfo import Uninfo

from zhenxun.configs.utils import (
Command,
Expand All @@ -23,7 +22,7 @@
from zhenxun.utils.message import MessageUtils

from ._data_source import SignManage
from .goods_register import driver # noqa: F401
from .goods_register import Uninfo
from .utils import clear_sign_data_pic

__plugin_meta__ = PluginMetadata(
Expand Down
10 changes: 1 addition & 9 deletions zhenxun/builtin_plugins/sign_in/goods_register.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
from decimal import Decimal

import nonebot
from nonebot.drivers import Driver
from nonebot_plugin_uninfo import Uninfo

from zhenxun.models.sign_user import SignUser
from zhenxun.models.user_console import UserConsole
from zhenxun.utils.decorator.shop import shop_register
from zhenxun.utils.platform import PlatformUtils

driver: Driver = nonebot.get_driver()


# @driver.on_startup
# async def _():
# """
# 导入内置的三个商品
# """
driver = nonebot.get_driver()


@shop_register(
Expand Down
3 changes: 2 additions & 1 deletion zhenxun/builtin_plugins/sign_in/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from zhenxun.models.sign_user import SignUser
from zhenxun.utils.http_utils import AsyncHttpx
from zhenxun.utils.image_utils import BuildImage
from zhenxun.utils.manager.priority_manager import PriorityLifecycle
from zhenxun.utils.platform import PlatformUtils

from .config import (
Expand Down Expand Up @@ -54,7 +55,7 @@
]


@driver.on_startup
@PriorityLifecycle.on_startup()
async def init_image():
SIGN_RESOURCE_PATH.mkdir(parents=True, exist_ok=True)
SIGN_TODAY_CARD_PATH.mkdir(exist_ok=True, parents=True)
Expand Down
5 changes: 4 additions & 1 deletion zhenxun/builtin_plugins/web_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
from zhenxun.services.log import logger, logger_
from zhenxun.utils.enum import PluginType
from zhenxun.utils.manager.priority_manager import PriorityLifecycle

from .api.configure import router as configure_router
from .api.logs import router as ws_log_routes
from .api.logs.log_manager import LOG_STORAGE
from .api.menu import router as menu_router
Expand Down Expand Up @@ -82,6 +84,7 @@
BaseApiRouter.include_router(plugin_router)
BaseApiRouter.include_router(system_router)
BaseApiRouter.include_router(menu_router)
BaseApiRouter.include_router(configure_router)


WsApiRouter = APIRouter(prefix="/zhenxun/socket")
Expand All @@ -91,7 +94,7 @@
WsApiRouter.include_router(chat_routes)


@driver.on_startup
@PriorityLifecycle.on_startup(priority=0)
async def _():
try:

Expand Down
Loading