Added support for IRCv3.1 away-notify.

This commit is contained in:
Aaron Weiss 2015-05-21 22:40:08 -04:00
parent be7b7d3233
commit fc175bb68a
2 changed files with 10 additions and 2 deletions

View file

@ -8,6 +8,8 @@ pub enum Capability {
MultiPrefix,
/// [account-notify](http://ircv3.net/specs/extensions/account-notify-3.1.html)
AccountNotify,
/// [away-notify](http://ircv3.net/specs/extensions/away-notify-3.1.html)
AwayNotify,
}
impl AsRef<str> for Capability {
@ -15,6 +17,7 @@ impl AsRef<str> for Capability {
match *self {
Capability::MultiPrefix => "multi-prefix",
Capability::AccountNotify => "account-notify",
Capability::AwayNotify => "away-notify",
}
}
}
@ -27,5 +30,6 @@ mod test {
fn to_str() {
assert_eq!(MultiPrefix.as_ref(), "multi-prefix");
assert_eq!(AccountNotify.as_ref(), "account-notify");
assert_eq!(AwayNotify.as_ref(), "away-notify");
}
}

View file

@ -147,8 +147,12 @@ pub enum Command {
// IRCv3 support
/// CAP [*] COMMAND [*] :[param]
CAP(Option<String>, CapSubCommand, Option<String>, Option<String>),
// IRCv3.1 extensions
/// ACCOUNT [account name]
ACCOUNT(String),
// AWAY is already defined as a send-only message.
//AWAY(Option<String>),
}
impl Into<Message> for Command {
@ -267,8 +271,7 @@ impl Into<Message> for Command {
Message::from_owned(None, string("PONG"), Some(vec![s]), Some(t)),
Command::PONG(s, None) => Message::from_owned(None, string("PONG"), None, Some(s)),
Command::ERROR(m) => Message::from_owned(None, string("ERROR"), None, Some(m)),
Command::AWAY(Some(m)) => Message::from_owned(None, string("AWAY"), None, Some(m)),
Command::AWAY(None) => Message::from_owned(None, string("AWAY"), None, None),
Command::AWAY(m) => Message::from_owned(None, string("AWAY"), None, m),
Command::REHASH => Message::from_owned(None, string("REHASH"), None, None),
Command::DIE => Message::from_owned(None, string("DIE"), None, None),
Command::RESTART => Message::from_owned(None, string("RESTART"), None, None),
@ -318,6 +321,7 @@ impl Into<Message> for Command {
Message::from_owned(None, string("CAP"), Some(vec![s.string(), c]), p),
Command::CAP(Some(k), s, Some(c), p) =>
Message::from_owned(None, string("CAP"), Some(vec![k, s.string(), c]), p),
Command::ACCOUNT(a) =>
Message::from_owned(None, string("ACCOUNT"), Some(vec![a]), None),
}