From c01d078806d15adc66653e06227310446d48692d Mon Sep 17 00:00:00 2001 From: Wen-chien Jesse Sung Date: Wed, 27 Jul 2016 15:34:44 +0800 Subject: [PATCH] Support telegram Signed-off-by: Wen-chien Jesse Sung --- push.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/push.cpp b/push.cpp index 57fef1b..77a2758 100755 --- a/push.cpp +++ b/push.cpp @@ -676,6 +676,20 @@ class CPushMod : public CModule params["level"] = options["message_priority"]; } } + else if (service == "telegram") + { + if ((options["secret"] == "") || (options["target"] =="")) + { + PutModule("Error: secret (API key) or target (chat_id) not set"); + return; + } + + service_host = "api.telegram.org"; + service_url = "/bot" + options["secret"] + "/sendMessage"; + + params["chat_id"] = options["target"]; + params["text"] = message_content; + } else { PutModule("Error: service type not selected"); @@ -1423,6 +1437,10 @@ class CPushMod : public CModule { PutModule("Note: Pushjet requires setting 'secret' (service key) option"); } + else if (value == "telegram") + { + PutModule("Note: Telegram requires setting both the 'secret' (api key) and 'target' (chat_id)"); + } else { PutModule("Error: unknown service name");