Silent Notifications in Telegram

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
MacJL
Posts: 51
Joined: Tuesday 22 April 2014 22:17
Target OS: OS X
Domoticz version: Beta
Location: France
Contact:

Silent Notifications in Telegram

Post 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?
Last edited by MacJL on Wednesday 12 December 2018 23:04, edited 2 times in total.
SweetPants

Re: Silent Notifications in Telegram

Post 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
MacJL
Posts: 51
Joined: Tuesday 22 April 2014 22:17
Target OS: OS X
Domoticz version: Beta
Location: France
Contact:

Re: Silent Notifications in Telegram

Post by MacJL »

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest