Updated handle_message(...) to use Response everywhere as needed.
This commit is contained in:
parent
4a48093905
commit
da30e4bccd
1 changed files with 19 additions and 16 deletions
|
@ -117,14 +117,8 @@ impl<T> IrcServer<T> where T: IrcStream {
|
|||
/// Handles messages internally for basic bot functionality.
|
||||
#[experimental]
|
||||
fn handle_message(&self, msg: &Message) {
|
||||
if msg.command[] == "PING" {
|
||||
self.send(PONG(msg.suffix.as_ref().unwrap()[], None)).unwrap();
|
||||
} else if msg.command[] == "376" || msg.command[] == "422" {
|
||||
for chan in self.config.channels.iter() {
|
||||
self.send(JOIN(chan[], None)).unwrap();
|
||||
}
|
||||
}
|
||||
else if let Some(Response::RPL_NAMREPLY) = Response::from_message(msg) {
|
||||
if let Some(resp) = Response::from_message(msg) {
|
||||
if resp == Response::RPL_NAMREPLY {
|
||||
if let Some(users) = msg.suffix.clone() {
|
||||
if let [_, _, ref chan] = msg.args[] {
|
||||
for user in users.split_str(" ") {
|
||||
|
@ -137,6 +131,15 @@ impl<T> IrcServer<T> where T: IrcStream {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if resp == Response::RPL_ENDOFMOTD || resp == Response::ERR_NOMOTD {
|
||||
for chan in self.config.channels.iter() {
|
||||
self.send(JOIN(chan[], None)).unwrap();
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if msg.command[] == "PING" {
|
||||
self.send(PONG(msg.suffix.as_ref().unwrap()[], None)).unwrap();
|
||||
} else if msg.command[] == "JOIN" || msg.command[] == "PART" {
|
||||
let chan = match msg.suffix {
|
||||
Some(ref suffix) => suffix[],
|
||||
|
|
Loading…
Reference in a new issue