Send MODE before joining any channels
This commit is contained in:
parent
077dfe3cb0
commit
97e1d562b8
15
src/lib.rs
15
src/lib.rs
|
@ -29,6 +29,7 @@ pub enum Command {
|
|||
USER(String, String, String, String),
|
||||
NICK(String),
|
||||
JOIN(String),
|
||||
MODE(String, Option<String>),
|
||||
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<str>
|
||||
}
|
||||
MODE(target, mode) => {
|
||||
let formatted = {
|
||||
if let Some(mode) = mode {
|
||||
format!("MODE {} {}", target, mode)
|
||||
} else {
|
||||
format!("MODE {}", target)
|
||||
}
|
||||
};
|
||||
|
||||
Cow::Owned(formatted) as Cow<str>
|
||||
}
|
||||
OTHER(_) => {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
|
|
Loading…
Reference in a new issue