diff options
author | Sadie Powell <sadie@witchery.services> | 2020-09-27 03:43:16 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-09-27 11:37:42 +0100 |
commit | 8d20578991934d69e04011c950d742d720dd2421 (patch) | |
tree | 9c5ed86b1225262e33e863bd1d32994b8d27a9a3 /src | |
parent | e79d4ec07dfb7ecb8b54926906bd2c53a8061e37 (diff) |
Add a shun option for cleaning problematic allowed commands.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_shun.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 6be91ce67..307e6a694 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -154,6 +154,7 @@ class ModuleShun : public Module, public Stats::EventListener private: CommandShun cmd; ShunFactory shun; + insp::flat_set<std::string, irc::insensitive_swo> cleanedcommands; insp::flat_set<std::string, irc::insensitive_swo> enabledcommands; bool affectopers; bool allowtags; @@ -210,6 +211,11 @@ class ModuleShun : public Module, public Stats::EventListener { ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); + cleanedcommands.clear(); + irc::spacesepstream cleanedcmds(tag->getString("cleanedcommands", "AWAY PART QUIT")); + for (std::string cleanedcmd; cleanedcmds.GetToken(cleanedcmd); ) + cleanedcommands.insert(cleanedcmd); + enabledcommands.clear(); irc::spacesepstream enabledcmds(tag->getString("enabledcommands", "ADMIN OPER PING PONG QUIT", 1)); for (std::string enabledcmd; enabledcmds.GetToken(enabledcmd); ) @@ -244,18 +250,26 @@ class ModuleShun : public Module, public Stats::EventListener tag++; } } - if (command == "QUIT") - { - /* Allow QUIT but dont show any quit message */ - parameters.clear(); - } - else if ((command == "PART") && (parameters.size() > 1)) + + if (cleanedcommands.count(command)) { - /* same for PART */ - parameters.pop_back(); + if (command == "AWAY" && !parameters.empty()) + { + // Allow away but only for unsetting. + parameters.clear(); + } + else if (command == "PART" && parameters.size() > 1) + { + // Allow part but strip the message. + parameters.pop_back(); + } + else if (command == "QUIT" && !parameters.empty()) + { + // Allow quit but strip the message. + parameters.clear(); + } } - /* if we're here, allow the command. */ return MOD_RES_PASSTHRU; } |