2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017, 2019-2020 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
6 * Copyright (C) 2012 Attila Molnar <attilamolnar@hush.com>
7 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 * Copyright (C) 2007 Craig Edwards <brain@inspircd.org>
10 * This file is part of InspIRCd. InspIRCd is free software: you can
11 * redistribute it and/or modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation, version 2.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "modules/ctctags.h"
27 class ModuleCommonChans
28 : public CTCTags::EventListener
32 SimpleUserModeHandler mode;
34 ModResult HandleMessage(User* user, const MessageTarget& target)
36 if (target.type != MessageTarget::TYPE_USER)
37 return MOD_RES_PASSTHRU;
39 User* targuser = target.Get<User>();
40 if (!targuser->IsModeSet(mode) || user->SharesChannelWith(targuser))
41 return MOD_RES_PASSTHRU;
43 if (user->HasPrivPermission("users/ignore-commonchans") || user->server->IsULine())
44 return MOD_RES_PASSTHRU;
46 user->WriteNumeric(Numerics::CannotSendTo(targuser, "messages", &mode));
52 : CTCTags::EventListener(this)
53 , mode(this, "deaf_commonchan", 'c')
57 Version GetVersion() CXX11_OVERRIDE
59 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);
62 ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
64 return HandleMessage(user, target);
67 ModResult OnUserPreTagMessage(User* user, const MessageTarget& target, CTCTags::TagMessageDetails& details) CXX11_OVERRIDE
69 return HandleMessage(user, target);
73 MODULE_INIT(ModuleCommonChans)