refactor(config): 移除.env依赖并引入服务器配置模型
将项目配置系统从依赖.env文件和环境变量迁移到使用Pydantic模型进行集中管理。此举通过移除`python-dotenv`库简化了环境设置,并提高了配置的类型安全性和可维护性。 主要变更包括: - 移除`bot.py`中的.env加载逻辑。 - 新增`ServerConfig`模型来管理服务器的主机和端口。 - 更新`src/common/server.py`和`src/common/message/api.py`以从全局配置对象获取服务器设置,取代了`os.environ`。 - 从配置中移除了已废弃的`MaizoneIntercomConfig`。 - 在`bot_config_template.toml`中添加了新的`[server]`配置部分。
This commit is contained in:
committed by
Windpicker-owo
parent
212fb0a449
commit
26e20b2cd7
@@ -24,8 +24,8 @@ def get_global_api() -> MessageServer: # sourcery skip: extract-method
|
||||
|
||||
# 设置基本参数
|
||||
kwargs = {
|
||||
"host": os.environ["HOST"],
|
||||
"port": int(os.environ["PORT"]),
|
||||
"host": global_config.server.host,
|
||||
"port": int(global_config.server.port),
|
||||
"app": get_global_server().get_app(),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user