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 | |
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
-rw-r--r-- | conf/modules.conf.example | 7 | ||||
-rw-r--r-- | src/modules/m_shun.cpp | 40 |
2 files changed, 39 insertions, 8 deletions
diff --git a/conf/modules.conf.example b/conf/modules.conf.example index 09434ee7c..b77090f82 100644 --- a/conf/modules.conf.example +++ b/conf/modules.conf.example @@ -1222,8 +1222,13 @@ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Shun module: Provides the /shun command, which stops a user executing -# all commands except PING and PONG. +# most commands. #<module name="m_shun.so"> +# +# You may also configure which commands you wish a user to be able to +# perform. It should be noted that if a shunned user issues QUIT or PART +# then their message will be removed, as if they did not issue one. +#<shun enabledcommands="PING PONG QUIT PART JOIN"> #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Spy module: Provides the ability to see the complete names list of 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; } |