From 8379d9b27ebc8534f6b1dd1070bfe16181f6ce67 Mon Sep 17 00:00:00 2001 From: Travis La Marr Date: Mon, 2 Jan 2012 04:51:37 -0500 Subject: [PATCH 01/14] Fix #1: Add support for Supertoasty push service --- README.md | 5 ++++- logo.png | Bin 0 -> 1569 bytes push.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 logo.png diff --git a/README.md b/README.md index 68a43cc..bfaa067 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ conditions. ZNC Push current supports the following services: * [Notifo][] * [Notify My Android][] (NMA) * [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 @@ -161,6 +162,7 @@ Configuration * "notifo" * "nma" * "prowl" + * "supertoasty" * `username = ""` @@ -172,7 +174,7 @@ 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, Prowl or Supertoasty. ### Conditions @@ -340,6 +342,7 @@ This project is licensed under the MIT license. See the `LICENSE` file for deta [Notifo]: http://notifo.com [Notify My Android]: http://www.notifymyandroid.com [Prowl]: http://www.prowlapp.com +[Supertoasty]: http://www.supertoasty.com [mantis]: http://leetcode.net/mantis [ZNC]: http://en.znc.in "ZNC, an advanced IRC bouncer" diff --git a/logo.png b/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..0a916ff477f1b73081435c461d6eff606d7efdba GIT binary patch literal 1569 zcmeAS@N?(olHy`uVBq!ia0vp^mLSZ*1|)kVnp=UCWQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2v2cW|hp4h>{3jAFJg2T)jk)8oi3#0-$aN1{?c|g2d$P)DnfH z)bz|eTc!8A_bVx6rr0WloBA5~7C5J7WO`H;r3P2|g(O#HCtIc{+1n}DR9FEG$W1Lt zRH(?!$t$+1uvG$^YXxM3g!Ppaz)DK8ZIvL7itr6kaLzAERWQ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H49nWD9WzmvO9U0#p00i_>zopr059KH2><{9 literal 0 HcmV?d00001 diff --git a/push.cpp b/push.cpp index 560e02d..6818b0c 100644 --- a/push.cpp +++ b/push.cpp @@ -300,6 +300,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"); @@ -901,6 +921,10 @@ class CPushMod : public CModule { 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"); From 9761c72b828e3873d474262bae96e73cb71de277 Mon Sep 17 00:00:00 2001 From: John Reese Date: Mon, 23 Jul 2012 19:37:15 -0700 Subject: [PATCH 02/14] Fix #5: Wrong bugtracker link in readme --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bfaa067..0eba824 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,7 @@ conditions. ZNC Push current supports the following services: 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 @@ -344,7 +343,7 @@ This project is licensed under the MIT license. See the `LICENSE` file for deta [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" From 58e24cf33163d53e2f1e31af9f3229c927d8e5e3 Mon Sep 17 00:00:00 2001 From: John Reese Date: Mon, 23 Jul 2012 22:07:28 -0700 Subject: [PATCH 03/14] Fix #4: Add support for Pushover service --- README.md | 5 ++++- push.cpp | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0eba824..7654196 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ conditions. ZNC Push current supports the following services: * [Boxcar][] * [Notifo][] * [Notify My Android][] (NMA) +* [Pushover][] * [Prowl][] * [Supertoasty][] @@ -160,6 +161,7 @@ Configuration * "boxcar" * "notifo" * "nma" + * "pushover" * "prowl" * "supertoasty" @@ -173,7 +175,7 @@ Configuration Authentication token for push notifications. - This option must be set when using Notifo, Notify My Android, Prowl or Supertoasty. + This option must be set when using Notifo, Notify My Android, Pushover, Prowl or Supertoasty. ### Conditions @@ -340,6 +342,7 @@ 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 diff --git a/push.cpp b/push.cpp index 6818b0c..bef4151 100644 --- a/push.cpp +++ b/push.cpp @@ -283,6 +283,25 @@ 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["device"] = short_message; + params["title"] = title; + params["message"] = short_message; + } else if (service == "prowl") { if (options["secret"] == "") @@ -917,6 +936,10 @@ 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"); From 2806967e02ceed1b5da11a7bbd12ba445744ab75 Mon Sep 17 00:00:00 2001 From: John Reese Date: Wed, 25 Jul 2012 16:21:24 -0700 Subject: [PATCH 04/14] Remove roadmap from readme --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 7654196..04814ea 100644 --- a/README.md +++ b/README.md @@ -324,14 +324,6 @@ Configuration in your `*push` window. -Roadmap -------- - -### Settings - -* Customizable notification titles and message formats. - - License ------- From ea8c52e766352f6009bddd9681a5d69ae4094636 Mon Sep 17 00:00:00 2001 From: John Reese Date: Wed, 25 Jul 2012 16:22:10 -0700 Subject: [PATCH 05/14] Fix #6: Add 'target' option to support Pushover devices --- README.md | 7 +++++++ push.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 04814ea..6595b3e 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,13 @@ Configuration 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 diff --git a/push.cpp b/push.cpp index bef4151..ba469c1 100644 --- a/push.cpp +++ b/push.cpp @@ -114,6 +114,7 @@ class CPushMod : public CModule defaults["service"] = ""; defaults["username"] = ""; defaults["secret"] = ""; + defaults["target"] = ""; // Condition strings defaults["channel_conditions"] = "all"; @@ -298,9 +299,13 @@ class CPushMod : public CModule params["token"] = pushover_api_token; params["user"] = options["secret"]; - //params["device"] = short_message; params["title"] = title; params["message"] = short_message; + + if (options["target"] != "") + { + params["device"] = options["target"]; + } } else if (service == "prowl") { From 2aaef797f12b0aeca0275b8e2083401882557e12 Mon Sep 17 00:00:00 2001 From: John Reese Date: Fri, 31 Aug 2012 11:15:58 -0700 Subject: [PATCH 06/14] New make rule to copy module to default znc path --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 27dfa5d..f0b8809 100644 --- a/Makefile +++ b/Makefile @@ -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 From dae1940dd81b16f6a2365352455b3cff093932ed Mon Sep 17 00:00:00 2001 From: cbenard Date: Wed, 24 Oct 2012 16:50:23 -0500 Subject: [PATCH 07/14] Modified to compile under znc-msvc (ZNC for Windows): http://code.google.com/p/znc-msvc/ --- push.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/push.cpp b/push.cpp index ba469c1..0e0e441 100644 --- a/push.cpp +++ b/push.cpp @@ -10,6 +10,9 @@ #define REQUIRESSL +#ifdef WIN_MSVC +#include "stdafx.hpp" +#endif #include "znc.h" #include "Chan.h" #include "User.h" From 885e8aa36e3cfcd400c9e5dd712b9c92dac604f1 Mon Sep 17 00:00:00 2001 From: cbenard Date: Wed, 24 Oct 2012 16:54:41 -0500 Subject: [PATCH 08/14] Fix documentation to refer to message_uri and not message_url. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6595b3e..187f156 100644 --- a/README.md +++ b/README.md @@ -275,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 From 25cf019163fee6f0a8a6cafb6987399bb5a4e50a Mon Sep 17 00:00:00 2001 From: cbenard Date: Wed, 24 Oct 2012 17:59:17 -0500 Subject: [PATCH 09/14] Removed #ifdef include since it doesn't actually work. Added URI for Pushover. --- push.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/push.cpp b/push.cpp index 0e0e441..b68f764 100644 --- a/push.cpp +++ b/push.cpp @@ -10,9 +10,6 @@ #define REQUIRESSL -#ifdef WIN_MSVC -#include "stdafx.hpp" -#endif #include "znc.h" #include "Chan.h" #include "User.h" @@ -305,6 +302,11 @@ class CPushMod : public CModule params["title"] = title; params["message"] = short_message; + if (uri != "") + { + params["url"] = uri; + } + if (options["target"] != "") { params["device"] = options["target"]; From 80cd9753771c8d94f2cfd962effaa2ab34bcada6 Mon Sep 17 00:00:00 2001 From: John Reese Date: Fri, 26 Oct 2012 11:26:38 -0700 Subject: [PATCH 10/14] Fix #18: Respond Ok to silent commands that don't error --- push.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/push.cpp b/push.cpp index b68f764..87e2cce 100644 --- a/push.cpp +++ b/push.cpp @@ -967,6 +967,8 @@ class CPushMod : public CModule options[option] = value; SetNV(option, options[option]); + + PutModule("Ok"); } } // APPEND command @@ -995,6 +997,8 @@ class CPushMod : public CModule options[option] += " " + value; options[option].Trim(); SetNV(option, options[option]); + + PutModule("Ok"); } } // PREPEND command @@ -1023,6 +1027,8 @@ class CPushMod : public CModule options[option] = value + " " + options[option]; options[option].Trim(); SetNV(option, options[option]); + + PutModule("Ok"); } } // UNSET command @@ -1045,6 +1051,8 @@ class CPushMod : public CModule { options[option] = defaults[option]; DelNV(option); + + PutModule("Ok"); } } // GET command @@ -1271,12 +1279,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") From 10c8fb41ff458bf2432a0a0a43dd106e5e4d2f27 Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Mon, 16 Jul 2012 17:43:51 -0700 Subject: [PATCH 11/14] Fix #3: Fix compatibility with 0.207 dev builds --- push.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/push.cpp b/push.cpp index 87e2cce..a39e979 100644 --- a/push.cpp +++ b/push.cpp @@ -10,12 +10,13 @@ #define REQUIRESSL -#include "znc.h" -#include "Chan.h" -#include "User.h" -#include "Modules.h" +#include +#include +#include +#include +#include +#include #include "time.h" -#include "FileUtils.h" #if (!defined(VERSION_MAJOR) || !defined(VERSION_MINOR) || (VERSION_MAJOR == 0 && VERSION_MINOR < 72)) #error This module needs ZNC 0.072 or newer. @@ -494,9 +495,9 @@ class CPushMod : public CModule { #ifdef PUSH_AWAY CString value = options["away_only"].AsLower(); - return value != "yes" || user->IsIRCAway(); + return value != "yes" || GetNetwork()->IsIRCAway(); #else - return true + return true; #endif } @@ -507,7 +508,7 @@ class CPushMod : public CModule */ unsigned int client_count() { - return user->GetClients().size(); + return user->GetUserClients().size(); } /** @@ -558,7 +559,7 @@ class CPushMod : public CModule } } - CNick nick = user->GetIRCNick(); + CNick nick = user->GetNick(); if (message.find(nick.GetNick()) != string::npos) { @@ -1189,7 +1190,7 @@ class CPushMod : public CModule #ifdef PUSH_AWAY table.AddRow(); table.SetCell("Condition", "away"); - table.SetCell("Status", user->IsIRCAway() ? "yes" : "no"); + table.SetCell("Status", GetNetwork()->IsIRCAway() ? "yes" : "no"); #endif table.AddRow(); From 1dc2a13f66f6b860adb4cb5754072b2bf8a0b246 Mon Sep 17 00:00:00 2001 From: John Reese Date: Tue, 24 Jul 2012 09:23:11 -0700 Subject: [PATCH 12/14] Remove legacy version handling --- push.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/push.cpp b/push.cpp index a39e979..974c745 100644 --- a/push.cpp +++ b/push.cpp @@ -18,15 +18,6 @@ #include #include "time.h" -#if (!defined(VERSION_MAJOR) || !defined(VERSION_MINOR) || (VERSION_MAJOR == 0 && VERSION_MINOR < 72)) -#error This module needs ZNC 0.072 or newer. -#endif - -// Handle versions of ZNC older than 0.090 by disabling the away_only condition -#if VERSION_MAJOR == 0 && VERSION_MINOR >= 90 -#define PUSH_AWAY -#endif - // Forward declaration class CPushMod; @@ -122,9 +113,7 @@ class CPushMod : public CModule defaults["query_conditions"] = "all"; // Notification conditions -#ifdef PUSH_AWAY defaults["away_only"] = "no"; -#endif defaults["client_count_less_than"] = "0"; defaults["highlight"] = ""; defaults["idle"] = "0"; @@ -493,12 +482,8 @@ class CPushMod : public CModule */ bool away_only() { -#ifdef PUSH_AWAY CString value = options["away_only"].AsLower(); return value != "yes" || GetNetwork()->IsIRCAway(); -#else - return true; -#endif } /** @@ -1187,11 +1172,9 @@ class CPushMod : public CModule table.AddColumn("Condition"); table.AddColumn("Status"); -#ifdef PUSH_AWAY table.AddRow(); table.SetCell("Condition", "away"); table.SetCell("Status", GetNetwork()->IsIRCAway() ? "yes" : "no"); -#endif table.AddRow(); table.SetCell("Condition", "client_count"); From e1540e455ce42fae623f28bfaeecbe9a4736267d Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 30 Aug 2012 22:47:27 -0400 Subject: [PATCH 13/14] Fix #9: fix namespacing issues for map and string --- push.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/push.cpp b/push.cpp index 974c745..fd84d47 100644 --- a/push.cpp +++ b/push.cpp @@ -17,6 +17,7 @@ #include #include #include "time.h" +#include // Forward declaration class CPushMod; @@ -74,13 +75,13 @@ class CPushMod : public CModule CString app; // Time last notification was sent for a given context - map last_notification_time; + std::map last_notification_time; // Time of last message by user to a given context - map last_reply_time; + std::map last_reply_time; // Time of last activity by user for a given context - map last_active_time; + std::map last_active_time; // Time of last activity by user in any context unsigned int idle_time; @@ -546,7 +547,7 @@ class CPushMod : public CModule CNick nick = user->GetNick(); - if (message.find(nick.GetNick()) != string::npos) + if (message.find(nick.GetNick()) != std::string::npos) { return true; } From e80d02ab0b54593299d84c3095d591b0cdd654e0 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Fri, 31 Aug 2012 01:09:56 -0400 Subject: [PATCH 14/14] Get the number of clients on the network using the size of GetUserClients wasn't working for me --- push.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/push.cpp b/push.cpp index fd84d47..ce28976 100644 --- a/push.cpp +++ b/push.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "time.h" #include @@ -494,7 +495,7 @@ class CPushMod : public CModule */ unsigned int client_count() { - return user->GetUserClients().size(); + return GetNetwork()->GetClients().size(); } /**