]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonotice.cpp
89a619590cf8495c9bc718320f1860c2a1b58a75
[user/henk/code/inspircd.git] / src / modules / m_nonotice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include <stdio.h>
18 #include "users.h"
19 #include "channels.h"
20 #include "modules.h"
21
22 /* $ModDesc: Provides support for unreal-style channel mode +T */
23
24 class ModuleNoNotice : public Module
25 {
26         Server *Srv;
27  public:
28  
29         ModuleNoNotice()
30         {
31                 Srv = new Server;
32                 Srv->AddExtendedMode('T',MT_CHANNEL,false,0,0);
33         }
34         
35         virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
36         {
37                 if (target_type == TYPE_CHANNEL)
38                 {
39                         chanrec* c = (chanrec*)dest;
40                         if (c->IsCustomModeSet('T'))
41                         {
42                                 if ((Srv->ChanMode(user,c) == "@") || (Srv->ChanMode(user,c) == "%"))
43                                 {
44                                         // ops and halfops can still /NOTICE the channel
45                                         return 0;
46                                 }
47                                 else
48                                 {
49                                         WriteServ(user->fd,"404 %s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name);
50                                         return 1;
51                                 }
52                         }
53                 }
54                 return 0;
55         }
56
57         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
58         {
59                 // check if this is our mode character...
60                 if ((modechar == 'T') && (type == MT_CHANNEL))
61                 {
62                         return 1;
63                 }
64                 else
65                 {
66                         return 0;
67                 }
68         }
69         
70         virtual ~ModuleNoNotice()
71         {
72                 delete Srv;
73         }
74         
75         virtual Version GetVersion()
76         {
77                 return Version(1,0,0,0);
78         }
79 };
80
81
82 class ModuleNoNoticeFactory : public ModuleFactory
83 {
84  public:
85         ModuleNoNoticeFactory()
86         {
87         }
88         
89         ~ModuleNoNoticeFactory()
90         {
91         }
92         
93         virtual Module * CreateModule()
94         {
95                 return new ModuleNoNotice;
96         }
97         
98 };
99
100
101 extern "C" void * init_module( void )
102 {
103         return new ModuleNoNoticeFactory;
104 }
105