Utmost-Happiness-Planet / nonebot_plugin_forwarder

A plugin based on NoneBot2, which can broadcast message from Source Groups to Destination Groups.
GNU General Public License v3.0
19 stars 3 forks source link

[enhancement]: 建议增加从环境变量读取配置 #8

Closed wei-z-git closed 1 year ago

wei-z-git commented 1 year ago

建议增加从环境变量读取配置,便于在docker中运行

SakuraPuare commented 1 year ago

目前不就是从.env中读取配置吗?

ninthseason commented 1 year ago

我认为插件直接读取环境变量是徒增耦合。

不打算添加该功能。

但如果这种行为成为趋势,将考虑添加。 如果能举例几个有此功能的插件作为参考是最好的。

wei-z-git commented 1 year ago

Hello @ninthseason , Nonebot2 文档已经在推荐这种方式,大概是使用Pydantic来管理配置: https://nb2.baka.icu/docs/tutorial/plugin/config-plugin

之前我参考(抄)的简易群管就是这样: https://github.com/yzyyz1387/nonebot_plugin_admin/blob/main/nonebot_plugin_admin/config.py

主要俺的机器人是Docker部署,配置和应用程序需要分离,不然每次改配置都需要重新build image, 要疯

另外我顺手参考(抄)文档改了下,初步测试通过(居然可以用!),PR如下,供参考: https://github.com/Utmost-Happiness-Planet/nonebot_plugin_forwarder/pull/9

ninthseason commented 1 year ago

已合并,感谢贡献