diff --git a/README.md b/README.md
index 2e755b1..5583f9a 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,10 @@ Commands
Allows you to see current configuration values.
+* `unset `
+
+ Allows you to reset a configuration option back to the default value.
+
* `status`
Check the status of current conditions.
diff --git a/notifo.cpp b/notifo.cpp
index 340cba4..fa67fdb 100644
--- a/notifo.cpp
+++ b/notifo.cpp
@@ -47,6 +47,7 @@ class CNotifoMod : public CModule
// Configuration options
MCString options;
+ MCString defaults;
public:
@@ -69,15 +70,15 @@ class CNotifoMod : public CModule
user = GetUser();
// Notifo user account and secret
- options["username"] = "";
- options["secret"] = "";
+ defaults["username"] = "";
+ defaults["secret"] = "";
// Notification conditions
- options["client_count_less_than"] = "0";
+ defaults["client_count_less_than"] = "0";
// Notification settings
- options["message_length"] = "100";
- options["message_uri"] = "";
+ defaults["message_length"] = "100";
+ defaults["message_uri"] = "";
}
virtual ~CNotifoMod() {}
@@ -237,13 +238,17 @@ class CNotifoMod : public CModule
*/
bool OnLoad(const CString& args, CString& message)
{
- for (MCString::iterator i = options.begin(); i != options.end(); i++)
+ for (MCString::iterator i = defaults.begin(); i != defaults.end(); i++)
{
CString value = GetNV(i->first);
if (value != "")
{
options[i->first] = value;
}
+ else
+ {
+ options[i->first] = defaults[i->first];
+ }
}
authencode();
@@ -377,6 +382,30 @@ class CNotifoMod : public CModule
authencode();
}
}
+ // UNSET command
+ else if (action == "unset")
+ {
+ if (token_count != 2)
+ {
+ PutModule("Usage: unset ");
+ return;
+ }
+
+ CString option = tokens[1].AsLower();
+ MCString::iterator pos = options.find(option);
+
+ if (pos == options.end())
+ {
+ PutModule("Error: invalid option name");
+ }
+ else
+ {
+ options[option] = defaults[option];
+ DelNV(option);
+
+ authencode();
+ }
+ }
// GET command
else if (action == "get")
{