]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_blockcolor.cpp
added m_noinvite that uses the new OnUserPreInvite method
[user/henk/code/inspircd.git] / src / modules / m_blockcolor.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 +c */
23
24 class ModuleBlockColor : public Module
25 {
26         Server *Srv;
27  public:
28  
29         ModuleBlockColor()
30         {
31                 Srv = new Server;
32                 Srv->AddExtendedMode('c',MT_CHANNEL,false,0,0);
33         }
34         
35         virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text)
36         {
37                 if (target_type == TYPE_CHANNEL)
38                 {
39                         chanrec* c = (chanrec*)dest;
40                         char ctext[MAXBUF];
41                         snprintf(ctext,MAXBUF,"%s",text.c_str());
42                         if (c->IsCustomModeSet('c'))
43                         {
44                                 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
45                                 {
46                                         WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
47                                         return 1;
48                                 }
49                         }
50                 }
51                 return 0;
52         }
53         
54         virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text)
55         {
56                 if (target_type == TYPE_CHANNEL)
57                 {
58                         chanrec* c = (chanrec*)dest;
59                         char ctext[MAXBUF];
60                         snprintf(ctext,MAXBUF,"%s",text.c_str());
61                         if (c->IsCustomModeSet('c'))
62                         {
63                                 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
64                                 {
65                                         WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
66                                         return 1;
67                                 }
68                         }
69                 }
70                 return 0;
71         }
72         
73         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
74         {
75                 // check if this is our mode character...
76                 if ((modechar == 'c') && (type == MT_CHANNEL))
77                 {
78                         return 1;
79                 }
80                 else
81                 {
82                         return 0;
83                 }
84         }
85
86         virtual ~ModuleBlockColor()
87         {
88                 delete Srv;
89         }
90         
91         virtual Version GetVersion()
92         {
93                 return Version(1,0,0,0);
94         }
95 };
96
97
98 class ModuleBlockColorFactory : public ModuleFactory
99 {
100  public:
101         ModuleBlockColorFactory()
102         {
103         }
104         
105         ~ModuleBlockColorFactory()
106         {
107         }
108         
109         virtual Module * CreateModule()
110         {
111                 return new ModuleBlockColor;
112         }
113         
114 };
115
116
117 extern "C" void * init_module( void )
118 {
119         return new ModuleBlockColorFactory;
120 }
121