From 78c00a2c130b735a0396dfc8119a1699b00680d4 Mon Sep 17 00:00:00 2001 From: Matteo Gheza Date: Mon, 10 Jan 2022 12:30:44 +0100 Subject: [PATCH] Fix Telegram bot notifications --- backend/telegramBotRouter.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/telegramBotRouter.php b/backend/telegramBotRouter.php index a49cda6..626e9b1 100644 --- a/backend/telegramBotRouter.php +++ b/backend/telegramBotRouter.php @@ -58,14 +58,20 @@ function sendTelegramNotification($message) //TODO: implement different types of notifications //TODO: add command for subscribing to notifications - $chats = $db->select("SELECT `chat_id` FROM `".DB_PREFIX."_bot_telegram_notifications`"); + $chats = $db->select("SELECT * FROM `".DB_PREFIX."_bot_telegram_notifications`"); if(!is_null($chats)) { foreach ($chats as $chat) { + if($chat['last_notification'] === $message) continue; $chat = $chat['chat_id']; $Bot->sendMessage([ "chat_id" => $chat, "text" => $message ]); + $db->update( + "`".DB_PREFIX."_bot_telegram_notifications`", + ["last_notification" => $message], + ["id" => $chat["id"]] + ); } } }