]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_muteban.cpp
Update copyrights for 2009.
[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://www.inspircd.org/wiki/index.php/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("$Id$",VF_VENDOR,API_VERSION);
35         }
36
37         virtual int OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
38         {
39                 if (!IS_LOCAL(user))
40                         return 0;
41
42                 if (target_type == TYPE_CHANNEL)
43                 {
44                         if (((Channel *)dest)->IsExtBanned(user, 'm'))
45                         {
46                                 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Cannot send to " + ((Channel *)dest)->name + ", as you are muted");
47                                 return 1;
48                         }
49                 }
50
51                 return 0;
52         }
53
54         virtual int OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
55         {
56                 if (!IS_LOCAL(user))
57                         return 0;
58
59                 if (target_type == TYPE_CHANNEL)
60                 {
61                         if (((Channel *)dest)->IsExtBanned(user, 'm'))
62                         {
63                                 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Cannot send to " + ((Channel *)dest)->name + ", as you are muted");
64                                 return 1;
65                         }
66                 }
67
68                 return 0;
69         }
70
71         virtual void On005Numeric(std::string &output)
72         {
73                 ServerInstance->AddExtBanChar('m');
74         }
75 };
76
77
78 MODULE_INIT(ModuleQuietBan)
79