From c87703e2a7805fd7566ba39b9dfdf6e836166e11 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 22 Mar 2022 15:27:39 +0000 Subject: Rename to . --- docs/conf/modules.conf.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 11e9ae5d4..310a25510 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -693,8 +693,8 @@ # banmessage - The message to give users when Z-lining them for connecting # too much. # -# duration - The time period to ban users who connect to much for. Defaults -# to 10 minutes. +# banduration - The time period to ban users who connect to much for. Defaults +# to 10 minutes. # # ipv4cidr - The IPv4 CIDR mask (1-32) to treat connecting users as coming # from the same host. Defaults to 32. @@ -710,7 +710,7 @@ # # # # threshold - The number of connections which are allowed before a user -# is connectbnaned. Defaults to 10. +# is connectbanned. Defaults to 10. # # banmessage - The message to give users when Z-lining them for connecting # too much. -- cgit v1.3.1-10-gc9f91 From 770b8ec19239140dbc690308c3855284b3da346e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 23 Mar 2022 14:33:57 +0000 Subject: Add support for blocking invites to the commonchans module. --- docs/conf/modules.conf.example | 4 ++++ src/modules/m_commonchans.cpp | 32 ++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 77efff761..0d9f76d2e 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -632,6 +632,10 @@ # that users must share a common channel with you to PRIVMSG or NOTICE # you. # +# +# You can also require a common channel for inviting to another channel +# by uncommenting this: +# #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Auto join on connect module: Allows you to force users to join one diff --git a/src/modules/m_commonchans.cpp b/src/modules/m_commonchans.cpp index 66c56bafc..9b97bd66a 100644 --- a/src/modules/m_commonchans.cpp +++ b/src/modules/m_commonchans.cpp @@ -30,6 +30,18 @@ class ModuleCommonChans { private: SimpleUserModeHandler mode; + bool invite; + + bool IsExempt(User* source, User* target) + { + if (!target->IsModeSet(mode) || source->SharesChannelWith(target)) + return true; // Target doesn't have mode set or shares a common channel. + + if (source->HasPrivPermission("users/ignore-commonchans") || source->server->IsULine()) + return true; // Source is an oper or a uline. + + return false; + } ModResult HandleMessage(User* user, const MessageTarget& target) { @@ -37,10 +49,7 @@ class ModuleCommonChans return MOD_RES_PASSTHRU; User* targetuser = target.Get(); - if (!targetuser->IsModeSet(mode) || user->SharesChannelWith(targetuser)) - return MOD_RES_PASSTHRU; - - if (user->HasPrivPermission("users/ignore-commonchans") || user->server->IsULine()) + if (IsExempt(user, targetuser)) return MOD_RES_PASSTHRU; user->WriteNumeric(Numerics::CannotSendTo(targetuser, "messages", &mode)); @@ -59,6 +68,21 @@ class ModuleCommonChans return Version("Adds user mode c (deaf_commonchan) which requires users to have a common channel before they can privately message each other.", VF_VENDOR); } + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE + { + ConfigTag* tag = ServerInstance->Config->ConfValue("commonchans"); + invite = tag->getBool("invite"); + } + + ModResult OnUserPreInvite(User* source, User* dest, Channel* channel, time_t timeout) CXX11_OVERRIDE + { + if (!invite || IsExempt(source, dest)) + return MOD_RES_PASSTHRU; + + source->WriteNumeric(Numerics::CannotSendTo(dest, "invites", &mode)); + return MOD_RES_DENY; + } + ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE { return HandleMessage(user, target); -- cgit v1.3.1-10-gc9f91