2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
5 * Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "modules/ctctags.h"
24 class ModuleCommonChans
25 : public CTCTags::EventListener
29 SimpleUserModeHandler mode;
31 ModResult HandleMessage(User* user, const MessageTarget& target)
33 if (target.type != MessageTarget::TYPE_USER)
34 return MOD_RES_PASSTHRU;
36 User* targuser = target.Get<User>();
37 if (!targuser->IsModeSet(mode) || user->SharesChannelWith(targuser))
38 return MOD_RES_PASSTHRU;
40 if (user->HasPrivPermission("users/ignore-commonchans") || user->server->IsULine())
41 return MOD_RES_PASSTHRU;
43 user->WriteNumeric(ERR_CANTSENDTOUSER, targuser->nick, "You are not permitted to send private messages to this user (+c is set)");
49 : CTCTags::EventListener(this)
50 , mode(this, "deaf_commonchan", 'c')
54 Version GetVersion() CXX11_OVERRIDE
56 return Version("Provides user mode +c, requires users to share a common channel with you to private message you", VF_VENDOR);
59 ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
61 return HandleMessage(user, target);
64 ModResult OnUserPreTagMessage(User* user, const MessageTarget& target, CTCTags::TagMessageDetails& details) CXX11_OVERRIDE
66 return HandleMessage(user, target);
70 MODULE_INIT(ModuleCommonChans)