mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
✨ 支持整合包插件安装和添加整合包文档
This commit is contained in:
parent
cffc3762f2
commit
be52ec2bde
22
README.md
22
README.md
@ -126,6 +126,28 @@ AccessToken: PUBLIC_ZHENXUN_TEST
|
|||||||
- 提供了 cd,阻塞,每日次数等限制,仅仅通过简单的属性就可以生成一个限制,例如:`PluginCdBlock` 等
|
- 提供了 cd,阻塞,每日次数等限制,仅仅通过简单的属性就可以生成一个限制,例如:`PluginCdBlock` 等
|
||||||
- **更多详细请通过 [传送门](https://hibikier.github.io/zhenxun_bot/) 查看文档!**
|
- **更多详细请通过 [传送门](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
|
```bash
|
||||||
|
|||||||
@ -18,6 +18,8 @@ from zhenxun.utils.utils import is_number
|
|||||||
|
|
||||||
from .config import BASE_PATH, DEFAULT_GITHUB_URL, EXTRA_GITHUB_URL
|
from .config import BASE_PATH, DEFAULT_GITHUB_URL, EXTRA_GITHUB_URL
|
||||||
|
|
||||||
|
BAT_FILE = Path() / "win启动.bat"
|
||||||
|
|
||||||
|
|
||||||
def row_style(column: str, text: str) -> RowStyle:
|
def row_style(column: str, text: str) -> RowStyle:
|
||||||
"""被动技能文本风格
|
"""被动技能文本风格
|
||||||
@ -50,8 +52,26 @@ def install_requirement(plugin_path: Path):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
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(
|
result = subprocess.run(
|
||||||
["poetry", "run", "pip", "install", "-r", str(existing_requirements)],
|
command,
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import platform
|
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -23,6 +22,8 @@ driver = nonebot.get_driver()
|
|||||||
|
|
||||||
port = driver.config.port
|
port = driver.config.port
|
||||||
|
|
||||||
|
BAT_FILE = Path() / "win启动.bat"
|
||||||
|
|
||||||
FILE_NAME = ".configure_restart"
|
FILE_NAME = ".configure_restart"
|
||||||
|
|
||||||
|
|
||||||
@ -58,11 +59,12 @@ async def _(setting: Setting) -> Result:
|
|||||||
Config.set_config("web-ui", "username", setting.username)
|
Config.set_config("web-ui", "username", setting.username)
|
||||||
Config.set_config("web-ui", "password", setting.password, True)
|
Config.set_config("web-ui", "password", setting.password, True)
|
||||||
env_file.write_text(env_text, encoding="utf-8")
|
env_file.write_text(env_text, encoding="utf-8")
|
||||||
|
for file in os.listdir(Path()):
|
||||||
|
if file.startswith(FILE_NAME):
|
||||||
|
Path(file).unlink()
|
||||||
flag_file = Path() / f"{FILE_NAME}_{int(time.time())}"
|
flag_file = Path() / f"{FILE_NAME}_{int(time.time())}"
|
||||||
flag_file.touch()
|
flag_file.touch()
|
||||||
return Result.ok(
|
return Result.ok(BAT_FILE.exists(), info="设置成功,请重启真寻以完成配置!")
|
||||||
platform.system() == "Windows", info="设置成功,请重启真寻以完成配置!"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
@ -92,20 +94,19 @@ async def run_restart_command(bat_path: Path, port: int):
|
|||||||
description="重启",
|
description="重启",
|
||||||
)
|
)
|
||||||
async def _() -> Result:
|
async def _() -> Result:
|
||||||
if platform.system() != "Windows":
|
if not BAT_FILE.exists():
|
||||||
return Result.fail("自动重启仅支持Windows系统,请尝试手动重启")
|
return Result.fail("自动重启仅支持意见整合包,请尝试手动重启")
|
||||||
flag_file = None
|
flag_file = next(
|
||||||
for file in os.listdir(Path()):
|
(Path() / file for file in os.listdir(Path()) if file.startswith(FILE_NAME)),
|
||||||
if file.startswith(FILE_NAME):
|
None,
|
||||||
flag_file = Path() / file
|
)
|
||||||
if not flag_file or not flag_file.exists():
|
if not flag_file or not flag_file.exists():
|
||||||
return Result.fail("重启标志文件不存在...")
|
return Result.fail("重启标志文件不存在...")
|
||||||
set_time = flag_file.name.split("_")[-1]
|
set_time = flag_file.name.split("_")[-1]
|
||||||
if time.time() - float(set_time) > 10 * 60:
|
if time.time() - float(set_time) > 10 * 60:
|
||||||
return Result.fail("重启标志文件已过期,请重新设置配置。")
|
return Result.fail("重启标志文件已过期,请重新设置配置。")
|
||||||
flag_file.unlink()
|
flag_file.unlink()
|
||||||
bat_path = Path() / "win启动.bat"
|
|
||||||
try:
|
try:
|
||||||
return Result.ok(info="执行重启命令成功")
|
return Result.ok(info="执行重启命令成功")
|
||||||
finally:
|
finally:
|
||||||
asyncio.create_task(run_restart_command(bat_path, port)) # noqa: RUF006
|
asyncio.create_task(run_restart_command(BAT_FILE, port)) # noqa: RUF006
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user