Implemented support for chghost extension.
This commit is contained in:
parent
d773dafb22
commit
e6593f4335
2 changed files with 22 additions and 1 deletions
|
@ -18,6 +18,8 @@ pub enum Capability {
|
|||
AccountTag,
|
||||
/// [cap-notify](http://ircv3.net/specs/extensions/cap-notify-3.2.html)
|
||||
CapNotify,
|
||||
/// [chghost](http://ircv3.net/specs/extensions/chghost-3.2.html)
|
||||
ChgHost,
|
||||
}
|
||||
|
||||
/// List of IRCv3 capability negotiation versions.
|
||||
|
@ -38,6 +40,7 @@ impl AsRef<str> for Capability {
|
|||
Capability::Monitor => "monitor",
|
||||
Capability::AccountTag => "account-tag",
|
||||
Capability::CapNotify => "cap-notify",
|
||||
Capability::ChgHost => "chghost",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,5 +58,6 @@ mod test {
|
|||
assert_eq!(Monitor.as_ref(), "monitor");
|
||||
assert_eq!(AccountTag.as_ref(), "account-tag");
|
||||
assert_eq!(CapNotify.as_ref(), "cap-notify");
|
||||
assert_eq!(ChgHost.as_ref(), "chghost");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,7 +158,9 @@ pub enum Command {
|
|||
|
||||
// IRCv3.2 extensions
|
||||
/// MONITOR command [nicklist]
|
||||
MONITOR(String, Option<String>)
|
||||
MONITOR(String, Option<String>),
|
||||
/// CHGHOST user host
|
||||
CHGHOST(String, String),
|
||||
}
|
||||
|
||||
impl Into<Message> for Command {
|
||||
|
@ -335,6 +337,8 @@ impl Into<Message> for Command {
|
|||
Message::from_owned(None, string("MONITOR"), Some(vec![c, t]), None),
|
||||
Command::MONITOR(c, None) =>
|
||||
Message::from_owned(None, string("MONITOR"), Some(vec![c]), None),
|
||||
Command::CHGHOST(u, h) =>
|
||||
Message::from_owned(None, string("CHGHOST"), Some(vec![u, h]), None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1081,6 +1085,19 @@ impl Command {
|
|||
} else {
|
||||
return Err(invalid_input())
|
||||
}
|
||||
} else if let "CHGHOST" = &m.command[..] {
|
||||
match m.suffix {
|
||||
Some(ref suffix) => if m.args.len() == 1 {
|
||||
Command::CHGHOST(m.args[0].clone(), suffix.clone())
|
||||
} else {
|
||||
return Err(invalid_input())
|
||||
},
|
||||
None => if m.args.len() == 2 {
|
||||
Command::CHGHOST(m.args[0].clone(), m.args[1].clone())
|
||||
} else {
|
||||
return Err(invalid_input())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Err(invalid_input())
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue