]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_muteban.cpp
m_dccallow Validate tokens before use
[user/henk/code/inspircd.git] / src / modules / m_muteban.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6  *
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.
10  *
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
14  * details.
15  *
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/>.
18  */
19
20
21 #include "inspircd.h"
22
23 /* $ModDesc: Implements extban +b m: - mute bans */
24
25 class ModuleQuietBan : public Module
26 {
27  private:
28  public:
29         void init()
30         {
31                 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
32                 ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
33         }
34
35         virtual ~ModuleQuietBan()
36         {
37         }
38
39         virtual Version GetVersion()
40         {
41                 return Version("Implements extban +b m: - mute bans",VF_OPTCOMMON|VF_VENDOR);
42         }
43
44         virtual ModResult OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
45         {
46                 if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL)
47                         return MOD_RES_PASSTHRU;
48
49                 Channel* chan = static_cast<Channel*>(dest);
50                 if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE)
51                 {
52                         user->WriteNumeric(404, "%s %s :Cannot send to channel (you're muted)", user->nick.c_str(), chan->name.c_str());
53                         return MOD_RES_DENY;
54                 }
55
56                 return MOD_RES_PASSTHRU;
57         }
58
59         virtual ModResult OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
60         {
61                 return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
62         }
63
64         virtual void On005Numeric(std::string &output)
65         {
66                 ServerInstance->AddExtBanChar('m');
67         }
68 };
69
70
71 MODULE_INIT(ModuleQuietBan)
72