Merge latest features from master branch

This commit is contained in:
John Reese 2012-10-26 11:31:13 -07:00
commit 11f5882e20
4 changed files with 89 additions and 13 deletions

View File

@ -1,5 +1,8 @@
push.so: push.cpp
znc-buildmod push.cpp
install: push.so
cp push.so $(HOME)/.znc/modules/push.so
clean:
-rm -f push.so

View File

@ -8,13 +8,14 @@ conditions. ZNC Push current supports the following services:
* [Boxcar][]
* [Notifo][]
* [Notify My Android][] (NMA)
* [Pushover][]
* [Prowl][]
* [Supertoasty][]
This project is still a Work In Progress, but should be functional enough and stable enough
for everyday usage. Users are more than welcome to submit feature requests or patches for
discussion or inclusion. Bug reports and feature requests can be submitted to
[my bug tracker][mantis] by selecting the "ZNC Push" project from the top right, or
sent via email.
[the repository issues list][issues], or sent via email.
For full functionality, this module requires ZNC version 0.090 or newer, but should compile
and run with a reduced feature set on versions as old as 0.078, the current version used by
@ -160,7 +161,9 @@ Configuration
* "boxcar"
* "notifo"
* "nma"
* "pushover"
* "prowl"
* "supertoasty"
* `username = ""`
@ -172,7 +175,14 @@ Configuration
Authentication token for push notifications.
This option must be set when using Notifo, Notify My Android, or Prowl.
This option must be set when using Notifo, Notify My Android, Pushover, Prowl or Supertoasty.
* `target = ""`
Device or target name for push notifications.
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.
### Conditions
@ -265,7 +275,7 @@ Configuration
truncated and ellipsized at or before this length is reached. A value of 0 (zero) will
disable this option.
* `message_url = ""`
* `message_uri = ""`
URI that will be sent with the notification to Notifo. This could be a web address or a
local scheme to access a mobile application. Keyword expansion is performed on this
@ -321,14 +331,6 @@ Configuration
in your `*push` window.
Roadmap
-------
### Settings
* Customizable notification titles and message formats.
License
-------
@ -339,9 +341,11 @@ This project is licensed under the MIT license. See the `LICENSE` file for deta
[Boxcar]: http://boxcar.io
[Notifo]: http://notifo.com
[Notify My Android]: http://www.notifymyandroid.com
[Pushover]: http://pushover.net
[Prowl]: http://www.prowlapp.com
[Supertoasty]: http://www.supertoasty.com
[mantis]: http://leetcode.net/mantis
[issues]: http://github.com/jreese/znc-push/issues
[ZNC]: http://en.znc.in "ZNC, an advanced IRC bouncer"
[ISO 8601]: http://en.wikipedia.org/wiki/ISO_8601 "ISO 8601 Date Format"

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -108,6 +108,7 @@ class CPushMod : public CModule
defaults["service"] = "";
defaults["username"] = "";
defaults["secret"] = "";
defaults["target"] = "";
// Condition strings
defaults["channel_conditions"] = "all";
@ -275,6 +276,34 @@ class CPushMod : public CModule
params["description"] = short_message;
params["url"] = uri;
}
else if (service == "pushover")
{
if (options["secret"] == "")
{
PutModule("Error: secret (user key) not set");
return;
}
CString pushover_api_token = "h6RToHDU7gNnB3IMyUb94SuwKtBzOD";
service_host = "api.pushover.net";
service_url = "/1/messages.json";
params["token"] = pushover_api_token;
params["user"] = options["secret"];
params["title"] = title;
params["message"] = short_message;
if (uri != "")
{
params["url"] = uri;
}
if (options["target"] != "")
{
params["device"] = options["target"];
}
}
else if (service == "prowl")
{
if (options["secret"] == "")
@ -292,6 +321,26 @@ class CPushMod : public CModule
params["description"] = short_message;
params["url"] = uri;
}
else if (service == "supertoasty")
{
if (options["secret"] == "")
{
PutModule("Error: secret (device id) not set");
return;
}
use_post = false;
use_port = 80;
use_ssl = false;
service_host = "api.supertoasty.com";
service_url = "/notify/"+options["secret"];
params["title"] = title;
params["text"] = short_message;
params["image"] = "https://github.com/jreese/znc-push/raw/supertoasty/logo.png";
params["sender"] = "ZNC Push";
}
else
{
PutModule("Error: service type not selected");
@ -885,10 +934,18 @@ class CPushMod : public CModule
{
PutModule("Note: NMA requires setting the 'secret' option");
}
else if (value == "pushover")
{
PutModule("Note: Pushover requires setting the 'secret' option");
}
else if (value == "prowl")
{
PutModule("Note: Prowl requires setting the 'secret' option");
}
else if (value == "supertoasty")
{
PutModule("Note: Supertoasty requires setting the 'secret' option with device id");
}
else
{
PutModule("Error: unknown service name");
@ -898,6 +955,8 @@ class CPushMod : public CModule
options[option] = value;
SetNV(option, options[option]);
PutModule("Ok");
}
}
// APPEND command
@ -926,6 +985,8 @@ class CPushMod : public CModule
options[option] += " " + value;
options[option].Trim();
SetNV(option, options[option]);
PutModule("Ok");
}
}
// PREPEND command
@ -954,6 +1015,8 @@ class CPushMod : public CModule
options[option] = value + " " + options[option];
options[option].Trim();
SetNV(option, options[option]);
PutModule("Ok");
}
}
// UNSET command
@ -976,6 +1039,8 @@ class CPushMod : public CModule
{
options[option] = defaults[option];
DelNV(option);
PutModule("Ok");
}
}
// GET command
@ -1200,12 +1265,16 @@ class CPushMod : public CModule
sock->Connect(service_host, use_port, use_ssl);
sock->Request(use_post, service_host, service_url, params, service_auth);
AddSocket(sock);
PutModule("Ok");
}
// SEND command
else if (action == "send")
{
CString message = command.Token(1, true, " ", true);
send_message(message);
PutModule("Ok");
}
// HELP command
else if (action == "help")