Add config setting controlling if a self-introduction message is posted after joining a room

Fixes https://github.com/etkecc/baibot/issues/32
This commit is contained in:
Slavi Pantaleev
2025-02-26 20:30:02 +02:00
parent 1ff7e8cf79
commit c051da2f4a
7 changed files with 49 additions and 0 deletions

View File

@@ -19,6 +19,9 @@ pub struct Config {
#[serde(default = "super::defaults::command_prefix")]
pub command_prefix: String,
#[serde(default)]
pub room: ConfigRoom,
pub access: ConfigAccess,
pub agents: ConfigAgents,
@@ -37,6 +40,7 @@ impl Config {
self.homeserver.validate()?;
self.user.validate()?;
self.persistence.validate()?;
self.room.validate()?;
self.access.validate()?;
if self.command_prefix.is_empty() {
@@ -243,6 +247,27 @@ impl PersistenceConfig {
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ConfigRoom {
#[serde(default = "super::defaults::room_post_join_self_introduction_enabled")]
pub post_join_self_introduction_enabled: bool,
}
impl ConfigRoom {
pub fn validate(&self) -> anyhow::Result<()> {
Ok(())
}
}
impl Default for ConfigRoom {
fn default() -> Self {
Self {
post_join_self_introduction_enabled: super::defaults::room_post_join_self_introduction_enabled(),
}
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ConfigAccess {
// Contains the admin whitelist patterns before parsing into regex.

View File

@@ -18,6 +18,10 @@ pub(super) fn command_prefix() -> String {
COMMAND_PREFIX.to_owned()
}
pub(super) fn room_post_join_self_introduction_enabled() -> bool {
true
}
pub(super) fn persistence_data_dir_path() -> Option<String> {
None
}

View File

@@ -11,6 +11,9 @@ pub const BAIBOT_USER_ENCRYPTION_RECOVERY_PASSPHRASE: &str =
pub const BAIBOT_COMMAND_PREFIX: &str = "BAIBOT_COMMAND_PREFIX";
pub const BAIBOT_ROOM_POST_JOIN_SELF_INTRODUCTION_ENABLED: &str =
"BAIBOT_ROOM_POST_JOIN_SELF_INTRODUCTION_ENABLED";
pub const BAIBOT_LOGGING: &str = "BAIBOT_LOGGING";
pub const BAIBOT_ACCESS_ADMIN_PATTERNS: &str = "BAIBOT_ACCESS_ADMIN_PATTERNS";