]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonotice.cpp
Added +N via m_nonicks, restored some stuff from a firewall fuckup
[user/henk/code/inspircd.git] / src / modules / m_nonotice.cpp
1 #include <stdio.h>
2
3 #include "users.h"
4 #include "channels.h"
5 #include "modules.h"
6
7 /* $ModDesc: Provides support for unreal-style channel mode +T */
8
9 class ModuleNoNotice : public Module
10 {
11         Server *Srv;
12  public:
13  
14         ModuleNoNotice()
15         {
16                 Srv = new Server;
17                 Srv->AddExtendedMode('T',MT_CHANNEL,false,0,0);
18         }
19         
20         virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text)
21         {
22                 if (target_type == TYPE_CHANNEL)
23                 {
24                         chanrec* c = (chanrec*)dest;
25                         if (c->IsCustomModeSet('T'))
26                         {
27                                 if ((Srv->ChanMode(user,c) == "@") || (Srv->ChanMode(user,c) == "%"))
28                                 {
29                                         // ops and halfops can still /NOTICE the channel
30                                         return 0;
31                                 }
32                                 else
33                                 {
34                                         WriteServ(user->fd,"404 %s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name);
35                                         return 1;
36                                 }
37                         }
38                 }
39                 return 0;
40         }
41
42         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
43         {
44                 // check if this is our mode character...
45                 if ((modechar == 'T') && (type == MT_CHANNEL))
46                 {
47                         return 1;
48                 }
49                 else
50                 {
51                         return 0;
52                 }
53         }
54         
55         virtual ~ModuleNoNotice()
56         {
57                 delete Srv;
58         }
59         
60         virtual Version GetVersion()
61         {
62                 return Version(1,0,0,0);
63         }
64 };
65
66
67 class ModuleNoNoticeFactory : public ModuleFactory
68 {
69  public:
70         ModuleNoNoticeFactory()
71         {
72         }
73         
74         ~ModuleNoNoticeFactory()
75         {
76         }
77         
78         virtual Module * CreateModule()
79         {
80                 return new ModuleNoNotice;
81         }
82         
83 };
84
85
86 extern "C" void * init_module( void )
87 {
88         return new ModuleNoNoticeFactory;
89 }
90