diff options
| author | 2021-05-22 15:38:48 +0100 | |
|---|---|---|
| committer | 2021-05-22 15:38:48 +0100 | |
| commit | d60c1fdec1027aa2abdca3ab4acd1165f90b69ec (patch) | |
| tree | e478c31c10068db42f03ce781955f0ce08a945bd /src/modules/m_delayjoin.cpp | |
| parent | Merge branch 'insp3' into master. (diff) | |
Refactor the population of exceptions in delayjoin.
Diffstat (limited to 'src/modules/m_delayjoin.cpp')
| -rw-r--r-- | src/modules/m_delayjoin.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 0d7475314..7cb469704 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -87,11 +87,25 @@ class ModuleDelayJoin , public CTCTags::EventListener , public Names::EventListener { - public: + private: IntExtItem unjoined; JoinHook joinhook; DelayJoinMode djm; + void PopulateExcepts(CUList& except, Membership* memb) + { + if (!unjoined.Get(memb)) + return; + + unjoined.Unset(memb); + for (const auto& [member, _] : memb->chan->GetUsers()) + { + if (member != memb->user && IS_LOCAL(member)) + except.insert(member); + } + } + + public: ModuleDelayJoin() : Module(VF_VENDOR, "Adds channel mode D (delayjoin) which hides JOIN messages from users until they speak.") , CTCTags::EventListener(this) @@ -145,16 +159,6 @@ ModResult ModuleDelayJoin::OnNamesListItem(LocalUser* issuer, Membership* memb, return MOD_RES_PASSTHRU; } -static void populate(CUList& except, Membership* memb) -{ - for (const auto& [member, _] : memb->chan->GetUsers()) - { - if (member == memb->user || !IS_LOCAL(member)) - continue; - except.insert(member); - } -} - void ModuleDelayJoin::OnUserJoin(Membership* memb, bool sync, bool created, CUList& except) { if (memb->chan->IsModeSet(djm)) @@ -163,20 +167,12 @@ void ModuleDelayJoin::OnUserJoin(Membership* memb, bool sync, bool created, CULi void ModuleDelayJoin::OnUserPart(Membership* memb, std::string &partmessage, CUList& except) { - if (unjoined.Get(memb)) - { - unjoined.Unset(memb); - populate(except, memb); - } + PopulateExcepts(except, memb); } void ModuleDelayJoin::OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& except) { - if (unjoined.Get(memb)) - { - unjoined.Unset(memb); - populate(except, memb); - } + PopulateExcepts(except, memb); } void ModuleDelayJoin::OnBuildNeighborList(User* source, IncludeChanList& include, std::map<User*, bool>& exception) |
