]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noctcp.cpp
1b1f56397efb908080ed50c508e06e1b936b76a1
[user/henk/code/inspircd.git] / src / modules / m_noctcp.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 +c */
8
9 class ModuleNoCTCP : public Module
10 {
11         Server *Srv;
12         
13  public:
14  
15         ModuleNoCTCP()
16         {
17                 Srv = new Server;
18                 Srv->AddExtendedMode('C',MT_CHANNEL,false,0,0);
19         }
20         
21         virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text)
22         {
23                 if (target_type == TYPE_CHANNEL)
24                 {
25                         chanrec* c = (chanrec*)dest;
26                         if (c->IsCustomModeSet('C'))
27                         {
28                                 if ((text.length()) && (text[0] == '\1'))
29                                 {
30                                         if (strncmp(text.c_str(),"\1ACTION ",8))
31                                         {
32                                                 WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
33                                                 return 1;
34                                         }
35                                 }
36                         }
37                 }
38                 return 0;
39         }
40         
41         virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text)
42         {
43                 if (target_type == TYPE_CHANNEL)
44                 {
45                         chanrec* c = (chanrec*)dest;
46                         if (c->IsCustomModeSet('C'))
47                         {
48                                 if ((text.length()) && (text[0] == '\1'))
49                                 {
50                                         if (strncmp(text.c_str(),"\1ACTION ",8))
51                                         {
52                                                 WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
53                                                 return 1;
54                                         }
55                                 }
56                         }
57                 }
58                 return 0;
59         }
60         
61         virtual ~ModuleNoCTCP()
62         {
63                 delete Srv;
64         }
65         
66         virtual Version GetVersion()
67         {
68                 return Version(1,0,0,0);
69         }
70 };
71
72
73 class ModuleNoCTCPFactory : public ModuleFactory
74 {
75  public:
76         ModuleNoCTCPFactory()
77         {
78         }
79         
80         ~ModuleNoCTCPFactory()
81         {
82         }
83         
84         virtual Module * CreateModule()
85         {
86                 return new ModuleNoCTCP;
87         }
88         
89 };
90
91
92 extern "C" void * init_module( void )
93 {
94         return new ModuleNoCTCPFactory;
95 }
96