mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2025-02-23 01:49:57 +08:00
看着没问题?
This commit is contained in:
parent
974c2577c3
commit
9711af9444
|
@ -255,6 +255,19 @@ impl IcaClientPy {
|
|||
/// 返回是否成功
|
||||
pub fn reload_plugin_status(&self) -> bool { PyStatus::get_mut().config.reload_from_default() }
|
||||
|
||||
/// 设置某个插件的状态
|
||||
pub fn set_plugin_status(&self, plugin_name: String, status: bool) {
|
||||
PyStatus::get_mut().set_status(&plugin_name, status);
|
||||
}
|
||||
|
||||
pub fn get_plugin_status(&self, plugin_name: String) -> Option<bool> {
|
||||
PyStatus::get().get_status(&plugin_name)
|
||||
}
|
||||
|
||||
/// 同步状态到配置文件
|
||||
/// 这样关闭的时候就会保存状态
|
||||
pub fn sync_status_to_config(&self) { PyStatus::get_mut().config.sync_status_to_config(); }
|
||||
|
||||
/// 重新加载插件
|
||||
///
|
||||
/// 返回是否成功
|
||||
|
|
|
@ -77,6 +77,19 @@ impl TailchatClientPy {
|
|||
/// 返回是否成功
|
||||
pub fn reload_plugin_status(&self) -> bool { PyStatus::get_mut().config.reload_from_default() }
|
||||
|
||||
/// 设置某个插件的状态
|
||||
pub fn set_plugin_status(&self, plugin_name: String, status: bool) {
|
||||
PyStatus::get_mut().set_status(&plugin_name, status);
|
||||
}
|
||||
|
||||
pub fn get_plugin_status(&self, plugin_name: String) -> Option<bool> {
|
||||
PyStatus::get().get_status(&plugin_name)
|
||||
}
|
||||
|
||||
/// 同步状态到配置文件
|
||||
/// 这样关闭的时候就会保存状态
|
||||
pub fn sync_status_to_config(&self) { PyStatus::get_mut().config.sync_status_to_config(); }
|
||||
|
||||
/// 重新加载插件
|
||||
///
|
||||
/// 返回是否成功
|
||||
|
|
|
@ -162,6 +162,13 @@ impl PluginConfigFile {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn write_to_default(&self) -> Result<(), std::io::Error> {
|
||||
let config_path = MainStatus::global_config().py().config_path.clone();
|
||||
let config_path = Path::new(&config_path);
|
||||
let path = config_path.join(CONFIG_FILE_NAME);
|
||||
self.write_to_file(&path)
|
||||
}
|
||||
|
||||
pub fn write_to_file(&self, path: &PathBuf) -> Result<(), std::io::Error> {
|
||||
let config_path = path.join(CONFIG_FILE_NAME);
|
||||
std::fs::write(config_path, self.data.to_string())?;
|
||||
|
|
|
@ -434,9 +434,8 @@ pub fn init_py() {
|
|||
}
|
||||
|
||||
pub fn post_py() -> anyhow::Result<()> {
|
||||
PyStatus::get_mut().config.sync_status_to_config();
|
||||
PyStatus::get()
|
||||
.config
|
||||
.write_to_file(&PathBuf::from(MainStatus::global_config().py().config_path))?;
|
||||
let status = PyStatus::get_mut();
|
||||
status.config.sync_status_to_config();
|
||||
status.config.write_to_default()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
12
news.md
12
news.md
|
@ -23,6 +23,12 @@
|
|||
- 用于重新加载插件状态
|
||||
- 添加了 `reload_plugin(plugin_name: str)` api
|
||||
- 用于重新加载指定插件
|
||||
- 添加了 `set_plugin_status(plugin_name: str, status: bool)` api
|
||||
- 用于设置插件的启用状态
|
||||
- 添加了 `get_plugin_status(plugin_name: str) -> bool` api
|
||||
- 用于获取插件的启用状态
|
||||
- 添加了 `sync_status_to_config` api
|
||||
- 用于将内存中的插件状态同步到配置文件中
|
||||
|
||||
### tailchat 1.2.5
|
||||
|
||||
|
@ -30,6 +36,12 @@
|
|||
- 用于重新加载插件状态
|
||||
- 添加了 `reload_plugin(plugin_name: str)` api
|
||||
- 用于重新加载指定插件
|
||||
- 添加了 `set_plugin_status(plugin_name: str, status: bool)` api
|
||||
- 用于设置插件的启用状态
|
||||
- 添加了 `get_plugin_status(plugin_name: str) -> bool` api
|
||||
- 用于获取插件的启用状态
|
||||
- 添加了 `sync_status_to_config` api
|
||||
- 用于将内存中的插件状态同步到配置文件中
|
||||
|
||||
## 0.7.4
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user