From 9b533e7ea37741808e63500e6f7b3273cfcb8e5a Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sat, 16 Nov 2024 11:30:32 +0000
Subject: [PATCH] fix: Respect `telegram.ban_alert` configuration
Signed-off-by: Awiteb
---
src/users_fetcher.rs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/users_fetcher.rs b/src/users_fetcher.rs
index a2d6d0b..f116aab 100644
--- a/src/users_fetcher.rs
+++ b/src/users_fetcher.rs
@@ -65,7 +65,9 @@ async fn check_new_user(
tracing::info!("@{} has been banned because `{re}`", user.username);
if config.dry_run {
// If it's a dry run, we don't need to ban the user
- ban_sender.send(user).await.ok();
+ if config.telegram.ban_alert {
+ ban_sender.send(user).await.ok();
+ }
return;
}
@@ -78,7 +80,7 @@ async fn check_new_user(
.await
{
tracing::error!("Error while banning a user: {err}");
- } else {
+ } else if config.telegram.ban_alert {
ban_sender.send(user).await.ok();
}
} else if let Some(re) = config.expressions.sus.is_match(&user) {
@@ -137,7 +139,7 @@ pub async fn users_fetcher(
tracing::info!("Starting users fetcher");
loop {
tokio::select! {
- _ = tokio::time::sleep(Duration::from_secs(20)) => {
+ _ = tokio::time::sleep(Duration::from_secs(120)) => {
tokio::spawn(check_new_users(
Arc::clone(&last_user_id),
Arc::clone(&request_client),