From 6137aea7287294852a04f159d7add485ab99d103 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 20 Jun 2023 15:40:25 +0100 Subject: Add support for cloaking users by their ident/username. --- src/modules/m_cloak_user.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/modules/m_cloak_user.cpp') diff --git a/src/modules/m_cloak_user.cpp b/src/modules/m_cloak_user.cpp index b01159b2a..85663e16b 100644 --- a/src/modules/m_cloak_user.cpp +++ b/src/modules/m_cloak_user.cpp @@ -154,6 +154,23 @@ public: } }; +class IdentMethod final + : public UserMethod +{ +private: + // Retrieves the middle segment of the cloak. + std::string GetMiddle(LocalUser* user) override + { + return user->ident; + } + +public: + IdentMethod(const Cloak::Engine* engine, const std::shared_ptr& tag, const CharState& hm) ATTR_NOT_NULL(2) + : UserMethod(engine, tag, hm) + { + } +}; + template class UserEngine final : public Cloak::Engine @@ -182,6 +199,7 @@ class ModuleCloakUser final private: UserEngine accountcloak; UserEngine accountidcloak; + UserEngine identcloak; UserEngine nickcloak; Cloak::API cloakapi; CharState hostmap; @@ -192,6 +210,7 @@ public: , Account::EventListener(this) , accountcloak(this, "account", hostmap) , accountidcloak(this, "account-id", hostmap) + , identcloak(this, "ident", hostmap) , nickcloak(this, "nick", hostmap) , cloakapi(this) { @@ -221,6 +240,13 @@ public: cloakapi->ResetCloaks(luser, true); } + void OnChangeIdent(User* user, const std::string& ident) override + { + LocalUser* luser = IS_LOCAL(user); + if (luser && cloakapi && cloakapi->IsActiveCloak(identcloak)) + cloakapi->ResetCloaks(luser, true); + } + void OnUserPostNick(User* user, const std::string& oldnick) override { LocalUser* luser = IS_LOCAL(user); -- cgit v1.3.1-10-gc9f91