Fix Telegram bot notifications

This commit is contained in:
Matteo Gheza 2022-01-10 12:30:44 +01:00
parent 8a5d6a2aa7
commit 78c00a2c13
1 changed files with 7 additions and 1 deletions

View File

@ -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"]]
);
}
}
}