mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Fix auto-selecting chat channel, add some more config options
This commit is contained in:
@@ -7,6 +7,10 @@ pub struct ChatConfig {
|
||||
#[serde(default = "default_command_chann")]
|
||||
pub command_channel: String,
|
||||
pub commands: Vec<ChatCommand>,
|
||||
#[serde(default = "default_selected_chann")]
|
||||
pub default_channel: String,
|
||||
#[serde(default = "default_true")]
|
||||
pub can_create_channels: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
@@ -36,7 +40,7 @@ fn default_pub_channs() -> Vec<String> {
|
||||
vec![
|
||||
"main".to_owned(),
|
||||
"sys".to_owned(),
|
||||
"openjam_worship".to_owned(),
|
||||
"jam_club".to_owned(),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -44,3 +48,11 @@ fn default_pub_channs() -> Vec<String> {
|
||||
fn default_command_chann() -> String {
|
||||
"sys".to_owned()
|
||||
}
|
||||
|
||||
fn default_selected_chann() -> String {
|
||||
"jam_club".to_owned()
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
@@ -288,6 +288,8 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
super::ChatSystemConfig {
|
||||
command_channel: self.chat.command_channel.clone(),
|
||||
commands: self.chat.commands.clone(),
|
||||
default_channel: self.chat.default_channel.clone(),
|
||||
can_create_channels: self.chat.can_create_channels,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,4 +410,12 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
(map.into_conf(), map_conf)
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn url_links(&self) -> super::LinksConfig {
|
||||
super::LinksConfig {
|
||||
feedback_url: self.settings.server.feedback_url.clone(),
|
||||
support_url: self.settings.server.support_url.clone(),
|
||||
wiki_url: self.settings.server.wiki_url.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ mod cubes_json;
|
||||
pub use cubes_json::CubeConfig;
|
||||
|
||||
mod traits;
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig};
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig};
|
||||
|
||||
pub type ConfigImpl = CubeConfig;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
// FIXME don't use serializable types in traits
|
||||
fn network_config(&self) -> crate::persist::NetworkConf;
|
||||
fn maps(&self) -> std::collections::HashMap<GameMap, MapConfig>;
|
||||
fn url_links(&self) -> LinksConfig;
|
||||
}
|
||||
|
||||
pub struct CompleteCampaignProvider {
|
||||
@@ -153,6 +154,8 @@ impl GarageUpgrades {
|
||||
pub struct ChatSystemConfig {
|
||||
pub command_channel: String,
|
||||
pub commands: Vec<crate::persist::ChatCommand>,
|
||||
pub default_channel: String,
|
||||
pub can_create_channels: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -355,3 +358,10 @@ pub struct MapConfig {
|
||||
pub spawns: std::collections::HashMap<u8, Vec<Point>>, // team -> points
|
||||
pub bases: std::collections::HashMap<u8, (Sphere, f32)>, // team -> base
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct LinksConfig {
|
||||
pub feedback_url: String,
|
||||
pub support_url: String,
|
||||
pub wiki_url: String,
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ fn default_gameplay_settings() -> super::GameplaySettings {
|
||||
shield_hps: 2_000,
|
||||
request_review_level: 10_000,
|
||||
critical_ratio: 5.0,
|
||||
cross_promo_image: "https://git.ngram.ca/OpenJam/servers/raw/branch/main/assets/robocraft/favicon.jpg".to_owned(),
|
||||
cross_promo_image: "https://git.ngram.ca/OpenJam/servers/raw/branch/main/assets/robocraft/default.png".to_owned(),
|
||||
cross_promo_link: "https://git.ngram.ca/OpenJam/servers".to_owned(),
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,12 @@ pub struct ServerSettings {
|
||||
pub queue_mode: QueueMode,
|
||||
#[serde(default = "default_cdn_root_url")]
|
||||
pub cdn_url: String,
|
||||
#[serde(default = "default_feedback_url")]
|
||||
pub feedback_url: String,
|
||||
#[serde(default = "default_support_url")]
|
||||
pub support_url: String,
|
||||
#[serde(default = "default_wiki_url")]
|
||||
pub wiki_url: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
|
||||
@@ -98,9 +104,24 @@ fn default_server_conf() -> ServerSettings {
|
||||
auto_signup: false,
|
||||
queue_mode: QueueMode::Notify,
|
||||
cdn_url: default_cdn_root_url(),
|
||||
feedback_url: default_feedback_url(),
|
||||
support_url: default_support_url(),
|
||||
wiki_url: default_wiki_url(),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_cdn_root_url() -> String {
|
||||
"http://127.0.0.1:8010".to_owned()
|
||||
}
|
||||
|
||||
fn default_feedback_url() -> String {
|
||||
"https://mstdn.ca/@ngram".to_owned()
|
||||
}
|
||||
|
||||
fn default_support_url() -> String {
|
||||
"https://rvlt.gg/jtVE0pD5".to_owned()
|
||||
}
|
||||
|
||||
fn default_wiki_url() -> String {
|
||||
"https://git.ngram.ca/OpenJam/servers/wiki".to_owned()
|
||||
}
|
||||
|
||||
@@ -1142,11 +1142,20 @@ impl super::GameEventSetter for GameEventSetterImpl {
|
||||
impl super::ChatUser for UserData {
|
||||
async fn subscribed_channels(&self) -> Result<polariton::operation::Typed<()>, i16> {
|
||||
let channels = self.subscribed_channels_strings().await?;
|
||||
log::info!("User is subscribed to channels {:?}", channels);
|
||||
Ok(polariton::operation::Typed::Arr(polariton::operation::Arr {
|
||||
ty: polariton::serdes::TypePrefix::HashMap, // hashtable
|
||||
items: channels.iter().map(|name| crate::data::channel::ChatChannelInfo {
|
||||
channel_name: name.to_owned(),
|
||||
members: Vec::default(),
|
||||
items: channels.into_iter().map(|name| crate::data::channel::ChatChannelInfo {
|
||||
channel_name: name,
|
||||
members: vec![
|
||||
crate::data::channel::ChatChannelMember {
|
||||
name: self.account.display_name.clone(),
|
||||
use_custom_avatar: false,
|
||||
state: crate::data::channel::ChatPlayerState::Idk0,
|
||||
custom_avatar: Vec::default(),
|
||||
avatar_id: 0,
|
||||
},
|
||||
],
|
||||
channel_ty: crate::data::channel::ChatChannelType::Public,
|
||||
}.as_transmissible()).collect()
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user