diff options
author | Adam <Adam@anope.org> | 2017-10-08 11:37:09 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-10-08 11:37:09 -0400 |
commit | 20c7bcad55597f17c01089ae2ec0c458bafa705f (patch) | |
tree | b23f8d20ed5caec167592debba920013aba23881 /modules | |
parent | 85f10a20bb3f59afb0d97e42452f2aea60882551 (diff) |
Simplify initial burst of persistent channels
Also don't create/destroy channels as persist is set on and off which no
longer makes since with the live database backend
Diffstat (limited to 'modules')
-rw-r--r-- | modules/chanserv/main/chanserv.cpp | 56 | ||||
-rw-r--r-- | modules/chanserv/set.cpp | 66 |
2 files changed, 50 insertions, 72 deletions
diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp index 2521ee22e..3c6fe000a 100644 --- a/modules/chanserv/main/chanserv.cpp +++ b/modules/chanserv/main/chanserv.cpp @@ -43,7 +43,7 @@ class ChanServCore : public Module , public EventHook<Event::Log> , public EventHook<Event::ExpireTick> , public EventHook<Event::CheckDelete> - , public EventHook<Event::PreUplinkSync> + , public EventHook<Event::PostInit> , public EventHook<Event::ChanRegistered> , public EventHook<Event::JoinChannel> , public EventHook<Event::ChanInfo> @@ -71,7 +71,7 @@ class ChanServCore : public Module , EventHook<Event::Log>(this) , EventHook<Event::ExpireTick>(this) , EventHook<Event::CheckDelete>(this) - , EventHook<Event::PreUplinkSync>(this) + , EventHook<Event::PostInit>(this) , EventHook<Event::ChanRegistered>(this) , EventHook<Event::JoinChannel>(this) , EventHook<Event::ChanInfo>(this) @@ -462,42 +462,42 @@ class ChanServCore : public Module return EVENT_CONTINUE; } - void OnPreUplinkSync(Server *serv) override + void OnPostInit() override { - /* Find all persistent channels and create them, as we are about to finish burst to our uplink */ + ChannelMode *perm = ModeManager::FindChannelModeByName("PERM"); + + /* Find all persistent channels and create them, so they will be bursted to the uplink */ for (ChanServ::Channel *ci : Serialize::GetObjects<ChanServ::Channel *>()) { - if (ci->IsPersist()) - { - bool created; - Channel *c = Channel::FindOrCreate(ci->GetName(), created, ci->GetTimeRegistered()); + if (!ci->IsPersist()) + continue; - if (ModeManager::FindChannelModeByName("PERM") != NULL) + bool created; + Channel *c = Channel::FindOrCreate(ci->GetName(), created, ci->GetTimeRegistered()); + c->syncing |= created; + + if (perm != nullptr) + { + c->SetMode(NULL, perm); + } + else + { + if (!ci->GetBot()) { - if (created) - IRCD->Send<messages::MessageChannel>(c); - c->SetMode(NULL, "PERM"); + ServiceBot *bi = ci->WhoSends(); + if (bi != nullptr) + bi->Assign(nullptr, ci); } - else - { - if (!ci->GetBot()) - { - ServiceBot *bi = ci->WhoSends(); - if (bi != nullptr) - bi->Assign(nullptr, ci); - } - if (ci->GetBot() != nullptr && c->FindUser(ci->GetBot()) == nullptr) - { - Anope::string botmodes = Config->GetModule("botserv/main")->Get<Anope::string>("botmodes", - Config->GetModule("chanserv/main")->Get<Anope::string>("botmodes")); - ChannelStatus status(botmodes); - ci->GetBot()->Join(c, &status); - } + if (ci->GetBot() != nullptr && c->FindUser(ci->GetBot()) == nullptr) + { + Anope::string botmodes = Config->GetModule("botserv/main")->Get<Anope::string>("botmodes", + Config->GetModule("chanserv/main")->Get<Anope::string>("botmodes")); + ChannelStatus status(botmodes); + ci->GetBot()->Join(c, &status); } } } - } void OnChanRegistered(ChanServ::Channel *ci) override diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp index bab6da8bc..dbe17f0ab 100644 --- a/modules/chanserv/set.cpp +++ b/modules/chanserv/set.cpp @@ -18,15 +18,12 @@ */ #include "module.h" -#include "modules/chanserv/mode.h" #include "modules/chanserv.h" #include "modules/chanserv/info.h" #include "modules/chanserv/set.h" class CommandCSSet : public Command { - ServiceReference<ModeLocks> mlocks; - public: CommandCSSet(Module *creator) : Command(creator, "chanserv/set", 2, 3) { @@ -491,8 +488,6 @@ inline static Anope::string BotModes() class CommandCSSetPersist : public Command { - ServiceReference<ModeLocks> mlocks; - public: CommandCSSetPersist(Module *creator, const Anope::string &cname = "chanserv/set/persist") : Command(creator, cname, 2, 2) { @@ -537,47 +532,33 @@ class CommandCSSetPersist : public Command { ci->SetPersist(true); - /* Channel doesn't exist, create it */ Channel *c = ci->GetChannel(); - if (!c) - { - bool created; - c = Channel::FindOrCreate(ci->GetName(), created); - if (ci->GetBot()) - { - ChannelStatus status(BotModes()); - ci->GetBot()->Join(c, &status); - } - if (created) - c->Sync(); - } - - /* Set the perm mode */ - if (cm) - { - if (c && !c->HasMode("PERM")) - c->SetMode(NULL, cm); - /* Add it to the channels mlock */ - if (mlocks) - mlocks->SetMLock(ci, cm, true, "", source.GetNick()); - } - /* No botserv bot, no channel mode, give them ChanServ. - * Yes, this works fine with no BotServ. - */ - else if (!ci->GetBot()) + if (c) { - ServiceBot *ChanServ = Config->GetClient("ChanServ"); - if (!ChanServ) + /* Set the perm mode */ + if (cm) { - source.Reply(_("ChanServ is required to enable persist on this network.")); - return; + if (c && !c->HasMode("PERM")) + c->SetMode(NULL, cm); } - - ChanServ->Assign(NULL, ci); - if (!c->FindUser(ChanServ)) + /* No botserv bot, no channel mode, give them ChanServ. + * Yes, this works fine with no BotServ. + */ + else if (!ci->GetBot()) { - ChannelStatus status(BotModes()); - ChanServ->Join(c, &status); + ServiceBot *ChanServ = Config->GetClient("ChanServ"); + if (!ChanServ) + { + source.Reply(_("ChanServ is required to enable persist on this network.")); + return; + } + + ChanServ->Assign(NULL, ci); + if (!c->FindUser(ChanServ)) + { + ChannelStatus status(BotModes()); + ChanServ->Join(c, &status); + } } } } @@ -601,9 +582,6 @@ class CommandCSSetPersist : public Command Channel *c = ci->GetChannel(); if (c && c->HasMode("PERM")) c->RemoveMode(NULL, cm); - /* Remove from mlock */ - if (mlocks) - mlocks->RemoveMLock(ci, cm, true); } /* No channel mode, no BotServ, but using ChanServ as the botserv bot * which was assigned when persist was set on |