Implemented PREPEND command for modifying config values

This commit is contained in:
John Reese 2011-01-19 12:54:05 -05:00
parent f2de10139c
commit 74c813a656
2 changed files with 33 additions and 2 deletions

View File

@ -74,6 +74,11 @@ Commands
Allows you to add a string to end of a configuration value. Automatically adds a
space to separate the appended value from the existing value.
* `prepend <option> <value>`
Allows you to add a string to beginning of a configuration value. Automatically adds
a space to separate the prepended value from the existing value.
* `get [<option>]`
Allows you to see current configuration values.

View File

@ -548,7 +548,7 @@ class CNotifoMod : public CModule
{
options[option] = value;
options[option].Trim();
SetNV(option, value);
SetNV(option, options[option]);
authencode();
}
@ -574,7 +574,33 @@ class CNotifoMod : public CModule
{
options[option] += " " + value;
options[option].Trim();
SetNV(option, value);
SetNV(option, options[option]);
authencode();
}
}
// PREPEND command
else if (action == "prepend")
{
if (token_count < 3)
{
PutModule("Usage: prepend <option> <value>");
return;
}
CString option = tokens[1].AsLower();
CString value = command.Token(2, true, " ");
MCString::iterator pos = options.find(option);
if (pos == options.end())
{
PutModule("Error: invalid option name");
}
else
{
options[option] = value + " " + options[option];
options[option].Trim();
SetNV(option, options[option]);
authencode();
}