Added support for IRCv3.1 extended-join.
This commit is contained in:
parent
fc175bb68a
commit
3805c7c914
4 changed files with 23 additions and 12 deletions
|
@ -10,6 +10,8 @@ pub enum Capability {
|
|||
AccountNotify,
|
||||
/// [away-notify](http://ircv3.net/specs/extensions/away-notify-3.1.html)
|
||||
AwayNotify,
|
||||
/// [extended-join](http://ircv3.net/specs/extensions/extended-join-3.1.html)
|
||||
ExtendedJoin,
|
||||
}
|
||||
|
||||
impl AsRef<str> for Capability {
|
||||
|
@ -18,6 +20,7 @@ impl AsRef<str> for Capability {
|
|||
Capability::MultiPrefix => "multi-prefix",
|
||||
Capability::AccountNotify => "account-notify",
|
||||
Capability::AwayNotify => "away-notify",
|
||||
Capability::ExtendedJoin => "extended-join",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,5 +34,6 @@ mod test {
|
|||
assert_eq!(MultiPrefix.as_ref(), "multi-prefix");
|
||||
assert_eq!(AccountNotify.as_ref(), "account-notify");
|
||||
assert_eq!(AwayNotify.as_ref(), "away-notify");
|
||||
assert_eq!(ExtendedJoin.as_ref(), "extended-join");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub enum Command {
|
|||
|
||||
// 3.2 Channel operations
|
||||
/// JOIN chanlist [chankeys]
|
||||
JOIN(String, Option<String>),
|
||||
JOIN(String, Option<String>, Option<String>),
|
||||
/// PART chanlist :[comment]
|
||||
PART(String, Option<String>),
|
||||
// MODE is already defined.
|
||||
|
@ -152,7 +152,9 @@ pub enum Command {
|
|||
/// ACCOUNT [account name]
|
||||
ACCOUNT(String),
|
||||
// AWAY is already defined as a send-only message.
|
||||
//AWAY(Option<String>),
|
||||
// AWAY(Option<String>),
|
||||
// JOIN is already defined.
|
||||
// JOIN(String, Option<String>, Option<String>),
|
||||
}
|
||||
|
||||
impl Into<Message> for Command {
|
||||
|
@ -175,10 +177,10 @@ impl Into<Message> for Command {
|
|||
Command::QUIT(None) => Message::from_owned(None, string("QUIT"), None, None),
|
||||
Command::SQUIT(s, c) =>
|
||||
Message::from_owned(None, string("SQUIT"), Some(vec![s]), Some(c)),
|
||||
Command::JOIN(c, Some(k)) =>
|
||||
Message::from_owned(None, string("JOIN"), Some(vec![c, k]), None),
|
||||
Command::JOIN(c, None) =>
|
||||
Message::from_owned(None, string("JOIN"), Some(vec![c]), None),
|
||||
Command::JOIN(c, Some(k), n) =>
|
||||
Message::from_owned(None, string("JOIN"), Some(vec![c, k]), n),
|
||||
Command::JOIN(c, None, n) =>
|
||||
Message::from_owned(None, string("JOIN"), Some(vec![c]), n),
|
||||
Command::PART(c, Some(m)) =>
|
||||
Message::from_owned(None, string("PART"), Some(vec![c]), Some(m)),
|
||||
Command::PART(c, None) =>
|
||||
|
@ -427,16 +429,21 @@ impl Command {
|
|||
} else if let "JOIN" = &m.command[..] {
|
||||
match m.suffix {
|
||||
Some(ref suffix) => if m.args.len() == 0 {
|
||||
Command::JOIN(suffix.clone(), None)
|
||||
Command::JOIN(suffix.clone(), None, None)
|
||||
} else if m.args.len() == 1 {
|
||||
Command::JOIN(m.args[0].clone(), Some(suffix.clone()))
|
||||
Command::JOIN(m.args[0].clone(), Some(suffix.clone()), None)
|
||||
} else if m.args.len() == 2 {
|
||||
Command::JOIN(m.args[0].clone(), Some(m.args[1].clone()), Some(suffix.clone()))
|
||||
} else {
|
||||
return Err(invalid_input())
|
||||
},
|
||||
None => if m.args.len() == 1 {
|
||||
Command::JOIN(m.args[0].clone(), None)
|
||||
Command::JOIN(m.args[0].clone(), None, None)
|
||||
} else if m.args.len() == 2 {
|
||||
Command::JOIN(m.args[0].clone(), Some(m.args[1].clone()))
|
||||
Command::JOIN(m.args[0].clone(), Some(m.args[1].clone()), None)
|
||||
} else if m.args.len() == 3 {
|
||||
Command::JOIN(m.args[0].clone(), Some(m.args[1].clone()),
|
||||
Some(m.args[2].clone()))
|
||||
} else {
|
||||
return Err(invalid_input())
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ impl<T: IrcRead, U: IrcWrite> IrcServer<T, U> {
|
|||
self.config.umodes().to_owned(), None)).unwrap();
|
||||
}
|
||||
for chan in self.config.channels().into_iter() {
|
||||
self.send(JOIN(chan.to_owned(), None)).unwrap();
|
||||
self.send(JOIN(chan.to_owned(), None, None)).unwrap();
|
||||
}
|
||||
} else if resp == Response::ERR_NICKNAMEINUSE ||
|
||||
resp == Response::ERR_ERRONEOUSNICKNAME {
|
||||
|
|
|
@ -40,7 +40,7 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
|||
|
||||
/// Joins the specified channel or chanlist.
|
||||
fn send_join(&self, chanlist: &str) -> Result<()> {
|
||||
self.send(JOIN(chanlist.to_owned(), None))
|
||||
self.send(JOIN(chanlist.to_owned(), None, None))
|
||||
}
|
||||
|
||||
/// Attempts to oper up using the specified username and password.
|
||||
|
|
Loading…
Reference in a new issue