diff options
| author | 2022-03-23 14:33:57 +0000 | |
|---|---|---|
| committer | 2022-03-23 14:33:57 +0000 | |
| commit | 770b8ec19239140dbc690308c3855284b3da346e (patch) | |
| tree | 4d1fecd717aaac150b2497beecb67072aba42882 /src/modules/m_commonchans.cpp | |
| parent | Fix our WHO oplevels being incompatible with the WHOX spec. (diff) | |
Add support for blocking invites to the commonchans module.
Diffstat (limited to 'src/modules/m_commonchans.cpp')
| -rw-r--r-- | src/modules/m_commonchans.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
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<User>(); - 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); |
