Skip to content

Commit

Permalink
Add option for service name
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amyreese committed Sep 29, 2011
1 parent 1f76601 commit 7817e98
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -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 ...

Expand All @@ -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
Expand Down
32 changes: 30 additions & 2 deletions push.cpp
Expand Up @@ -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"] = "";

Expand Down Expand Up @@ -782,16 +783,35 @@ class CPushMod : public CModule
}
else
{
value.Trim();

if (option == "channel_conditions" || option == "query_conditions")
{
if (value != "all")
{
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();
Expand All @@ -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;
Expand All @@ -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];
Expand Down

0 comments on commit 7817e98

Please sign in to comment.