diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-08-27 15:42:24 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-08-27 15:42:24 +0000 |
commit | 67c12453047f009692da518774ed6e49ee0acb9a (patch) | |
tree | d32e4f4afb8c1c066d0c7ec22cb43ca124d33b97 /src | |
parent | 4608413eb87259fa1f563c0aab5262b51154662c (diff) |
Add and document <shun:enabledcommands>, allowing customisation of specifically which commands shunned users may execute. NOTE: PART/QUIT (if allowed) will always suppress the PART/QUIT message. This needs some testing. :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10316 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_shun.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index cd944bda6..59588ab5e 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -145,6 +145,7 @@ class ModuleShun : public Module { cmd_shun* mycommand; ShunFactory *f; + std::map<std::string, bool> ShunEnabledCommands; public: ModuleShun(InspIRCd* Me) : Module(Me) @@ -155,8 +156,9 @@ class ModuleShun : public Module mycommand = new cmd_shun(ServerInstance); ServerInstance->AddCommand(mycommand); - Implementation eventlist[] = { I_OnStats, I_OnPreCommand, I_OnUserConnect }; - ServerInstance->Modules->Attach(eventlist, this, 3); + Implementation eventlist[] = { I_OnStats, I_OnPreCommand, I_OnUserConnect, I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, 4); + OnRehash(NULL, ""); } virtual ~ModuleShun() @@ -174,6 +176,25 @@ class ModuleShun : public Module return 1; } + virtual void OnRehash(User* user, const std::string ¶meter) + { + ConfigReader MyConf(ServerInstance); + std::string cmds = MyConf.ReadValue("shun", "enabledcommands", 0); + + if (cmds.empty()) + cmds = "PING PONG QUIT"; + + ShunEnabledCommands.clear(); + + std::stringstream dcmds(cmds); + std::string thiscmd; + + while (dcmds >> thiscmd) + { + ShunEnabledCommands[thiscmd] = true; + } + } + virtual void OnUserConnect(User* user) { if (!IS_LOCAL(user)) @@ -201,16 +222,21 @@ class ModuleShun : public Module return 0; } + std::map<std::string, bool>::iterator i = ShunEnabledCommands.find(command); + + if (i == ShunEnabledCommands.end()) + return 1; + if (command == "QUIT") { /* Allow QUIT but dont show any quit message */ parameters.clear(); - return 0; } - - /* Always allow PONG and PING */ - if (command == "PONG" || command == "PING") - return 0; + else if (command == "PART") + { + /* same for PART */ + parameters.clear(); + } return 1; } |