Allow customising who can receive the joinflood close notification.

Closes #1747.
This commit is contained in:
Sadie Powell 2023-05-07 12:14:43 +01:00
parent 9f70663094
commit 15fcf2c761
2 changed files with 21 additions and 10 deletions

View File

@ -1429,20 +1429,27 @@
# Closes the channel for N seconds if X users join in Y seconds. # Closes the channel for N seconds if X users join in Y seconds.
#<module name="joinflood"> #<module name="joinflood">
# #
# duration: The number of seconds to close a channel for when it is # duration: The number of seconds to close a channel for when it is
# being flooded with joins. # being flooded with joins.
# #
# bootwait: The number of seconds to disengage joinflood for after # bootwait: The number of seconds to disengage joinflood for after
# a server boots. This allows users to reconnect without # a server boots. This allows users to reconnect without
# being throttled by joinflood. # being throttled by joinflood.
# #
# splitwait: The number of seconds to disengage joinflood for after # splitwait: The number of seconds to disengage joinflood for after
# a server splits. This allows users to reconnect without # a server splits. This allows users to reconnect without
# being throttled by joinflood. # being throttled by joinflood.
#
# notifyrank: The lowest prefix rank that should receive notification
# that the channel is closed to new users. This can be set
# to 0 for all users, 10000 for voiced users (+v) and above,
# 30000 for channel operators (+o), or the value specified
# in <customprefix:rank> for any custom prefix rank.
# #
#<joinflood duration="1m" #<joinflood duration="1m"
# bootwait="30s" # bootwait="30s"
# splitwait="30s"> # splitwait="30s"
# notifyrank="0">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Anti auto rejoin: Adds support for prevention of auto-rejoin (+J). # Anti auto rejoin: Adds support for prevention of auto-rejoin (+J).

View File

@ -139,6 +139,7 @@ private:
time_t ignoreuntil = 0; time_t ignoreuntil = 0;
unsigned long bootwait; unsigned long bootwait;
unsigned long splitwait; unsigned long splitwait;
ModeHandler::Rank notifyrank;
public: public:
ModuleJoinFlood() ModuleJoinFlood()
@ -154,6 +155,7 @@ public:
duration = static_cast<unsigned int>(tag->getDuration("duration", 60, 10, 600)); duration = static_cast<unsigned int>(tag->getDuration("duration", 60, 10, 600));
bootwait = tag->getDuration("bootwait", 30); bootwait = tag->getDuration("bootwait", 30);
splitwait = tag->getDuration("splitwait", 30); splitwait = tag->getDuration("splitwait", 30);
notifyrank = tag->getNum<ModeHandler::Rank>("notifyrank", 0);
if (status.initial) if (status.initial)
ignoreuntil = ServerInstance->startup_time + bootwait; ignoreuntil = ServerInstance->startup_time + bootwait;
@ -195,8 +197,10 @@ public:
{ {
f->clear(); f->clear();
f->lock(); f->lock();
PrefixMode* pm = ServerInstance->Modes.FindNearestPrefixMode(notifyrank);
memb->chan->WriteNotice(INSP_FORMAT("This channel has been closed to new users for {} seconds because there have been more than {} joins in {} seconds.", memb->chan->WriteNotice(INSP_FORMAT("This channel has been closed to new users for {} seconds because there have been more than {} joins in {} seconds.",
duration, f->joins, f->secs)); duration, f->joins, f->secs), pm ? pm->GetPrefix() : 0);
} }
} }
} }