From 0c223ab07fc126daee1d01b5e85ca246d7bbb9ea Mon Sep 17 00:00:00 2001 From: "thealok@gmail.com" Date: Thu, 2 May 2013 21:29:39 -0400 Subject: [PATCH 1/3] fix tabbing --- push.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/push.cpp b/push.cpp index 8d706ee..f233264 100644 --- a/push.cpp +++ b/push.cpp @@ -76,13 +76,13 @@ class CPushMod : public CModule CString app; // Time last notification was sent for a given context - std::map last_notification_time; + std::map last_notification_time; // Time of last message by user to a given context - std::map last_reply_time; + std::map last_reply_time; // Time of last activity by user for a given context - std::map last_active_time; + std::map last_active_time; // Time of last activity by user in any context unsigned int idle_time; @@ -129,7 +129,7 @@ class CPushMod : public CModule defaults["nick_blacklist"] = ""; defaults["replied"] = "yes"; - // Advanced + // Advanced defaults["channel_conditions"] = "all"; defaults["query_conditions"] = "all"; defaults["debug"] = "off"; @@ -310,20 +310,20 @@ class CPushMod : public CModule params["url"] = message_uri; } - if ( options["message_uri_title"] != "" ) - { - params["url_title"] = options["message_uri_title"]; - } + if ( options["message_uri_title"] != "" ) + { + params["url_title"] = options["message_uri_title"]; + } if (options["target"] != "") { params["device"] = options["target"]; } - if ( options["message_sound"] != "" ) - { - params["sound"] = options["message_sound"]; - } + if ( options["message_sound"] != "" ) + { + params["sound"] = options["message_sound"]; + } if (options["message_priority"] != "") { From 128f727b833988e40086b69762d45b91ca3f6799 Mon Sep 17 00:00:00 2001 From: "thealok@gmail.com" Date: Thu, 2 May 2013 21:35:36 -0400 Subject: [PATCH 2/3] Add support for PushBullet https://www.pushbullet.com/ --- push.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/push.cpp b/push.cpp index f233264..f95022c 100644 --- a/push.cpp +++ b/push.cpp @@ -251,6 +251,26 @@ class CPushMod : public CModule params["title"] = message_title; params["uri"] = message_uri; } + else if (service == "pushbullet") + { + if (options["username"] == "" || options["secret"] == "") + { + PutModule("Error: username (device id) or secret (api key) not set"); + return; + } + + service_host = "www.pushbullet.com"; + service_url = "/api/pushes"; + + // BASIC auth, base64-encoded APIKey: + service_auth = options["secret"] + CString(":"); + service_auth.Base64Encode(); + + params["device_id"] = options["username"]; + params["type"] = "note"; + params["title"] = message_title; + params["body"] = message_content; + } else if (service == "boxcar") { if (options["username"] == "") @@ -1039,6 +1059,10 @@ class CPushMod : public CModule { PutModule("Note: Notifo requires setting both 'username' and 'secret' options"); } + else if (value == "pushbullet") + { + PutModule("Note: Pushbullet requires setting both 'username' (to device id) and 'secret' (to api key) options"); + } else if (value == "boxcar") { PutModule("Note: Boxcar requires setting the 'username' option"); From 49d8bb3a0aebde3a81d6f43ef9f7081628185f6d Mon Sep 17 00:00:00 2001 From: "thealok@gmail.com" Date: Thu, 9 May 2013 22:35:54 -0400 Subject: [PATCH 3/3] Cleanup and update docs --- README.md | 6 +++++- push.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd30a73..2e97f90 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ conditions. ZNC Push current supports the following services: * [Pushover][] * [Prowl][] * [Supertoasty][] +* [PushBullet][] * Custom URL GET requests This project is still a Work In Progress, but should be functional enough and stable enough @@ -190,6 +191,7 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or * "pushover" * "prowl" * "supertoasty" + * "pushbullet" * "url" * `username = ""` @@ -202,7 +204,7 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or Authentication token for push notifications. - This option must be set when using Notifo, Notify My Android, Pushover, Prowl or Supertoasty. + This option must be set when using Notifo, Notify My Android, Pushover, Prowl, Supertoasty or PushBullet. * `target = ""` @@ -211,6 +213,7 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or When using Pushover, this option allows you to specify a single device name to send notifications to; if blank or unset, notifications will be sent to all devices. + This option must be set when using PushBullet. ### Notifications @@ -391,6 +394,7 @@ This project is licensed under the MIT license. See the `LICENSE` file for deta [Pushover]: http://pushover.net [Prowl]: http://www.prowlapp.com [Supertoasty]: http://www.supertoasty.com +[PushBullet]: https://www.pushbullet.com/ [issues]: http://github.com/jreese/znc-push/issues [ZNC]: http://en.znc.in "ZNC, an advanced IRC bouncer" diff --git a/push.cpp b/push.cpp index f95022c..74ec51e 100644 --- a/push.cpp +++ b/push.cpp @@ -253,9 +253,9 @@ class CPushMod : public CModule } else if (service == "pushbullet") { - if (options["username"] == "" || options["secret"] == "") + if (options["target"] == "" || options["secret"] == "") { - PutModule("Error: username (device id) or secret (api key) not set"); + PutModule("Error: target (device id) or secret (api key) not set"); return; } @@ -266,7 +266,7 @@ class CPushMod : public CModule service_auth = options["secret"] + CString(":"); service_auth.Base64Encode(); - params["device_id"] = options["username"]; + params["device_id"] = options["target"]; params["type"] = "note"; params["title"] = message_title; params["body"] = message_content; @@ -1061,7 +1061,7 @@ class CPushMod : public CModule } else if (value == "pushbullet") { - PutModule("Note: Pushbullet requires setting both 'username' (to device id) and 'secret' (to api key) options"); + PutModule("Note: Pushbullet requires setting both 'target' (to device id) and 'secret' (to api key) options"); } else if (value == "boxcar") {