Add !unban command

This commit is contained in:
Yash Karandikar 2023-06-26 16:28:07 -05:00
parent 4e8934903e
commit 0cd4fa9b39

View file

@ -110,6 +110,20 @@ async fn main() -> anyhow::Result<()> {
format!("{:#?}", channel_users).replace("\n", "\r\n"),
)?;
}
} else if let Some(mut user) = message.strip_prefix("!unban ") {
user = user.trim();
if !user.is_empty() {
if let Some(users) = channel_users.get_mut(channel) {
if let Some(status) = users.get_mut(user) {
*status = Status::TimeoutCount(0);
let mode =
Mode::Minus(ChannelMode::Ban, Some(format!("{}!*@*", user)));
client.send_mode(channel, &[mode])?;
client.send_privmsg(channel, format!("Unbanned {}", user))?;
}
}
}
}
let users = unwrap_or_continue!(channel_users.get_mut(channel));
let user = unwrap_or_continue!(users.get_mut(nick));