From 847cceaba350444510b37f685d51fdfc584b1fd2 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 25 Aug 2013 02:59:54 -0400 Subject: Create persistent channels on startup, which used to work and got lost somewhere Fix some oddities with using persistent channels with no botserv Send list modes to uplink when bursting Fix issues with persist + keepmodes Fix /os modes clear all not clearing all status modes Fix operwall on ratbox/plexus Dont apply mlock in SetCorrectModes since that just recursively calls itself unncessarially Change command logging to show the command name and not the service name --- modules/commands/cs_set.cpp | 92 +++++++++++++++++++++++++++++++++----------- modules/commands/os_mode.cpp | 4 +- 2 files changed, 71 insertions(+), 25 deletions(-) (limited to 'modules/commands') diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 766b2d9e9..2d1cdf9aa 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -395,6 +395,13 @@ class CommandCSSetPeace : public Command } }; +inline static Anope::string BotModes() +{ + return Config->GetModule("botserv")->Get("botmodes", + Config->GetModule("chanserv")->Get("botmodes", "o") + ); +} + class CommandCSSetPersist : public Command { public: @@ -439,15 +446,25 @@ class CommandCSSetPersist : public Command Channel *c = Channel::FindOrCreate(ci->name, created); if (ci->bi) { - ChannelStatus status(Config->GetModule("botserv")->Get("botmodes")); + ChannelStatus status(BotModes()); ci->bi->Join(c, &status); } } + /* Set the perm mode */ + if (cm) + { + if (ci->c && !ci->c->HasMode("PERM")) + ci->c->SetMode(NULL, cm); + /* Add it to the channels mlock */ + ModeLocks *ml = ci->Require("modelocks"); + if (ml) + ml->SetMLock(cm, true); + } /* No botserv bot, no channel mode, give them ChanServ. * Yes, this works fine with no BotServ. */ - if (!ci->bi && !cm) + else if (!ci->bi) { BotInfo *ChanServ = Config->GetClient("ChanServ"); if (!ChanServ) @@ -459,21 +476,10 @@ class CommandCSSetPersist : public Command ChanServ->Assign(NULL, ci); if (!ci->c->FindUser(ChanServ)) { - ChannelStatus status(Config->GetModule("botserv")->Get("botmodes")); + ChannelStatus status(BotModes()); ChanServ->Join(ci->c, &status); } } - - /* Set the perm mode */ - if (cm) - { - if (ci->c && !ci->c->HasMode("PERM")) - ci->c->SetMode(NULL, cm); - /* Add it to the channels mlock */ - ModeLocks *ml = ci->Require("modelocks"); - if (ml) - ml->SetMLock(cm, true); - } } Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable persist"; @@ -485,6 +491,9 @@ class CommandCSSetPersist : public Command { ci->Shrink("PERSIST"); + BotInfo *ChanServ = Config->GetClient("ChanServ"), + *BotServ = Config->GetClient("BotServ"); + /* Unset perm mode */ if (cm) { @@ -495,19 +504,17 @@ class CommandCSSetPersist : public Command if (ml) ml->RemoveMLock(cm, true); } - /* No channel mode, no BotServ, but using ChanServ as the botserv bot * which was assigned when persist was set on */ - BotInfo *ChanServ = Config->GetClient("ChanServ"), - *BotServ = Config->GetClient("BotServ"); - if (!cm && !BotServ && ci->bi) + else if (!cm && !BotServ && ci->bi) { if (!ChanServ) { source.Reply(_("ChanServ is required to enable persist on this network.")); return; } + /* Unassign bot */ ChanServ->UnAssign(NULL, ci); } @@ -980,7 +987,7 @@ class CommandCSSetNoexpire : public Command class CSSet : public Module { - SerializableExtensibleItem persist, noautoop, peace, securefounder, + SerializableExtensibleItem noautoop, peace, securefounder, restricted, secure, secureops, signkick, signkick_level, noexpire; struct KeepModes : SerializableExtensibleItem @@ -1028,6 +1035,40 @@ class CSSet : public Module } } keep_modes; + struct Persist : SerializableExtensibleItem + { + Persist(Module *m, const Anope::string &n) : SerializableExtensibleItem(m, n) { } + + void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override + { + SerializableExtensibleItem::ExtensibleUnserialize(e, s, data); + + if (s->GetSerializableType()->GetName() != "ChannelInfo" || !this->HasExt(e)) + return; + + ChannelInfo *ci = anope_dynamic_static_cast(s); + if (ci->c) + return; + + bool created; + Channel *c = Channel::FindOrCreate(ci->name, created, ci->time_registered); + if (!ci->bi) + { + BotInfo *ChanServ = Config->GetClient("ChanServ"); + if (ChanServ) + ChanServ->Assign(NULL, ci); + } + if (!ci->bi) + return; + + if (!c->FindUser(ci->bi)) + { + ChannelStatus status(BotModes()); + ci->bi->Join(c, &status); + } + } + } persist; + CommandCSSet commandcsset; CommandCSSetAutoOp commandcssetautoop; CommandCSSetBanType commandcssetbantype; @@ -1046,11 +1087,11 @@ class CSSet : public Module public: CSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - persist(this, "PERSIST"), noautoop(this, "NOAUTOOP"), peace(this, "PEACE"), + noautoop(this, "NOAUTOOP"), peace(this, "PEACE"), securefounder(this, "SECUREFOUNDER"), restricted(this, "RESTRICTED"), secure(this, "CS_SECURE"), secureops(this, "SECUREOPS"), signkick(this, "SIGNKICK"), signkick_level(this, "SIGNKICK_LEVEL"), noexpire(this, "CS_NO_EXPIRE"), - keep_modes(this, "CS_KEEP_MODES"), + keep_modes(this, "CS_KEEP_MODES"), persist(this, "PERSIST"), commandcsset(this), commandcssetautoop(this), commandcssetbantype(this), commandcssetdescription(this), commandcssetfounder(this), commandcssetkeepmodes(this), @@ -1075,6 +1116,11 @@ class CSSet : public Module } } + void OnChannelSync(Channel *c) anope_override + { + OnChannelCreate(c); + } + EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override { if (!c->ci || !restricted.HasExt(c->ci) || c->MatchesList(u, "EXCEPT")) @@ -1101,7 +1147,7 @@ class CSSet : public Module if (mode->name == "PERM") persist.Set(c->ci, true); - if (mode->type != MODE_STATUS) + if (mode->type != MODE_STATUS && !c->syncing && Me->IsSynced()) c->ci->last_modes = c->GetModes(); } @@ -1122,7 +1168,7 @@ class CSSet : public Module } } - if (c->ci && mode->type != MODE_STATUS) + if (c->ci && mode->type != MODE_STATUS && !c->syncing && Me->IsSynced()) c->ci->last_modes = c->GetModes(); return EVENT_CONTINUE; diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 7057ead72..13f3f44d7 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -48,8 +48,8 @@ class CommandOSMode : public Command if (uc->user->HasMode("OPER")) continue; - for (size_t i = 0; i < uc->status.Modes().length(); ++i) - c->RemoveMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i]), uc->user->GetUID(), false); + for (size_t i = uc->status.Modes().length(); i > 0; --i) + c->RemoveMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false); } source.Reply(_("All modes cleared on %s."), c->name.c_str()); -- cgit