Unban users when they join back for real

This commit is contained in:
Yash Karandikar 2022-07-18 21:33:54 -05:00
parent f6a03a792f
commit 70f9b42d1b
Signed by: karx
GPG key ID: A794DA2529474BA5

View file

@ -59,6 +59,19 @@ async fn main() -> anyhow::Result<()> {
match message.command {
Command::JOIN(ref channel, _, _) => {
let users = unwrap_or_continue!(channel_users.get_mut(channel));
for (user, status) in users.iter_mut() {
if nick.starts_with(user) {
// They're joining back for real, unban them
*status = match status {
Status::Banned => Status::TimeoutCount(0),
_ => *status,
};
let mode = Mode::Minus(ChannelMode::Ban, Some(format!("{}!*@*", user)));
client.send_mode(channel, &[mode])?;
client.send_privmsg(nick, "You're unbanned, welcome back!")?;
}
}
if !users.contains_key(nick) {
users.insert(nick.to_string(), Status::TimeoutCount(0));
}