Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added silent messaging to sendMessage() #361

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/UniversalTelegramBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<JsonObject>(), message_id); // if message id == 0 then edit is false, else edit is true
}

Expand Down
2 changes: 1 addition & 1 deletion src/UniversalTelegramBot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down