Support telegram

Signed-off-by: Wen-chien Jesse Sung <jesse@cola.voip.idv.tw>
This commit is contained in:
Wen-chien Jesse Sung 2016-07-27 15:34:44 +08:00
parent 3c6a6a5ead
commit c01d078806
1 changed files with 18 additions and 0 deletions

View File

@ -676,6 +676,20 @@ class CPushMod : public CModule
params["level"] = options["message_priority"]; 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 else
{ {
PutModule("Error: service type not selected"); PutModule("Error: service type not selected");
@ -1423,6 +1437,10 @@ class CPushMod : public CModule
{ {
PutModule("Note: Pushjet requires setting 'secret' (service key) option"); 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 else
{ {
PutModule("Error: unknown service name"); PutModule("Error: unknown service name");