summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/event.h11
-rw-r--r--modules/chanserv/main/chanserv.cpp56
-rw-r--r--modules/chanserv/set.cpp66
-rw-r--r--src/init.cpp2
-rw-r--r--src/servers.cpp3
5 files changed, 66 insertions, 72 deletions
diff --git a/include/event.h b/include/event.h
index c95544790..985eb6ef7 100644
--- a/include/event.h
+++ b/include/event.h
@@ -154,6 +154,17 @@ class EventManager
namespace Event
{
+ struct CoreExport PostInit : Events
+ {
+ static constexpr const char *NAME = "postinit";
+
+ using Events::Events;
+
+ /** Called after initialization but before connect
+ */
+ virtual void OnPostInit() anope_abstract;
+ };
+
struct CoreExport PreUserKicked : Events
{
static constexpr const char *NAME = "preuserkicked";
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
diff --git a/src/init.cpp b/src/init.cpp
index aed6b8a24..98b753eb4 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -594,6 +594,8 @@ void Anope::Init(int ac, char **av)
EventManager::Get()->Dispatch(&Event::LoadDatabase::OnLoadDatabase);;
Anope::Logger.Log("Databases loaded");
+ EventManager::Get()->Dispatch(&Event::PostInit::OnPostInit);
+
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
it->second->Sync();
}
diff --git a/src/servers.cpp b/src/servers.cpp
index 35f066f4a..f00f925d0 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -129,6 +129,7 @@ void Server::Burst()
ServiceBot *chanserv = Config->GetClient("ChanServ");
+ /* Burst channel state */
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
{
Channel *c = it->second;
@@ -139,6 +140,7 @@ void Server::Burst()
for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
IRCD->Send<messages::Join>(cit->second->user, c, &cit->second->status);
+ /* Burst b/e/I */
for (Channel::ModeList::const_iterator it2 = c->GetModes().begin(); it2 != c->GetModes().end(); ++it2)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(it2->first);
@@ -151,6 +153,7 @@ void Server::Burst()
if (!c->topic.empty() && !c->topic_setter.empty())
IRCD->Send<messages::Topic>(ci ? ci->WhoSends() : chanserv, c, c->topic, c->topic_ts, c->topic_setter);
+ /* Cause other channel metadata to be synced */
c->syncing = true;
}
}