2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2005 Craig Edwards <craigedwards@brainbox.cc>
8 * This file is part of InspIRCd. InspIRCd is free software: you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation, version 2.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "modules/ctctags.h"
25 class ModuleRestrictMsg
27 , public CTCTags::EventListener
30 ModResult HandleMessage(User* user, const MessageTarget& target)
32 if ((target.type == MessageTarget::TYPE_USER) && (IS_LOCAL(user)))
34 User* u = target.Get<User>();
36 // message allowed if:
37 // (1) the sender is opered
38 // (2) the recipient is opered
39 // (3) the recipient is on a ulined server
40 // anything else, blocked.
41 if (u->IsOper() || user->IsOper() || u->server->IsULine())
43 return MOD_RES_PASSTHRU;
45 user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "You are not permitted to send private messages to this user");
49 // however, we must allow channel messages...
50 return MOD_RES_PASSTHRU;
55 : CTCTags::EventListener(this)
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);
69 Version GetVersion() CXX11_OVERRIDE
71 return Version("Forbids users from messaging each other, but users may still message opers and opers may message other opers", VF_VENDOR);
75 MODULE_INIT(ModuleRestrictMsg)