Compare commits

..

3 Commits

Author SHA1 Message Date
28892d9fea Fix pending update count check in webhook handling
Some checks are pending
Build docker image / Build-Docker-Image (push) Waiting to run
2025-08-10 14:51:23 +02:00
6b39a837ff Update invalid token check to match new error message 2025-08-10 14:18:41 +02:00
9da1c4eed2 Fix typo in check_uninited function name and improve error logging 2025-08-10 13:52:09 +02:00

View File

@@ -97,7 +97,7 @@ impl BotsManager {
} }
} }
async fn check_unininted(bots_data: &[BotData]) { async fn check_uninited(bots_data: &[BotData]) {
let semaphore = Arc::new(Semaphore::const_new(5)); let semaphore = Arc::new(Semaphore::const_new(5));
let mut set_webhook_tasks = JoinSet::new(); let mut set_webhook_tasks = JoinSet::new();
@@ -143,7 +143,7 @@ impl BotsManager {
let _ = BotsManager::check_bots_data(&bots_data).await; let _ = BotsManager::check_bots_data(&bots_data).await;
if !only_bot_data { if !only_bot_data {
let _ = BotsManager::check_unininted(&bots_data).await; let _ = BotsManager::check_uninited(&bots_data).await;
} }
} }
@@ -174,7 +174,7 @@ impl BotsManager {
match result { match result {
Ok(webhook_info) => { Ok(webhook_info) => {
if webhook_info.pending_update_count != 0 { if webhook_info.pending_update_count == 0 {
continue; continue;
} }
@@ -185,7 +185,9 @@ impl BotsManager {
} }
} }
Err(err) => { Err(err) => {
if err.to_string().contains("Api(InvalidToken)") { let error_message = err.to_string();
if error_message.contains("Invalid bot token") {
BOTS_DATA.invalidate(token.as_str()).await; BOTS_DATA.invalidate(token.as_str()).await;
if let Err(d_err) = delete_bot(bot_data.id).await { if let Err(d_err) = delete_bot(bot_data.id).await {
log::error!("Error deleting bot {}: {:?}", bot_data.id, d_err); log::error!("Error deleting bot {}: {:?}", bot_data.id, d_err);
@@ -193,7 +195,7 @@ impl BotsManager {
continue; continue;
} }
log::error!("Error getting webhook info: {err:?}"); log::error!("Error getting webhook info: {error_message}");
WEBHOOK_CHECK_ERRORS_COUNT WEBHOOK_CHECK_ERRORS_COUNT
.insert(bot_data.id, error_count + 1) .insert(bot_data.id, error_count + 1)