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

Move chat system into core, merge configs, save to database

This commit is contained in:
NG (Graham)
2025-05-23 16:46:12 -04:00
parent b83a23c115
commit 4f0bcde7d8
29 changed files with 362 additions and 331 deletions

View File

@@ -4,8 +4,34 @@ use serde::{Serialize, Deserialize};
pub struct ChatConfig {
#[serde(default = "default_pub_channs")]
pub public_channels: Vec<String>,
#[serde(default = "default_command_chann")]
pub command_channel: String,
pub commands: Vec<ChatCommand>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ChatCommand {
pub regex: String,
pub op: ChatOperation,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(tag = "type")]
pub enum ChatOperation {
BuiltIn(BuiltInChatOperation),
Custom,
#[serde(alias = "No-op")]
Nop,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(tag = "built_in")]
pub enum BuiltInChatOperation {
OnlineUsers,
TotalUsers,
}
fn default_pub_channs() -> Vec<String> {
vec![
"main".to_owned(),
@@ -13,3 +39,8 @@ fn default_pub_channs() -> Vec<String> {
"openjam_worship".to_owned(),
]
}
fn default_command_chann() -> String {
"sys".to_owned()
}