Implement PART update, check, and ban
This commit is contained in:
parent
ae984af15b
commit
603b7ec20b
24
src/main.rs
24
src/main.rs
|
@ -59,7 +59,9 @@ async fn main() -> anyhow::Result<()> {
|
||||||
match message.command {
|
match message.command {
|
||||||
Command::JOIN(ref channel, _, _) => {
|
Command::JOIN(ref channel, _, _) => {
|
||||||
let users = unwrap_or_continue!(channel_users.get_mut(channel));
|
let users = unwrap_or_continue!(channel_users.get_mut(channel));
|
||||||
users.insert(nick.to_string(), Status::TimeoutCount(0));
|
if !users.contains_key(nick) {
|
||||||
|
users.insert(nick.to_string(), Status::TimeoutCount(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Command::PRIVMSG(ref channel, ref message) => {
|
Command::PRIVMSG(ref channel, ref message) => {
|
||||||
if message.starts_with("!dbg") {
|
if message.starts_with("!dbg") {
|
||||||
|
@ -69,6 +71,26 @@ async fn main() -> anyhow::Result<()> {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Command::PART(ref channel, Some(ref message)) => {
|
||||||
|
if message == &conf.quit_message {
|
||||||
|
let users = unwrap_or_continue!(channel_users.get_mut(channel));
|
||||||
|
let user = unwrap_or_continue!(users.get_mut(nick));
|
||||||
|
|
||||||
|
*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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue