]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
Remove an extern, partly because it's unused, partly because it then gets shadowed...
[user/henk/code/inspircd.git] / src / modules / m_nokicks.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 +Q */
26
27 class ModuleNoKicks : public Module
28 {
29         Server *Srv;
30         
31  public:
32  
33         ModuleNoKicks(Server* Me)
34                 : Module::Module(Me)
35         {
36                 Srv = Me;
37                 Srv->AddExtendedMode('Q',MT_CHANNEL,false,0,0);
38         }
39
40         void Implements(char* List)
41         {
42                 List[I_On005Numeric] = List[I_OnAccessCheck] = List[I_OnExtendedMode] = 1;
43         }
44
45         virtual void On005Numeric(std::string &output)
46         {
47                 InsertMode(output,"Q",4);
48         }
49
50         virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
51         {
52                 if (access_type == AC_KICK)
53                 {
54                         if (channel->IsModeSet('Q'))
55                         {
56                                 if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!strcmp(source->server,"")))
57                                 {
58                                         // ulines can still kick with +Q in place
59                                         return ACR_ALLOW;
60                                 }
61                                 else
62                                 {
63                                         // nobody else can (not even opers with override, and founders)
64                                         WriteServ(source->fd,"484 %s %s :Can't kick user %s from channel (+Q set)",source->nick, channel->name,dest->nick);
65                                         return ACR_DENY;
66                                 }
67                         }
68                 }
69                 return ACR_DEFAULT;
70         }
71         
72         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
73         {
74                 // check if this is our mode character...
75                 if ((modechar == 'Q') && (type == MT_CHANNEL))
76                 {
77                         return 1;
78                 }
79                 else
80                 {
81                         return 0;
82                 }
83         }
84
85         virtual ~ModuleNoKicks()
86         {
87         }
88         
89         virtual Version GetVersion()
90         {
91                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
92         }
93 };
94
95
96 class ModuleNoKicksFactory : public ModuleFactory
97 {
98  public:
99         ModuleNoKicksFactory()
100         {
101         }
102         
103         ~ModuleNoKicksFactory()
104         {
105         }
106         
107         virtual Module * CreateModule(Server* Me)
108         {
109                 return new ModuleNoKicks(Me);
110         }
111         
112 };
113
114
115 extern "C" void * init_module( void )
116 {
117         return new ModuleNoKicksFactory;
118 }
119