Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
feat: add a config option to check public instance-only features
Browse files Browse the repository at this point in the history
  • Loading branch information
nashiradeer committed Apr 15, 2024
1 parent 909ec43 commit e20d315
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- Add a config option to enable public instance-only features.
- New project icon.

### Changed
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ pub struct Config {
pub lavalink: Option<Vec<LavalinkConfig>>,
/// The token of the Discord bot.
pub discord_token: Option<String>,
/// If the bot is running in the public instance.
pub public_instance: Option<bool>,
}

impl Config {
Expand Down Expand Up @@ -191,11 +193,19 @@ impl Config {
.discord_token
.or_else(|| env::var("HYDROGEN_DISCORD_TOKEN").ok());

// Get the public instance from the environment.
let public_instance = self.public_instance.or_else(|| {
env::var("HYDROGEN_PUBLIC_INSTANCE")
.ok()
.map(|s| matches!(s.to_lowercase().as_str(), "true" | "yes" | "1" | "enabled"))
});

Self {
default_language,
language_path,
lavalink,
discord_token,
public_instance,
}
}
}
Expand Down

0 comments on commit e20d315

Please sign in to comment.