mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Allow normalising extbans to a specific format.
Also, fix canonicalisation of acting extban values.
This commit is contained in:
parent
57b3a40afa
commit
27c0ae9433
@ -637,6 +637,15 @@
|
||||
# in the /LIST response. Defaults to yes.
|
||||
modesinlist="no"
|
||||
|
||||
# extbanformat: The method to use for normalising extbans. Can be set
|
||||
# to one of:
|
||||
# - any Do not perform any extban normalisation.
|
||||
# - name Normalise extbans to use their name.
|
||||
# - letter Normalise extbans to use their letter. This is useful for
|
||||
# if you need to keep compatibility with v3.
|
||||
# Defaults to "any" if not set.
|
||||
extbanformat="name"
|
||||
|
||||
# exemptchanops: Allows users with with a status mode to be exempt
|
||||
# from various channel restrictions. Possible restrictions are:
|
||||
# - anticaps Channel mode +B - blocks messages with too many capital
|
||||
|
@ -28,6 +28,18 @@ namespace ExtBan
|
||||
class Manager;
|
||||
class ManagerRef;
|
||||
|
||||
enum class Format
|
||||
{
|
||||
/** Do not perform any normalisation of extbans. */
|
||||
ANY,
|
||||
|
||||
/** Normalise extbans to use their name (e.g. mute). */
|
||||
NAME,
|
||||
|
||||
/** Normalise extbans to use their letter (e.g. m). */
|
||||
LETTER,
|
||||
};
|
||||
|
||||
/** All possible types of extban. */
|
||||
enum class Type
|
||||
{
|
||||
@ -84,6 +96,9 @@ public:
|
||||
*/
|
||||
virtual void DelExtBan(Base* extban) = 0;
|
||||
|
||||
/** Retrieves the method used for normalising extbans. */
|
||||
virtual Format GetFormat() const = 0;
|
||||
|
||||
/** Retrieves a mapping of extban letters to their associated object. */
|
||||
virtual const LetterMap& GetLetterMap() const = 0;
|
||||
|
||||
|
@ -178,6 +178,12 @@ public:
|
||||
exempts[restriction] = prefix;
|
||||
}
|
||||
|
||||
ExtBan::Format newformat = optionstag->getEnum("extbanformat", ExtBan::Format::ANY, {
|
||||
{ "any", ExtBan::Format::ANY },
|
||||
{ "name", ExtBan::Format::NAME },
|
||||
{ "letter", ExtBan::Format::LETTER },
|
||||
});
|
||||
|
||||
auto securitytag = ServerInstance->Config->ConfValue("security");
|
||||
Invite::AnnounceState newannouncestate = securitytag->getEnum("announceinvites", Invite::ANNOUNCE_DYNAMIC, {
|
||||
{ "all", Invite::ANNOUNCE_ALL },
|
||||
@ -192,6 +198,7 @@ public:
|
||||
banmode.DoRehash();
|
||||
|
||||
exemptions.swap(exempts);
|
||||
extbanmgr.format = newformat;
|
||||
invapi.announceinvites = newannouncestate;
|
||||
joinhook.modefromuser = optionstag->getBool("cyclehostsfromuser");
|
||||
|
||||
|
@ -163,6 +163,8 @@ private:
|
||||
NameMap byname;
|
||||
|
||||
public:
|
||||
ExtBan::Format format;
|
||||
|
||||
ExtBanManager(Module* Creator, ModeChannelBan& bm)
|
||||
: ExtBan::Manager(Creator)
|
||||
, banmode(bm)
|
||||
@ -173,6 +175,7 @@ public:
|
||||
void AddExtBan(ExtBan::Base* extban) override;
|
||||
bool Canonicalize(std::string& text) const override;
|
||||
void DelExtBan(ExtBan::Base* extban) override;
|
||||
ExtBan::Format GetFormat() const override { return format; }
|
||||
const LetterMap& GetLetterMap() const override { return byletter; }
|
||||
const NameMap& GetNameMap() const override { return byname; }
|
||||
ModResult GetStatus(ExtBan::Acting* extban, User* user, Channel* channel) const override;
|
||||
|
@ -42,7 +42,27 @@ bool ExtBanManager::Canonicalize(std::string& text) const
|
||||
if (!extban)
|
||||
return false; // Looks like an extban but it isn't.
|
||||
|
||||
// Canonicalize the extban.
|
||||
text.assign(inverted ? "!" : "");
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case ExtBan::Format::NAME:
|
||||
text.append(extban->GetName());
|
||||
break;
|
||||
|
||||
case ExtBan::Format::LETTER:
|
||||
text.append(1, extban->GetLetter());
|
||||
break;
|
||||
|
||||
default:
|
||||
text.append(xbname);
|
||||
break;
|
||||
}
|
||||
|
||||
extban->Canonicalize(xbvalue);
|
||||
text.append(":").append(xbvalue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user