Skip to content

Commit 2673e7b

Browse files
committed
Add default values for old config if missing fields
1 parent 9fb1406 commit 2673e7b

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

src/config.rs

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ struct ConfigOld {
239239
}
240240

241241
#[derive(Serialize, Deserialize)]
242-
#[serde(rename_all = "camelCase")]
242+
#[serde(rename_all = "camelCase", default)]
243243
struct ObsOld {
244244
ip: String,
245245
password: String,
@@ -265,7 +265,7 @@ struct RtmpOld {
265265
}
266266

267267
#[derive(Serialize, Deserialize)]
268-
#[serde(rename_all = "camelCase")]
268+
#[serde(rename_all = "camelCase", default)]
269269
struct TwitchChat {
270270
channel: String,
271271
enable: bool,
@@ -419,6 +419,51 @@ impl From<RtmpOld> for stream_servers::StreamServer {
419419
}
420420
}
421421

422+
impl Default for ObsOld {
423+
fn default() -> Self {
424+
Self {
425+
ip: "localhost".to_string(),
426+
password: "password".to_string(),
427+
normal_scene: "live".to_string(),
428+
low_bitrate_scene: "low".to_string(),
429+
offline_scene: "offline".to_string(),
430+
refresh_scene: "refresh".to_string(),
431+
low_bitrate_trigger: 800,
432+
high_rtt_trigger: Some(2500),
433+
refresh_scene_interval: 10,
434+
only_switch_when_streaming: true,
435+
}
436+
}
437+
}
438+
439+
impl Default for TwitchChat {
440+
fn default() -> Self {
441+
Self {
442+
channel: "715209".to_string(),
443+
enable: true,
444+
prefix: "!".to_string(),
445+
enable_public_commands: true,
446+
public_commands: vec!["bitrate".to_string()],
447+
enable_mod_commands: true,
448+
mod_commands: vec![
449+
"refresh".to_string(),
450+
"fix".to_string(),
451+
"trigger".to_string(),
452+
"sourceinfo".to_string(),
453+
"obsinfo".to_string(),
454+
],
455+
enable_auto_switch_notification: true,
456+
enable_auto_stop_stream_on_host_or_raid: true,
457+
admin_users: vec!["715209".to_string(), "b3ck".to_string()],
458+
alias: Some(vec![
459+
vec!["r".to_string(), "refresh".to_string()],
460+
vec!["f".to_string(), "fix".to_string()],
461+
vec!["b".to_string(), "bitrate".to_string()],
462+
]),
463+
}
464+
}
465+
}
466+
422467
fn update_command(
423468
config: &mut HashMap<chat::Command, CommandInfo>,
424469
command: String,

0 commit comments

Comments
 (0)