1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add basic C FFI for chat plugins and corresponding plugin loader

This commit is contained in:
NG (Graham)
2026-01-13 22:15:56 -05:00
parent f001ddfaf7
commit 455b466621
7 changed files with 147 additions and 5 deletions

View File

@@ -6,9 +6,9 @@ pub struct ChatProvider {
}
impl ChatProvider {
pub fn new(conf: oj_rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
pub fn new(conf: oj_rc_core::persist::config::ChatSystemConfig, dir: impl AsRef<std::path::Path>) -> std::io::Result<Self> {
Ok(Self {
chat_system: std::sync::Arc::new(tokio::sync::RwLock::new(crate::state::chat::ChatSystem::new(conf)?)),
chat_system: std::sync::Arc::new(tokio::sync::RwLock::new(crate::state::chat::ChatSystem::new(conf, dir)?)),
})
}
@@ -198,12 +198,12 @@ impl ChatSystem {
handle.send_private_message(response);
}
pub fn new(config: oj_rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
pub fn new(config: oj_rc_core::persist::config::ChatSystemConfig, dir: impl AsRef<std::path::Path>) -> std::io::Result<Self> {
Ok(Self {
chats: HashMap::new(),
online_users: HashMap::new(),
config: super::ChatSystemConfig::from_persist(config)?,
plugin: crate::PluginWrapper::new(vec![]), // TODO construct plugins
plugin: crate::PluginWrapper::new(crate::plugin_wrapper::load_chat_plugins(dir)),
})
}