]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_quietban.cpp
DOH
[user/henk/code/inspircd.git] / src / modules / m_quietban.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 q: - quiet 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(1,2,0,0,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 (target_type == TYPE_CHANNEL)
40                 {
41                         if (((Channel *)dest)->IsExtBanned(user, 'q'))
42                         {
43                                 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Cannot send to " + ((Channel *)dest)->name + ", as you are muted");
44                                 return 1;
45                         }
46                 }
47                 
48                 return 0;
49         }
50
51         virtual int OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
52         {
53                 if (target_type == TYPE_CHANNEL)
54                 {
55                         if (((Channel *)dest)->IsExtBanned(user, 'q'))
56                         {
57                                 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Cannot send to " + ((Channel *)dest)->name + ", as you are muted");
58                                 return 1;
59                         }
60                 }
61
62                 return 0;
63         }
64
65         virtual void On005Numeric(std::string &output)
66         {
67                 if (output.find(" EXTBAN=:") == std::string::npos)
68                         output.append(" EXTBAN=:q");
69                 else
70                         output.insert(output.find(" EXTBAN=:") + 8, "q");
71         }
72 };
73
74
75 MODULE_INIT(ModuleQuietBan)
76