From b049c8c7b47300f7502f29dfeb1dc63d4115c0e1 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 10 Jun 2025 09:23:17 +0100 Subject: Show disabled modes in 005 to allow clients to provide better UI. --- modules/disable.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'modules/disable.cpp') diff --git a/modules/disable.cpp b/modules/disable.cpp index ff52c94ed..e9eaa7af6 100644 --- a/modules/disable.cpp +++ b/modules/disable.cpp @@ -18,6 +18,7 @@ #include "inspircd.h" +#include "modules/isupport.h" enum { @@ -33,6 +34,7 @@ typedef std::vector CommandList; class ModuleDisable final : public Module + , public ISupport::EventListener { private: CommandList commands; @@ -75,6 +77,7 @@ private: public: ModuleDisable() : Module(VF_VENDOR, "Allows commands, channel modes, and user modes to be disabled.") + , ISupport::EventListener(this) { } @@ -122,6 +125,32 @@ public: notifyopers = tag->getBool("notifyopers"); } + void OnBuildISupport(ISupport::TokenMap& tokens) override + { + if (chanmodes.none() || usermodes.none()) + return; + + auto &buf = tokens["DISABLEDMODES"]; + for (unsigned char chr = '0'; chr <= 'z'; ++chr) + { + if (!ModeParser::IsModeChar(chr)) + continue; + + if (chanmodes.test(ModeParser::GetModeIndex(chr))) + buf.push_back(chr); + } + + buf.push_back(','); + for (unsigned char chr = '0'; chr <= 'z'; ++chr) + { + if (!ModeParser::IsModeChar(chr)) + continue; + + if (usermodes.test(ModeParser::GetModeIndex(chr))) + buf.push_back(chr); + } + } + ModResult OnNumeric(User* user, const Numeric::Numeric& numeric) override { if (numeric.GetNumeric() != RPL_COMMANDS || numeric.GetParams().empty()) -- cgit v1.3.1-10-gc9f91