about summary refs log tree commit diff stats
path: root/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs40
1 files changed, 35 insertions, 5 deletions
diff --git a/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs b/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs
index c5320dd9..7db75672 100644
--- a/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs
+++ b/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs
@@ -5,6 +5,7 @@ use tracing::info;
 
 use crate::{
     clients::{Client, IdleClient},
+    config::Mode,
     dj::{Dj, algorithms::Discovery},
 };
 
@@ -26,7 +27,19 @@ enum SubCommand {
 
 #[derive(Subcommand)]
 enum DjCommand {
-    Start {},
+    Start {
+        /// The chance to select a "positive" track
+        #[arg(long)]
+        positive_chance: f64,
+
+        /// The chance to select a "neutral" track
+        #[arg(long)]
+        neutral_chance: f64,
+
+        /// The chance to select a "negative" track
+        #[arg(long)]
+        negative_chance: f64,
+    },
     Stop {},
 }
 
@@ -35,8 +48,17 @@ pub(crate) struct MessageQueue {
 }
 
 impl MessageQueue {
-    pub(crate) fn new() -> Self {
-        Self { dj: None }
+    pub(crate) fn new(mode: Mode) -> Self {
+        match mode {
+            Mode::Normal => Self { dj: None },
+            Mode::Dj => {
+                info!("Dj mode started on launch, as specified in config file");
+
+                Self {
+                    dj: Some(Dj::new(Discovery::new(0.65, 0.5, 0.2))),
+                }
+            }
+        }
     }
 
     pub(crate) async fn advance_dj(&mut self, client: &mut Client) -> Result<()> {
@@ -91,9 +113,17 @@ impl MessageQueue {
 
         match args.command {
             SubCommand::Dj { command } => match command {
-                DjCommand::Start {} => {
+                DjCommand::Start {
+                    positive_chance,
+                    neutral_chance,
+                    negative_chance,
+                } => {
                     info!("Dj started");
-                    self.dj = Some(Dj::new(Discovery::new()));
+                    self.dj = Some(Dj::new(Discovery::new(
+                        positive_chance,
+                        neutral_chance,
+                        negative_chance,
+                    )));
                     self.advance_dj(client).await?;
                 }
                 DjCommand::Stop {} => {