diff --git a/src/UniversalTelegramBot.cpp b/src/UniversalTelegramBot.cpp index 86cd747..af01734 100644 --- a/src/UniversalTelegramBot.cpp +++ b/src/UniversalTelegramBot.cpp @@ -560,7 +560,7 @@ bool UniversalTelegramBot::sendSimpleMessage(const String& chat_id, const String } bool UniversalTelegramBot::sendMessage(const String& chat_id, const String& text, - const String& parse_mode, int message_id) { // added message_id + const String& parse_mode, int message_id, bool silent) { // added message_id DynamicJsonDocument payload(maxMessageLength); payload["chat_id"] = chat_id; @@ -572,6 +572,9 @@ bool UniversalTelegramBot::sendMessage(const String& chat_id, const String& text if (parse_mode != "") payload["parse_mode"] = parse_mode; + if (silent) // if the message should be sent silently (no ringtone) - default is not silent + payload["disable_notification"] = true; + return sendPostMessage(payload.as(), message_id); // if message id == 0 then edit is false, else edit is true } diff --git a/src/UniversalTelegramBot.h b/src/UniversalTelegramBot.h index 5fc97ee..554c1bf 100644 --- a/src/UniversalTelegramBot.h +++ b/src/UniversalTelegramBot.h @@ -85,7 +85,7 @@ class UniversalTelegramBot { bool getMe(); bool sendSimpleMessage(const String& chat_id, const String& text, const String& parse_mode); - bool sendMessage(const String& chat_id, const String& text, const String& parse_mode = "", int message_id = 0); + bool sendMessage(const String& chat_id, const String& text, const String& parse_mode = "", int message_id = 0, bool silent=false); bool sendMessageWithReplyKeyboard(const String& chat_id, const String& text, const String& parse_mode, const String& keyboard, bool resize = false, bool oneTime = false,