aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_cloak_user.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-06-20 15:40:25 +0100
committerGravatar Sadie Powell2023-06-20 15:40:25 +0100
commit6137aea7287294852a04f159d7add485ab99d103 (patch)
tree190ffd1ac2e26a108eb43badddda475b620f9279 /src/modules/m_cloak_user.cpp
parentMerge the cloak_account and cloak_nick modules. (diff)
Add support for cloaking users by their ident/username.
Diffstat (limited to 'src/modules/m_cloak_user.cpp')
-rw-r--r--src/modules/m_cloak_user.cpp26
1 files changed, 26 insertions, 0 deletions
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<ConfigTag>& tag, const CharState& hm) ATTR_NOT_NULL(2)
+ : UserMethod(engine, tag, hm)
+ {
+ }
+};
+
template <typename Method>
class UserEngine final
: public Cloak::Engine
@@ -182,6 +199,7 @@ class ModuleCloakUser final
private:
UserEngine<AccountMethod> accountcloak;
UserEngine<AccountIdMethod> accountidcloak;
+ UserEngine<IdentMethod> identcloak;
UserEngine<NickMethod> 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);