summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/cs_set.cpp92
-rw-r--r--modules/commands/os_mode.cpp4
-rw-r--r--modules/protocol/bahamut.cpp3
-rw-r--r--modules/protocol/inspircd12.cpp3
-rw-r--r--modules/protocol/ngircd.cpp3
-rw-r--r--modules/protocol/plexus.cpp9
-rw-r--r--modules/protocol/ratbox.cpp6
-rw-r--r--modules/protocol/unreal.cpp3
-rw-r--r--modules/pseudoclients/chanserv.cpp2
9 files changed, 97 insertions, 28 deletions
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<Anope::string>("botmodes",
+ Config->GetModule("chanserv")->Get<Anope::string>("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<const Anope::string>("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>("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<const Anope::string>("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>("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<bool>("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<bool> persist, noautoop, peace, securefounder,
+ SerializableExtensibleItem<bool> noautoop, peace, securefounder,
restricted, secure, secureops, signkick, signkick_level, noexpire;
struct KeepModes : SerializableExtensibleItem<bool>
@@ -1028,6 +1035,40 @@ class CSSet : public Module
}
} keep_modes;
+ struct Persist : SerializableExtensibleItem<bool>
+ {
+ Persist(Module *m, const Anope::string &n) : SerializableExtensibleItem<bool>(m, n) { }
+
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ {
+ SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data);
+
+ if (s->GetSerializableType()->GetName() != "ChannelInfo" || !this->HasExt(e))
+ return;
+
+ ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(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());
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index c9ad9c5fd..633b6cab3 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -178,6 +178,9 @@ class BahamutIRCdProto : public IRCDProto
BotInfo *setter = BotInfo::Find(user->nick);
for (size_t i = 0; i < cs.Modes().length(); ++i)
c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+
+ if (uc != NULL)
+ uc->status = cs;
}
}
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 40cb465a1..023325c02 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -261,6 +261,9 @@ class InspIRCd12Proto : public IRCDProto
BotInfo *setter = BotInfo::Find(user->nick);
for (size_t i = 0; i < cs.Modes().length(); ++i)
c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+
+ if (uc != NULL)
+ uc->status = cs;
}
}
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index d32d87a73..639688e70 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -98,6 +98,9 @@ class ngIRCdProto : public IRCDProto
BotInfo *setter = BotInfo::Find(user->nick);
for (size_t i = 0; i < cs.Modes().length(); ++i)
c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+
+ if (uc != NULL)
+ uc->status = cs;
}
}
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 37516d928..57a2f4669 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -36,7 +36,6 @@ class PlexusProto : public IRCDProto
void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); }
void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); }
void SendSQLine(User *u, const XLine *x) anope_override { hybrid->SendSQLine(u, x); }
void SendSQLineDel(const XLine *x) anope_override { hybrid->SendSQLineDel(x); }
void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); }
@@ -48,6 +47,11 @@ class PlexusProto : public IRCDProto
void SendSVSHold(const Anope::string &nick, time_t t) anope_override { hybrid->SendSVSHold(nick, t); }
void SendSVSHoldDel(const Anope::string &nick) anope_override { hybrid->SendSVSHoldDel(nick); }
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
+ {
+ UplinkSocket::Message(source) << "OPERWALL :" << buf;
+ }
+
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
{
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << user->GetUID();
@@ -65,6 +69,9 @@ class PlexusProto : public IRCDProto
BotInfo *setter = BotInfo::Find(user->nick);
for (size_t i = 0; i < cs.Modes().length(); ++i)
c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+
+ if (uc != NULL)
+ uc->status = cs;
}
}
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index dc6cef168..7a3cc00f6 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -30,7 +30,6 @@ class RatboxProto : public IRCDProto
void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); }
void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); }
void SendSQLine(User *u, const XLine *x) anope_override { hybrid->SendSQLine(u, x); }
void SendSGLine(User *u, const XLine *x) anope_override { hybrid->SendSGLine(u, x); }
void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); }
@@ -44,6 +43,11 @@ class RatboxProto : public IRCDProto
void SendTopic(const MessageSource &source, Channel *c) anope_override { hybrid->SendTopic(source, c); }
bool IsIdentValid(const Anope::string &ident) anope_override { return hybrid->IsIdentValid(ident); }
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
+ {
+ UplinkSocket::Message(source) << "OPERWALL :" << buf;
+ }
+
void SendConnect() anope_override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID();
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 8e86ad729..17dca20a6 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -171,6 +171,9 @@ class UnrealIRCdProto : public IRCDProto
BotInfo *setter = BotInfo::Find(user->nick);
for (size_t i = 0; i < cs.Modes().length(); ++i)
c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+
+ if (uc != NULL)
+ uc->status = cs;
}
}
diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp
index efb0a78ab..41f62525c 100644
--- a/modules/pseudoclients/chanserv.cpp
+++ b/modules/pseudoclients/chanserv.cpp
@@ -288,7 +288,7 @@ class ChanServCore : public Module, public ChanServService
void OnChannelSync(Channel *c) anope_override
{
- bool perm = c->HasMode("PERM") || (c->ci && persist && persist->Get(c->ci));
+ bool perm = c->HasMode("PERM") || (c->ci && persist && persist->HasExt(c->ci));
if (!perm && !c->botchannel && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me)))
{
this->Hold(c);