From 7817e98dbaaa7645183f1e962460ad3382af1988 Mon Sep 17 00:00:00 2001 From: John Reese Date: Thu, 29 Sep 2011 10:21:15 -0400 Subject: [PATCH] Add option for service name Currently enforces either "notifo" or "boxcar", but does not yet change any behaviors in the rest of the module. Also prevents appending or prepending to the option value. Issue #226 --- README.md | 2 ++ push.cpp | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33e0aa0..5c13a20 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Then set your Notifo username and API secret. The API secret is not your passwo can be obtained by logging into Notifo's website, clicking Settings, and then "Click to Show" next to the "API Secret" heading: + /msg *push set service notifo /msg *push set username foo /msg *push set secret ... @@ -70,6 +71,7 @@ to set your configuration all over again: /msg *notifo save /tmp/znc_notifo /msg *push load /tmp/znc_notifo + /msg *push set service notifo Commands diff --git a/push.cpp b/push.cpp index 1170c71..769fb46 100644 --- a/push.cpp +++ b/push.cpp @@ -88,7 +88,8 @@ class CPushMod : public CModule // Current user user = GetUser(); - // Notifo user account and secret + // Push service information + defaults["service"] = ""; defaults["username"] = ""; defaults["secret"] = ""; @@ -782,6 +783,8 @@ class CPushMod : public CModule } else { + value.Trim(); + if (option == "channel_conditions" || option == "query_conditions") { if (value != "all") @@ -789,9 +792,26 @@ class CPushMod : public CModule eval(value); } } + else if (option == "service") + { + value.MakeLower(); + + if (value == "notifo") + { + PutModule("Note: Notifo requires setting both 'username' and 'secret' options"); + } + else if (value == "boxcar") + { + PutModule("Note: Boxcar requires setting the 'username' option"); + } + else + { + PutModule("Error: unknown service name"); + return; + } + } options[option] = value; - options[option].Trim(); SetNV(option, options[option]); authencode(); @@ -814,6 +834,10 @@ class CPushMod : public CModule { PutModule("Error: invalid option name"); } + else if (option == "service") + { + PutModule("Error: cannot append to this option"); + } else { options[option] += " " + value; @@ -840,6 +864,10 @@ class CPushMod : public CModule { PutModule("Error: invalid option name"); } + else if (option == "service") + { + PutModule("Error: cannot prepend to this option"); + } else { options[option] = value + " " + options[option];