]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonotice.cpp
Added preliminary m_sqllog.cpp
[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 void On005Numeric(std::string &output)
58         {
59                 std::stringstream line(output);
60                 std::string temp1, temp2;
61                 while (!line.eof())
62                 {
63                         line >> temp1;
64                         if (temp1.substr(0,10) == "CHANMODES=")
65                         {
66                                 // append the chanmode to the end
67                                 temp1 = temp1.substr(10,temp1.length());
68                                 temp1 = "CHANMODES=" + temp1 + "T";
69                         }
70                         temp2 = temp2 + temp1 + " ";
71                 }
72                 if (temp2.length())
73                         output = temp2.substr(0,temp2.length()-1);
74         }
75
76         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
77         {
78                 // check if this is our mode character...
79                 if ((modechar == 'T') && (type == MT_CHANNEL))
80                 {
81                         return 1;
82                 }
83                 else
84                 {
85                         return 0;
86                 }
87         }
88         
89         virtual ~ModuleNoNotice()
90         {
91                 delete Srv;
92         }
93         
94         virtual Version GetVersion()
95         {
96                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
97         }
98 };
99
100
101 class ModuleNoNoticeFactory : public ModuleFactory
102 {
103  public:
104         ModuleNoNoticeFactory()
105         {
106         }
107         
108         ~ModuleNoNoticeFactory()
109         {
110         }
111         
112         virtual Module * CreateModule()
113         {
114                 return new ModuleNoNotice;
115         }
116         
117 };
118
119
120 extern "C" void * init_module( void )
121 {
122         return new ModuleNoNoticeFactory;
123 }
124