summaryrefslogtreecommitdiff
path: root/src/config.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-09-04 21:04:37 -0400
committerAdam <Adam@anope.org>2011-09-10 02:06:31 -0400
commitdc5d1fa21c20000b77bf713585333c79121a8df0 (patch)
tree8661b0e4e8266c3fdf370d0bff0e5b7c900d9b24 /src/config.cpp
parent563d158e49754a7226b4bbcc8fa0c7f45a559cba (diff)
Made ChanServ privileges configurable
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 28a0b6a9c..5cb067735 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -872,6 +872,35 @@ static bool DoneCommands(ServerConfig *config, const Anope::string &)
return true;
}
+static bool InitPrivileges(ServerConfig *config, const Anope::string &)
+{
+ PrivilegeManager::ClearPrivileges();
+ return true;
+}
+
+static bool DoPrivileges(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *)
+{
+ Anope::string name = values[0].GetValue();
+ Anope::string desc = values[1].GetValue();
+
+ ValueItem vi(name);
+ if (!ValidateNotEmpty(config, "privilege", "name", vi))
+ throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information.");
+
+ vi = ValueItem(desc);
+ if (!ValidateNotEmpty(config, "privilege", "desc", vi))
+ throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information.");
+
+ PrivilegeManager::AddPrivilege(Privilege(name, desc));
+ return true;
+}
+
+static bool DonePrivileges(ServerConfig *config, const Anope::string &)
+{
+ Log(LOG_DEBUG) << "Loaded " << PrivilegeManager::GetPrivileges().size() << " privileges";
+ return true;
+}
+
/*************************************************************************/
static std::set<Anope::string> services;
@@ -1283,6 +1312,11 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"", "", "", "", ""},
{DT_STRING, DT_STRING, DT_STRING, DT_STRING},
InitCommands, DoCommands, DoneCommands},
+ {"privilege",
+ {"name", "desc", ""},
+ {"", "", ""},
+ {DT_STRING, DT_STRING, DT_STRING},
+ InitPrivileges, DoPrivileges, DonePrivileges},
{"",
{""},
{""},