summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/chanserv/cs_statusupdate.cpp62
1 files changed, 26 insertions, 36 deletions
diff --git a/modules/chanserv/cs_statusupdate.cpp b/modules/chanserv/cs_statusupdate.cpp
index ed7469501..23d13f692 100644
--- a/modules/chanserv/cs_statusupdate.cpp
+++ b/modules/chanserv/cs_statusupdate.cpp
@@ -11,57 +11,47 @@
class StatusUpdate final
: public Module
{
-public:
- StatusUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+private:
+ void OnAccessChange(ChannelInfo *ci, ChanAccess *access, bool adding)
{
+ if (!ci->c)
+ return;
- }
-
- void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
- {
- if (ci->c)
+ for (const auto &[_, uc] : ci->c->users)
{
- for (const auto &[_, uc] : ci->c->users)
+ auto *user = uc->user;
+
+ ChannelInfo *next;
+ if (user->server != Me && access->Matches(user, user->Account(), next))
{
- User *user = uc->user;
+ auto ag = ci->AccessFor(user);
- ChannelInfo *next;
- if (user->server != Me && access->Matches(user, user->Account(), next))
+ for (auto *cms : ModeManager::GetStatusChannelModesByRank())
{
- AccessGroup ag = ci->AccessFor(user);
+ if (!ag.HasPriv("AUTO" + cms->name))
+ ci->c->RemoveMode(NULL, cms, user->GetUID());
+ }
- for (auto *cms : ModeManager::GetStatusChannelModesByRank())
- {
- if (!ag.HasPriv("AUTO" + cms->name))
- ci->c->RemoveMode(NULL, cms, user->GetUID());
- }
+ if (adding)
ci->c->SetCorrectModes(user, true);
- }
}
}
}
- void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
+public:
+ StatusUpdate(const Anope::string &modname, const Anope::string &creator)
+ : Module(modname, creator, VENDOR)
{
- if (ci->c)
- {
- for (const auto &[_, uc] : ci->c->users)
- {
- User *user = uc->user;
+ }
- ChannelInfo *next;
- if (user->server != Me && access->Matches(user, user->Account(), next))
- {
- AccessGroup ag = ci->AccessFor(user);
+ void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
+ {
+ OnAccessChange(ci, access, true);
+ }
- for (auto *cms : ModeManager::GetStatusChannelModesByRank())
- {
- if (!ag.HasPriv("AUTO" + cms->name))
- ci->c->RemoveMode(NULL, cms, user->GetUID());
- }
- }
- }
- }
+ void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
+ {
+ OnAccessChange(ci, access, false);
}
};