Fix join/leave messages

This commit is contained in:
Yash Karandikar 2022-06-17 22:24:48 +05:30
parent 8faa4b2729
commit fb6bd5834d

View file

@ -46,6 +46,26 @@ pub async fn irc_loop(
}
while let Some(orig_message) = stream.next().await.transpose()? {
match orig_message.command {
Command::Response(response, args) => {
use irc::client::prelude::Response;
// if let Response::RPL_NAMREPLY = response {
if response == Response::RPL_NAMREPLY {
let channel = args[2].to_string();
let users = args[3]
.split(' ')
.map(ToOwned::to_owned)
.collect::<Vec<String>>();
channel_users.insert(channel, users);
}
continue;
}
_ => {}
};
let nickname = unwrap_or_continue!(orig_message.source_nickname());
if let Command::PRIVMSG(ref channel, ref message) = orig_message.command {
@ -122,18 +142,6 @@ pub async fn irc_loop(
.say(&http, format!("*{}* has quit ({})", nickname, reason))
.await?;
}
} else if let Command::Response(ref response, ref args) = orig_message.command {
use irc::client::prelude::Response;
if let Response::RPL_NAMREPLY = response {
let channel = args[2].to_string();
let users = args[3]
.split(' ')
.map(ToOwned::to_owned)
.collect::<Vec<String>>();
channel_users.insert(channel, users);
}
} else if let Command::NICK(ref new_nick) = orig_message.command {
for (channel, users) in &mut channel_users {
let channel_id = ChannelId::from(*unwrap_or_continue!(mapping.get(channel)));