Page 1 of 1

Silent Notifications in Telegram

Posted: Wednesday 12 December 2018 21:37
by MacJL
Hello,

I wanted to have silent notifications with the Telegram service. It's possible with Telegram API to send messages that does not produce sound or screen notifications when they are received, by adding the 'disable_notification' parameter.

In order to do that, I've patched the notifications/NotificationTelegram.cpp file to pass this parameter when the priority is low :

Code: Select all

@@ -46,6 +46,8 @@
        json["chat_id"] = _chatid;
        json["text"] = CURLEncode::URLDecode(Text);
        //json["body"] = CURLEncode::URLDecode(Text);
+       if ( Priority < 0 )
+               json["disable_notification"] = 1;
        sPostData = jsonWriter.write(json);

        //Add the required Content Type
Doing that, I've found a bug with Blocky when sending notification to a dedicated service with Priority and Sound. I've corrected it by adding 2 lines :

Code: Select all

@@ -2496,6 +2496,8 @@
                        }
                        else if (aParam.size() == 5)
                        {
+                               priority = aParam[2];
+                               sound = aParam[3];
                                subsystem = aParam[4];
                        }
                        m_sql.AddTaskItem(_tTaskItem::SendNotification(0, subject, body, std::string(""), atoi(priority.c_str()), sound, subsystem));
Do you think the patchs are good enough to be implemented? What is the process to propose these modifications?

Re: Silent Notifications in Telegram

Posted: Wednesday 12 December 2018 21:49
by SweetPants
MacJL wrote: Wednesday 12 December 2018 21:37 What is the process to propose these modifications?
The 'normal' way to do this is to create a Pull Request on github https://github.com/domoticz/domoticz

Re: Silent Notifications in Telegram

Posted: Sunday 16 December 2018 14:15
by MacJL