Port PART functionality to QUIT

This commit is contained in:
Yash Karandikar 2022-07-18 21:03:23 -05:00
parent 603b7ec20b
commit f6a03a792f
Signed by: karx
GPG key ID: A794DA2529474BA5

View file

@ -91,6 +91,27 @@ async fn main() -> anyhow::Result<()> {
}
}
}
Command::QUIT(Some(ref message)) => {
for (channel, users) in &mut channel_users {
let user = unwrap_or_continue!(users.get_mut(nick));
if message == &conf.quit_message {
*user = match user {
Status::TimeoutCount(count) => Status::TimeoutCount(*count + 1),
_ => *user,
};
if let Status::TimeoutCount(count) = user {
if *count > conf.timeout_limit.unwrap_or(1) {
let mode =
Mode::Plus(ChannelMode::Ban, Some(format!("{}!*@*", nick)));
client.send_mode(channel, &[mode])?;
*user = Status::Banned;
}
}
}
}
}
_ => {}
}
}