Skip to content

Commit

Permalink
Merge pull request #77 from kilmanio/volume-config
Browse files Browse the repository at this point in the history
Added config for default volume
  • Loading branch information
fkaa committed Oct 24, 2020
2 parents 67c1189 + bde3c01 commit d0a3a0a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ address = "localhost"
# This uses the same format as bookmarks in the TeamSpeak 3 client.
channel = "Lobby"

# The default volume for the bot (0.0 to 1.0)
volume = 0.3

# Web server settings
webserver_enable = true
domain = "localhost"
Expand Down
5 changes: 5 additions & 0 deletions src/bot/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct MasterArgs {
pub master_name: String,
pub address: String,
pub channel: Option<String>,
pub volume: f64,
#[serde(default = "default_verbose")]
pub verbose: u8,
pub domain: String,
Expand Down Expand Up @@ -66,6 +67,7 @@ impl MasterBot {
master_name: args.master_name,
address: args.address,
verbose: args.verbose,
volume: args.volume,
};

let bot_addr = Self {
Expand Down Expand Up @@ -141,6 +143,7 @@ impl MasterBot {
channel: channel_path,
verbose: self.config.verbose,
logger: self.logger.new(o!("musicbot" => name)),
volume: self.config.volume,
})
}

Expand Down Expand Up @@ -350,6 +353,7 @@ impl MasterArgs {
id: self.id,
channel,
verbose,
volume: self.volume,
}
}
}
Expand All @@ -358,4 +362,5 @@ pub struct MasterConfig {
pub master_name: String,
pub address: String,
pub verbose: u8,
pub volume: f64,
}
3 changes: 2 additions & 1 deletion src/bot/music.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ pub struct MusicBotArgs {
pub channel: String,
pub verbose: u8,
pub logger: Logger,
pub volume: f64,
}

impl MusicBot {
pub async fn spawn(args: MusicBotArgs) -> Address<Self> {
let mut player = AudioPlayer::new(args.logger.clone()).unwrap();
player.change_volume(VolumeChange::Absolute(0.5)).unwrap();
player.change_volume(VolumeChange::Absolute(args.volume)).unwrap();

let playlist = Playlist::new(args.logger.clone());

Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ async fn run(root_logger: Logger) -> Result<(), Box<dyn std::error::Error>> {
channel: String::from("local"),
verbose: bot_args.verbose,
logger: root_logger,
volume: bot_args.volume,
};
MusicBot::spawn(bot_args).await;

Expand Down

0 comments on commit d0a3a0a

Please sign in to comment.