From 67c12453047f009692da518774ed6e49ee0acb9a Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 27 Aug 2008 15:42:24 +0000 Subject: Add and document , 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 --- src/modules/m_shun.cpp | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'src') 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 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::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; } -- cgit v1.2.3