diff --git a/src/lib.rs b/src/lib.rs index 34e725a..01ee539 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,6 +29,7 @@ pub enum Command { USER(String, String, String, String), NICK(String), JOIN(String), + MODE(String, Option), OTHER(String), } @@ -77,6 +78,9 @@ impl Client { } let config = self.config.clone(); + if config.mode != "" { + self.write_command(Command::MODE(config.username, Some(config.mode)))?; + } for channel in config.channels.iter() { self.write_command(Command::JOIN(channel.to_string()))?; } @@ -145,6 +149,17 @@ impl Client { let formatted = format!("JOIN {}", channel); Cow::Owned(formatted) as Cow } + MODE(target, mode) => { + let formatted = { + if let Some(mode) = mode { + format!("MODE {} {}", target, mode) + } else { + format!("MODE {}", target) + } + }; + + Cow::Owned(formatted) as Cow + } OTHER(_) => { return Err(std::io::Error::new( std::io::ErrorKind::Other,