diff options
author | Sadie Powell <sadie@witchery.services> | 2021-06-04 02:12:09 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2021-06-04 02:12:09 +0100 |
commit | e67c2d563295701ac098bf186b7c1847f579f590 (patch) | |
tree | e21869a1c4315acf58693e8af638458a2e77d90c | |
parent | 3728a0bda1cf010520c4fae821fc9c98b2adb083 (diff) |
Add support for per-mode list limits.
-rw-r--r-- | include/protocol.h | 2 | ||||
-rw-r--r-- | modules/commands/cs_ban.cpp | 7 | ||||
-rw-r--r-- | modules/commands/cs_mode.cpp | 4 | ||||
-rw-r--r-- | src/protocol.cpp | 5 |
4 files changed, 14 insertions, 4 deletions
diff --git a/include/protocol.h b/include/protocol.h index 4f4042738..a9fd2d763 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -15,6 +15,7 @@ #include "services.h" #include "anope.h" #include "service.h" +#include "modes.h" /* Encapsultes the IRCd protocol we are speaking. */ class CoreExport IRCDProto : public Service @@ -241,6 +242,7 @@ class CoreExport IRCDProto : public Service * Defaults to Config->ListSize */ virtual unsigned GetMaxListFor(Channel *c); + virtual unsigned GetMaxListFor(Channel *c, ChannelMode *cm); virtual Anope::string NormalizeMask(const Anope::string &mask); }; diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 113873d2c..648651dfa 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -42,10 +42,13 @@ class CommandCSBan : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - const Anope::string &chan = params[0]; Configuration::Block *block = Config->GetCommand(source); const Anope::string &mode = block->Get<Anope::string>("mode", "BAN"); + ChannelMode *cm = ModeManager::FindChannelModeByName(mode); + if (cm == NULL) + return; + const Anope::string &chan = params[0]; ChannelInfo *ci = ChannelInfo::Find(chan); if (ci == NULL) { @@ -59,7 +62,7 @@ class CommandCSBan : public Command source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); return; } - else if (IRCD->GetMaxListFor(c) && c->HasMode(mode) >= IRCD->GetMaxListFor(c)) + else if (IRCD->GetMaxListFor(c, cm) && c->HasMode(mode) >= IRCD->GetMaxListFor(c, cm)) { source.Reply(_("The %s list for %s is full."), mode.lower().c_str(), c->name.c_str()); return; diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index d5129fdc6..0f6378036 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -336,7 +336,7 @@ class CommandCSMode : public Command continue; } - if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c)) + if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c, cm) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c, cm)) { source.Reply(_("List for mode %c is full."), cm->mchar); continue; @@ -660,7 +660,7 @@ class CommandCSMode : public Command if (adding) { - if (IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) < IRCD->GetMaxListFor(ci->c)) + if (IRCD->GetMaxListFor(ci->c, cm) && ci->c->HasMode(cm->name) < IRCD->GetMaxListFor(ci->c, cm)) ci->c->SetMode(NULL, cm, param); } else diff --git a/src/protocol.cpp b/src/protocol.cpp index e4e64842e..5cb11d807 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -438,6 +438,11 @@ unsigned IRCDProto::GetMaxListFor(Channel *c) return c->HasMode("LBAN") ? 0 : Config->GetBlock("networkinfo")->Get<int>("modelistsize"); } +unsigned IRCDProto::GetMaxListFor(Channel *c, ChannelMode *cm) +{ + return GetMaxListFor(c); +} + Anope::string IRCDProto::NormalizeMask(const Anope::string &mask) { if (IsExtbanValid(mask)) |