Merge pull request #35 from alok0/master

Support for PushBullet
This commit is contained in:
John Reese 2013-05-09 21:01:13 -07:00
commit 3e13fe55f9
2 changed files with 41 additions and 13 deletions

View File

@ -11,6 +11,7 @@ conditions. ZNC Push current supports the following services:
* [Pushover][] * [Pushover][]
* [Prowl][] * [Prowl][]
* [Supertoasty][] * [Supertoasty][]
* [PushBullet][]
* Custom URL GET requests * Custom URL GET requests
This project is still a Work In Progress, but should be functional enough and stable enough 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" * "pushover"
* "prowl" * "prowl"
* "supertoasty" * "supertoasty"
* "pushbullet"
* "url" * "url"
* `username = ""` * `username = ""`
@ -202,7 +204,7 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or
Authentication token for push notifications. 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 = ""` * `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 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. notifications to; if blank or unset, notifications will be sent to all devices.
This option must be set when using PushBullet.
### Notifications ### Notifications
@ -391,6 +394,7 @@ This project is licensed under the MIT license. See the `LICENSE` file for deta
[Pushover]: http://pushover.net [Pushover]: http://pushover.net
[Prowl]: http://www.prowlapp.com [Prowl]: http://www.prowlapp.com
[Supertoasty]: http://www.supertoasty.com [Supertoasty]: http://www.supertoasty.com
[PushBullet]: https://www.pushbullet.com/
[issues]: http://github.com/jreese/znc-push/issues [issues]: http://github.com/jreese/znc-push/issues
[ZNC]: http://en.znc.in "ZNC, an advanced IRC bouncer" [ZNC]: http://en.znc.in "ZNC, an advanced IRC bouncer"

View File

@ -76,13 +76,13 @@ class CPushMod : public CModule
CString app; CString app;
// Time last notification was sent for a given context // Time last notification was sent for a given context
std::map <CString, unsigned int> last_notification_time; std::map <CString, unsigned int> last_notification_time;
// Time of last message by user to a given context // Time of last message by user to a given context
std::map <CString, unsigned int> last_reply_time; std::map <CString, unsigned int> last_reply_time;
// Time of last activity by user for a given context // Time of last activity by user for a given context
std::map <CString, unsigned int> last_active_time; std::map <CString, unsigned int> last_active_time;
// Time of last activity by user in any context // Time of last activity by user in any context
unsigned int idle_time; unsigned int idle_time;
@ -129,7 +129,7 @@ class CPushMod : public CModule
defaults["nick_blacklist"] = ""; defaults["nick_blacklist"] = "";
defaults["replied"] = "yes"; defaults["replied"] = "yes";
// Advanced // Advanced
defaults["channel_conditions"] = "all"; defaults["channel_conditions"] = "all";
defaults["query_conditions"] = "all"; defaults["query_conditions"] = "all";
defaults["debug"] = "off"; defaults["debug"] = "off";
@ -251,6 +251,26 @@ class CPushMod : public CModule
params["title"] = message_title; params["title"] = message_title;
params["uri"] = message_uri; params["uri"] = message_uri;
} }
else if (service == "pushbullet")
{
if (options["target"] == "" || options["secret"] == "")
{
PutModule("Error: target (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["target"];
params["type"] = "note";
params["title"] = message_title;
params["body"] = message_content;
}
else if (service == "boxcar") else if (service == "boxcar")
{ {
if (options["username"] == "") if (options["username"] == "")
@ -310,20 +330,20 @@ class CPushMod : public CModule
params["url"] = message_uri; params["url"] = message_uri;
} }
if ( options["message_uri_title"] != "" ) if ( options["message_uri_title"] != "" )
{ {
params["url_title"] = options["message_uri_title"]; params["url_title"] = options["message_uri_title"];
} }
if (options["target"] != "") if (options["target"] != "")
{ {
params["device"] = options["target"]; params["device"] = options["target"];
} }
if ( options["message_sound"] != "" ) if ( options["message_sound"] != "" )
{ {
params["sound"] = options["message_sound"]; params["sound"] = options["message_sound"];
} }
if (options["message_priority"] != "") if (options["message_priority"] != "")
{ {
@ -1039,6 +1059,10 @@ class CPushMod : public CModule
{ {
PutModule("Note: Notifo requires setting both 'username' and 'secret' options"); PutModule("Note: Notifo requires setting both 'username' and 'secret' options");
} }
else if (value == "pushbullet")
{
PutModule("Note: Pushbullet requires setting both 'target' (to device id) and 'secret' (to api key) options");
}
else if (value == "boxcar") else if (value == "boxcar")
{ {
PutModule("Note: Boxcar requires setting the 'username' option"); PutModule("Note: Boxcar requires setting the 'username' option");