]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_muteban.cpp
6040252c10909b981e7357914aba10d20ec06505
[user/henk/code/inspircd.git] / src / modules / m_muteban.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Implements extban +b m: - mute bans */
17
18 class ModuleQuietBan : public Module
19 {
20  private:
21  public:
22         ModuleQuietBan(InspIRCd* Me) : Module(Me)
23         {
24                 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
25                 ServerInstance->Modules->Attach(eventlist, this, 3);
26         }
27
28         virtual ~ModuleQuietBan()
29         {
30         }
31
32         virtual Version GetVersion()
33         {
34                 return Version("Implements extban +b m: - mute bans",VF_COMMON|VF_VENDOR,API_VERSION);
35         }
36
37         virtual ModResult OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
38         {
39                 if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL)
40                         return MOD_RES_PASSTHRU;
41
42                 Channel* chan = static_cast<Channel*>(dest);
43                 if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE)
44                 {
45                         user->WriteNumeric(404, "%s %s :Cannot send to channel (you're muted)", user->nick.c_str(), chan->name.c_str());
46                         return MOD_RES_DENY;
47                 }
48
49                 return MOD_RES_PASSTHRU;
50         }
51
52         virtual ModResult OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
53         {
54                 return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
55         }
56
57         virtual void On005Numeric(std::string &output)
58         {
59                 ServerInstance->AddExtBanChar('m');
60         }
61 };
62
63
64 MODULE_INIT(ModuleQuietBan)
65