mirror of https://github.com/SeanOMik/znc-push.git
Add support for PushBullet device_iden in addition to device_id
This commit is contained in:
parent
90594e0764
commit
b7804ade9c
|
@ -233,7 +233,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.
|
||||
This option must be set when using PushBullet. This module supports both `device_id` (older, numeric id) and the newer `device_iden` (newer, alphanumeric id) used by PushBullet. You can find your `device_iden` by navigating to a device page and noting the last part of the URL.
|
||||
|
||||
### Notifications
|
||||
|
||||
|
|
21
push.cpp
21
push.cpp
|
@ -196,6 +196,18 @@ class CPushMod : public CModule
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies whether a given string contains only numbers.
|
||||
*
|
||||
* @param content String to verify
|
||||
*/
|
||||
bool is_number(const CString& content)
|
||||
{
|
||||
CString::const_iterator it = content.begin();
|
||||
while(it != content.end() && std::isdigit(*it)) ++it;
|
||||
return !content.empty() && it == content.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the currently-configured push service.
|
||||
* Requires (and assumes) that the user has already configured their
|
||||
|
@ -267,7 +279,14 @@ class CPushMod : public CModule
|
|||
service_auth = options["secret"] + CString(":");
|
||||
service_auth.Base64Encode();
|
||||
|
||||
params["device_id"] = options["target"];
|
||||
// Pushbullet uses number device_id but they
|
||||
// are transitioning to an alphanumeric device_iden
|
||||
if (is_number(options["target"]))
|
||||
{
|
||||
params["device_id"] = options["target"];
|
||||
} else {
|
||||
params["device_iden"] = options["target"];
|
||||
}
|
||||
params["type"] = "note";
|
||||
params["title"] = message_title;
|
||||
params["body"] = message_content;
|
||||
|
|
Loading…
Reference in New Issue