Change delaymsg to use exemptchanops and have an oper priv (#1959).

This commit is contained in:
iwalkalone 2022-02-13 15:54:47 +01:00 committed by GitHub
parent 2b2a3a31d7
commit 5027a63e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -682,6 +682,8 @@
# (requires the blockcolor module).
# - censor Channel mode +G - censors messages based on the network
# configuration (requires the censor module).
# - delaymsg Channel mode +d - blocks sending messages until specified
# seconds have passed since user join
# - filter Channel mode +g - blocks messages containing the given
# glob mask (requires the chanfilter module).
# - flood Channel mode +f - kicks (and bans) on text flood of a

View File

@ -27,6 +27,7 @@
# - users/mass-message: allows opers with this priv to PRIVMSG and NOTICE to a server mask (e.g. NOTICE $*).
# - users/samode-usermodes: allows opers with this priv to change the user modes of any other user using /SAMODE.
# PERMISSIONS:
# - channels/ignore-delaymsg: allows opers with this priv to be immune to delaymsg restriction on a +d channel.
# - channels/ignore-noctcp: allows opers with this priv to send a CTCP to a +C channel.
# - channels/ignore-nonicks: allows opers with this priv to change their nick when on a +N channel.
# - channels/ignore-repeat: allows opers with this priv to be immune to repeat punishment on a +E channel.

View File

@ -22,6 +22,7 @@
#include "inspircd.h"
#include "modules/ctctags.h"
#include "modules/exemption.h"
class DelayMsgMode : public ParamMode<DelayMsgMode, LocalIntExt>
{
@ -56,12 +57,14 @@ class ModuleDelayMsg
private:
DelayMsgMode djm;
bool allownotice;
CheckExemption::EventProvider exemptionprov;
ModResult HandleMessage(User* user, const MessageTarget& target, bool notice);
public:
ModuleDelayMsg()
: CTCTags::EventListener(this)
, djm(this)
, exemptionprov(this)
{
}
@ -139,12 +142,16 @@ ModResult ModuleDelayMsg::HandleMessage(User* user, const MessageTarget& target,
if ((ts + len) > ServerInstance->Time())
{
if (channel->GetPrefixValue(user) < VOICE_VALUE)
{
const std::string message = InspIRCd::Format("You cannot send messages to this channel until you have been a member for %d seconds.", len);
user->WriteNumeric(Numerics::CannotSendTo(channel, message));
return MOD_RES_DENY;
}
ModResult res = CheckExemption::Call(exemptionprov, user, channel, "delaymsg");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
if (user->HasPrivPermission("channels/ignore-delaymsg"))
return MOD_RES_PASSTHRU;
const std::string message = InspIRCd::Format("You cannot send messages to this channel until you have been a member for %d seconds.", len);
user->WriteNumeric(Numerics::CannotSendTo(channel, message));
return MOD_RES_DENY;
}
else
{