]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_muteban.cpp
Remove InspIRCd* parameters and fields
[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()        {
23                 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
24                 ServerInstance->Modules->Attach(eventlist, this, 3);
25         }
26
27         virtual ~ModuleQuietBan()
28         {
29         }
30
31         virtual Version GetVersion()
32         {
33                 return Version("Implements extban +b m: - mute bans",VF_COMMON|VF_VENDOR,API_VERSION);
34         }
35
36         virtual ModResult OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
37         {
38                 if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL)
39                         return MOD_RES_PASSTHRU;
40
41                 Channel* chan = static_cast<Channel*>(dest);
42                 if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE)
43                 {
44                         user->WriteNumeric(404, "%s %s :Cannot send to channel (you're muted)", user->nick.c_str(), chan->name.c_str());
45                         return MOD_RES_DENY;
46                 }
47
48                 return MOD_RES_PASSTHRU;
49         }
50
51         virtual ModResult OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
52         {
53                 return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
54         }
55
56         virtual void On005Numeric(std::string &output)
57         {
58                 ServerInstance->AddExtBanChar('m');
59         }
60 };
61
62
63 MODULE_INIT(ModuleQuietBan)
64