Skip to content

Commit 4ba6be0

Browse files
committed
refactor(Utils): 修正配置加载逻辑并更新相关功能
- 移除 hotlist_handler 中的重复代码行 - 更新版本号至 2.1.0+13010 - 修改配置加载逻辑,从 asyncio.run 改为同步方式 - 更新配置文件生成后的提示信息 - 调整配置加载的异步函数为同步函数 Signed-off-by: Shanshui2024 <[email protected]>
1 parent d0fbfc7 commit 4ba6be0

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

plugins/axt_plugin_hotlist.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ async def hotlist_handler(event: MessageEventPayload):
1919
"- acfun | AcFun热搜榜" + "\n" + \
2020
"- weibo | 微博热搜榜" + "\n" + \
2121
"- bilibili | 哔哩哔哩全站日榜" + "\n" + \
22-
"- douyin | 抖音热搜榜" + "\n" + \
2322
"- zhihu | 知乎热搜榜" + "\n" + \
2423
"- douyin | 抖音热搜榜" + "\n" + \
2524
"==========================" + "\n" + \

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "AxTBot-Public"
3-
version = "2.1.0+13001"
3+
version = "2.1.0+13010"
44
description = "AxTBot 社区机器人是由 AxT社区 开发并维护的公共、公益性QQ官方机器人,基于QQ开放平台 ,使用 Python 和 FastAPI 构建"
55
authors = [
66
{name = "Shanshui2024", email = "[email protected]"},

src/Utils/Config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from src.Utils.ConfigClass import ConfigBase
66

77

8-
asyncio.run(load_config(Path("config.yaml"))) # 确保配置已加载
8+
load_config(Path("config.yaml")) # 确保配置已加载
99

1010
def __init__ (self):
1111
"""初始化配置"""

src/Utils/ConfigCli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ def save_config(config: ConfigBase, path: Path):
139139
with open(path, 'w', encoding='utf-8') as f:
140140
f.write(yaml_content)
141141

142-
print(f"✅ 配置文件已生成: {path}\n请阅读以下文档:https://docs.axtn.net/AxTBot-v2.1/config/global.html 了解配置项含义")
142+
print(f"✅ 配置文件已生成: {path}\n请阅读以下文档:https://docs.axtn.net/axtbot/v2.1/config/global.html 了解配置项含义")
143143

144-
async def load_config(config_path: Path) -> ConfigBase:
144+
def load_config(config_path: Path) -> ConfigBase:
145145
"""加载配置,如果不存在则引导创建"""
146146
# 情况1: 配置文件不存在
147147
if not config_path.exists():

src/app/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async def startup_event(app: FastAPI):
1414
logger.debug("===========框架 startup 事件激活===========")
1515
logger.info("框架 前置处理 >>> 日志记录已启动")
1616
logger.info("框架 前置处理 >>> Tortoise ORM数据库已启动")
17-
await load_config(config_path=Path("config.yaml"))
17+
load_config(config_path=Path("config.yaml"))
1818
logger.debug(f"框架 前置处理 >>> 配置文件:{config}")
1919
logger.debug("------------------更新检查------------------")
2020
if config.Advanced.update:

0 commit comments

Comments
 (0)