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
This commit is contained in:
John Reese 2011-09-29 10:21:15 -04:00
parent 1f76601c56
commit 7817e98dba
2 changed files with 32 additions and 2 deletions

View File

@ -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 can be obtained by logging into Notifo's website, clicking Settings, and then "Click to
Show" next to the "API Secret" heading: Show" next to the "API Secret" heading:
/msg *push set service notifo
/msg *push set username foo /msg *push set username foo
/msg *push set secret ... /msg *push set secret ...
@ -70,6 +71,7 @@ to set your configuration all over again:
/msg *notifo save /tmp/znc_notifo /msg *notifo save /tmp/znc_notifo
/msg *push load /tmp/znc_notifo /msg *push load /tmp/znc_notifo
/msg *push set service notifo
Commands Commands

View File

@ -88,7 +88,8 @@ class CPushMod : public CModule
// Current user // Current user
user = GetUser(); user = GetUser();
// Notifo user account and secret // Push service information
defaults["service"] = "";
defaults["username"] = ""; defaults["username"] = "";
defaults["secret"] = ""; defaults["secret"] = "";
@ -782,6 +783,8 @@ class CPushMod : public CModule
} }
else else
{ {
value.Trim();
if (option == "channel_conditions" || option == "query_conditions") if (option == "channel_conditions" || option == "query_conditions")
{ {
if (value != "all") if (value != "all")
@ -789,9 +792,26 @@ class CPushMod : public CModule
eval(value); 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] = value;
options[option].Trim();
SetNV(option, options[option]); SetNV(option, options[option]);
authencode(); authencode();
@ -814,6 +834,10 @@ class CPushMod : public CModule
{ {
PutModule("Error: invalid option name"); PutModule("Error: invalid option name");
} }
else if (option == "service")
{
PutModule("Error: cannot append to this option");
}
else else
{ {
options[option] += " " + value; options[option] += " " + value;
@ -840,6 +864,10 @@ class CPushMod : public CModule
{ {
PutModule("Error: invalid option name"); PutModule("Error: invalid option name");
} }
else if (option == "service")
{
PutModule("Error: cannot prepend to this option");
}
else else
{ {
options[option] = value + " " + options[option]; options[option] = value + " " + options[option];