mirror of
https://github.com/anope/anope.git
synced 2026-06-12 19:14:47 +02:00
Allow clearing other list modes using ClearBans.
This commit is contained in:
+3
-3
@@ -107,8 +107,8 @@ public:
|
||||
/* If this IRCd has unique ids, whether the IDs and nicknames are ambiguous */
|
||||
bool AmbiguousID = false;
|
||||
|
||||
/** Can we ask the server to unban a user? */
|
||||
bool CanClearBans = false;
|
||||
/** Can we ask the server to remove list modes matching a user? */
|
||||
std::set<Anope::string> CanClearModes;
|
||||
|
||||
/** Can we send tag messages? */
|
||||
bool CanTagMessage = false;
|
||||
@@ -304,7 +304,7 @@ public:
|
||||
*/
|
||||
virtual void SendOper(User *u);
|
||||
|
||||
virtual void SendClearBans(const MessageSource &user, Channel *c, User* u) { }
|
||||
virtual void SendClearModes(const MessageSource &user, Channel *c, User* u, const Anope::string &mode) { }
|
||||
|
||||
virtual bool IsNickValid(const Anope::string &);
|
||||
virtual bool IsChannelValid(const Anope::string &);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -44,16 +44,18 @@ public:
|
||||
if (!ci->c || !(source.AccessFor(ci).HasPriv("UNBAN") || source.AccessFor(ci).HasPriv("UNBANME")))
|
||||
continue;
|
||||
|
||||
if (IRCD->CanClearBans)
|
||||
{
|
||||
IRCD->SendClearBans(ci->WhoSends(), ci->c, source.GetUser());
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const auto *mode : modes)
|
||||
{
|
||||
if (IRCD->CanClearModes.count(mode->name))
|
||||
{
|
||||
IRCD->SendClearModes(ci->WhoSends(), ci->c, source.GetUser(), mode->name);
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
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())
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user