summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-04-15 14:44:41 +0100
committerSadie Powell <sadie@witchery.services>2025-04-15 15:00:25 +0100
commit5c2fc1ceddd808df93e1aa477e5ddd7cc268f4a7 (patch)
treee61d15bf3b1e44a191a8c652c7c6700e189da79e /modules
parentd891f2bcbd1152a3845ea092e8233cd13e5624f8 (diff)
Allow clearing other list modes using ClearBans.
Diffstat (limited to 'modules')
-rw-r--r--modules/botserv/botserv.cpp4
-rw-r--r--modules/chanserv/cs_unban.cpp28
-rw-r--r--modules/protocol/inspircd.cpp17
-rw-r--r--modules/protocol/unrealircd.cpp10
4 files changed, 38 insertions, 21 deletions
diff --git a/modules/botserv/botserv.cpp b/modules/botserv/botserv.cpp
index 6478161bf..cd9d7f7ae 100644
--- a/modules/botserv/botserv.cpp
+++ b/modules/botserv/botserv.cpp
@@ -57,10 +57,10 @@ public:
BotInfo *bi = user->server == Me ? dynamic_cast<BotInfo *>(user) : NULL;
if (bi && Config->GetModule(this).Get<bool>("smartjoin"))
{
- if (IRCD->CanClearBans)
+ if (IRCD->CanClearModes.count("BAN"))
{
// We can ask the IRCd to clear bans.
- IRCD->SendClearBans(bi, c, bi);
+ IRCD->SendClearModes(bi, c, bi, "BAN");
}
else
{
diff --git a/modules/chanserv/cs_unban.cpp b/modules/chanserv/cs_unban.cpp
index 09dcee602..d87388bc2 100644
--- a/modules/chanserv/cs_unban.cpp
+++ b/modules/chanserv/cs_unban.cpp
@@ -44,16 +44,18 @@ public:
if (!ci->c || !(source.AccessFor(ci).HasPriv("UNBAN") || source.AccessFor(ci).HasPriv("UNBANME")))
continue;
- if (IRCD->CanClearBans)
+ for (const auto *mode : modes)
{
- IRCD->SendClearBans(ci->WhoSends(), ci->c, source.GetUser());
- count++;
- continue;
- }
+ if (IRCD->CanClearModes.count(mode->name))
+ {
+ IRCD->SendClearModes(ci->WhoSends(), ci->c, source.GetUser(), mode->name);
+ count++;
+ continue;
+ }
- for (const auto *mode : modes)
if (ci->c->Unban(source.GetUser(), mode->name, true))
++count;
+ }
}
Log(LOG_COMMAND, source, this, NULL) << "on all channels";
@@ -96,13 +98,15 @@ public:
bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;
-
- if (IRCD->CanClearBans)
- IRCD->SendClearBans(ci->WhoSends(), ci->c, source.GetUser());
- else
+ for (const auto *mode : modes)
{
- for (const auto *mode : modes)
- ci->c->Unban(u2, mode->name, source.GetUser() == u2);
+ if (IRCD->CanClearModes.count(mode->name))
+ {
+ IRCD->SendClearModes(ci->WhoSends(), ci->c, source.GetUser(), mode->name);
+ continue;
+ }
+
+ ci->c->Unban(u2, mode->name, source.GetUser() == u2);
}
if (u2 == source.GetUser())
diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp
index 1b0189d7d..46ee5158c 100644
--- a/modules/protocol/inspircd.cpp
+++ b/modules/protocol/inspircd.cpp
@@ -268,9 +268,13 @@ public:
IRCDProto::SendContextPrivmsg(bi, target, context, msg);
}
- void SendClearBans(const MessageSource &user, Channel *c, User* u) override
+ void SendClearModes(const MessageSource &user, Channel *c, User* u, const Anope::string &mode) override
{
- Uplink::Send(user, "SVSCMODE", u->GetUID(), c->name, 'b');
+ auto *cm = ModeManager::FindChannelModeByName(mode);
+ if (!cm || !cm->mchar)
+ return;
+
+ Uplink::Send(user, "SVSCMODE", u->GetUID(), c->name, cm->mchar);
}
void SendQuit(User *u, const Anope::string &buf, const Anope::string &operbuf) override
@@ -1194,7 +1198,7 @@ struct IRCDMessageCapab final
throw ProtocolException("Protocol mismatch, no or invalid protocol version given in CAPAB START.");
Servers::Capab.clear();
- IRCD->CanClearBans = false;
+ IRCD->CanClearModes.clear();
IRCD->CanSQLineChannel = false;
IRCD->CanSVSHold = false;
IRCD->CanTagMessage = false;
@@ -1522,7 +1526,6 @@ struct IRCDMessageCapab final
else if (modname.equals_cs("services"))
{
- IRCD->CanClearBans = true;
IRCD->CanSVSHold = true;
Servers::Capab.insert("SERVICES");
Servers::Capab.insert("TOPICLOCK");
@@ -1630,6 +1633,12 @@ struct IRCDMessageCapab final
if (!Servers::Capab.count("SERVICES"))
throw ProtocolException("The services module is not loaded. This is required by Anope.");
+
+ for (auto *cm : ModeManager::GetChannelModes())
+ {
+ if (cm->type == MODE_LIST && cm->mchar)
+ IRCD->CanClearModes.insert(cm->name);
+ }
}
if (!ModeManager::FindUserModeByName("PRIV"))
diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp
index 7e37e1f27..4a2b881a0 100644
--- a/modules/protocol/unrealircd.cpp
+++ b/modules/protocol/unrealircd.cpp
@@ -59,7 +59,7 @@ public:
CanSQLineChannel = true;
CanSZLine = true;
CanSVSHold = true;
- CanClearBans = true;
+ CanClearModes.insert("BAN");
CanCertFP = true;
CanTagMessage = true;
RequiresID = true;
@@ -456,9 +456,13 @@ private:
return true;
}
- void SendClearBans(const MessageSource &user, Channel *c, User* u) override
+ void SendClearModes(const MessageSource &user, Channel *c, User* u, const Anope::string &mode) override
{
- Uplink::Send(user, "SVS2MODE", c->name, "-b", u->GetUID());
+ auto *cm = ModeManager::FindChannelModeByName(mode);
+ if (!cm || !cm->mchar)
+ return;
+
+ Uplink::Send(user, "SVS2MODE", c->name, Anope::printf("-%c", cm->mchar), u->GetUID());
}
bool IsTagValid(const Anope::string &tname, const Anope::string &tvalue) override