diff options
| author | 2021-06-07 06:59:23 +0100 | |
|---|---|---|
| committer | 2021-06-07 07:15:39 +0100 | |
| commit | d7f967bdfc2931771350a459c7eb77fa52f45517 (patch) | |
| tree | 93597d65440b4e9166e02405cf2b8c7dd8d9d2ca /src/modules/m_codepage.cpp | |
| parent | Release v4.0.0 alpha 1. (diff) | |
| parent | Add CI support for Windows. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/m_codepage.cpp')
| -rw-r--r-- | src/modules/m_codepage.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 74b8f138e..4d8281402 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -18,6 +18,7 @@ #include "inspircd.h" +#include "modules/isupport.h" class Codepage { @@ -170,6 +171,7 @@ class SingleByteCodepage final class ModuleCodepage final : public Module + , public ISupport::EventListener { private: // The currently active codepage. @@ -184,6 +186,9 @@ class ModuleCodepage final // The IsNick handler which was set before this module was loaded. const std::function<bool(const std::string&)> origisnick; + // The character set used for the codepage. + std::string charset; + template <typename T> void RehashHashmap(T& hashmap) { @@ -231,6 +236,7 @@ class ModuleCodepage final public: ModuleCodepage() : Module(VF_VENDOR | VF_COMMON, "Allows the server administrator to define what characters are allowed in nicknames and how characters should be compared in a case insensitive way.") + , ISupport::EventListener(this) , codepage(nullptr) , origcasemap(national_case_insensitive_map) , origcasemapname(ServerInstance->Config->CaseMapping) @@ -252,7 +258,9 @@ class ModuleCodepage final void ReadConfig(ConfigStatus& status) override { - const std::string name = ServerInstance->Config->ConfValue("codepage")->getString("name"); + auto codepagetag = ServerInstance->Config->ConfValue("codepage"); + + const std::string name = codepagetag->getString("name"); if (name.empty()) throw ModuleException("<codepage:name> is a required field!"); @@ -306,6 +314,7 @@ class ModuleCodepage final lower, reinterpret_cast<unsigned char*>(&lower), upper, reinterpret_cast<unsigned char*>(&upper)); } + charset = codepagetag->getString("charset"); std::swap(codepage, newcodepage); ServerInstance->IsNick = [this](const std::string& nick) { return codepage->IsValidNick(nick); }; CheckInvalidNick(); @@ -316,6 +325,12 @@ class ModuleCodepage final CheckRehash(newcodepage->casemap); } + void OnBuildISupport(ISupport::TokenMap& tokens) override + { + if (!charset.empty()) + tokens["CHARSET"] = charset; + } + void GetLinkData(LinkData& data, std::string& compatdata) override { codepage->GetLinkData(data, compatdata); |
