mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 12:41:05 +08:00
更新到 2.12.20
This commit is contained in:
parent
cb87108804
commit
91aa3f7bd9
|
@ -11,7 +11,7 @@ use crate::error::{ClientResult, IcaError};
|
||||||
use crate::{version_str, StopGetter};
|
use crate::{version_str, StopGetter};
|
||||||
|
|
||||||
/// icalingua 客户端的兼容版本号
|
/// icalingua 客户端的兼容版本号
|
||||||
pub const ICA_PROTOCOL_VERSION: &str = "2.12.12";
|
pub const ICA_PROTOCOL_VERSION: &str = "2.12.20";
|
||||||
|
|
||||||
pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientResult<(), IcaError> {
|
pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientResult<(), IcaError> {
|
||||||
let span = span!(Level::INFO, "Icalingua Client");
|
let span = span!(Level::INFO, "Icalingua Client");
|
||||||
|
|
|
@ -57,6 +57,14 @@ impl PluginConfigFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_table(&self) -> Option<&Table> {
|
||||||
|
self.data.get(CONFIG_KEY).and_then(|item| item.as_table())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_table_mut(&mut self) -> Option<&mut Table> {
|
||||||
|
self.data.get_mut(CONFIG_KEY).and_then(|item| item.as_table_mut())
|
||||||
|
}
|
||||||
|
|
||||||
/// 获取插件状态
|
/// 获取插件状态
|
||||||
/// 默认为 true
|
/// 默认为 true
|
||||||
pub fn get_status(&self, path: &Path) -> bool {
|
pub fn get_status(&self, path: &Path) -> bool {
|
||||||
|
@ -73,6 +81,23 @@ impl PluginConfigFile {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 删掉一个状态
|
||||||
|
pub fn remove_status(&mut self, path: &Path) -> Option<bool> {
|
||||||
|
let path_str = path.to_str().unwrap();
|
||||||
|
if let Some(table) = self.get_table_mut() {
|
||||||
|
if let Some(item) = table.get_mut(path_str) {
|
||||||
|
if let Some(bool) = item.as_bool() {
|
||||||
|
table.remove(path_str);
|
||||||
|
return Some(bool);
|
||||||
|
} else {
|
||||||
|
table.remove(path_str);
|
||||||
|
return Some(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
/// 设置插件状态
|
/// 设置插件状态
|
||||||
pub fn set_status(&mut self, path: &Path, status: bool) {
|
pub fn set_status(&mut self, path: &Path, status: bool) {
|
||||||
self.verify_and_init();
|
self.verify_and_init();
|
||||||
|
|
|
@ -41,6 +41,11 @@ impl PyStatus {
|
||||||
|
|
||||||
pub fn add_file(path: PathBuf, plugin: PyPlugin) { Self::get_map_mut().insert(path, plugin); }
|
pub fn add_file(path: PathBuf, plugin: PyPlugin) { Self::get_map_mut().insert(path, plugin); }
|
||||||
|
|
||||||
|
/// 删除一个插件
|
||||||
|
pub fn delete_file(path: &PathBuf) -> Option<PyPlugin> {
|
||||||
|
Self::get_map_mut().remove(path)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn verify_file(path: &PathBuf) -> bool {
|
pub fn verify_file(path: &PathBuf) -> bool {
|
||||||
Self::get_map().get(path).map_or(false, |plugin| plugin.verifiy())
|
Self::get_map().get(path).map_or(false, |plugin| plugin.verifiy())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user