]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonotice.cpp
Holy christ that was a LOT OF SPACES. TABS, USE THEM, LOVE THEM, APPRECIATE THEM...
[user/henk/code/inspircd.git] / src / modules / m_nonotice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 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 using namespace std;
18
19 #include <stdio.h>
20 #include "users.h"
21 #include "channels.h"
22 #include "modules.h"
23 #include "helperfuncs.h"
24
25 /* $ModDesc: Provides support for unreal-style channel mode +T */
26
27 class ModuleNoNotice : public Module
28 {
29         Server *Srv;
30  public:
31  
32         ModuleNoNotice(Server* Me)
33                 : Module::Module(Me)
34         {
35                 Srv = Me;
36                 Srv->AddExtendedMode('T',MT_CHANNEL,false,0,0);
37         }
38
39         void Implements(char* List)
40         {
41                 List[I_OnUserPreNotice] = List[I_On005Numeric] = List[I_OnExtendedMode] = 1;
42         }
43         
44         virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
45         {
46                 if (target_type == TYPE_CHANNEL)
47                 {
48                         chanrec* c = (chanrec*)dest;
49                         if (c->IsModeSet('T'))
50                         {
51                                 if ((Srv->IsUlined(user->server)) || (Srv->ChanMode(user,c) == "@") || (Srv->ChanMode(user,c) == "%"))
52                                 {
53                                         // ops and halfops can still /NOTICE the channel
54                                         return 0;
55                                 }
56                                 else
57                                 {
58                                         WriteServ(user->fd,"404 %s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name);
59                                         return 1;
60                                 }
61                         }
62                 }
63                 return 0;
64         }
65
66         virtual void On005Numeric(std::string &output)
67         {
68                 InsertMode(output,"T",4);
69         }
70
71         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
72         {
73                 // check if this is our mode character...
74                 if ((modechar == 'T') && (type == MT_CHANNEL))
75                 {
76                         return 1;
77                 }
78                 else
79                 {
80                         return 0;
81                 }
82         }
83         
84         virtual ~ModuleNoNotice()
85         {
86         }
87         
88         virtual Version GetVersion()
89         {
90                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
91         }
92 };
93
94
95 class ModuleNoNoticeFactory : public ModuleFactory
96 {
97  public:
98         ModuleNoNoticeFactory()
99         {
100         }
101         
102         ~ModuleNoNoticeFactory()
103         {
104         }
105         
106         virtual Module * CreateModule(Server* Me)
107         {
108                 return new ModuleNoNotice(Me);
109         }
110         
111 };
112
113
114 extern "C" void * init_module( void )
115 {
116         return new ModuleNoNoticeFactory;
117 }
118