]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
Removed a pointless check in ./configure --clean that made it only work with one...
[user/henk/code/inspircd.git] / src / modules / m_nokicks.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include <stdio.h>
15 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18 #include "inspircd.h"
19
20 /* $ModDesc: Provides support for unreal-style channel mode +Q */
21
22
23
24 class NoKicks : public ModeHandler
25 {
26  public:
27         NoKicks(InspIRCd* Instance) : ModeHandler(Instance, 'Q', 0, 0, false, MODETYPE_CHANNEL, false) { }
28
29         ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
30         {
31                 if (adding)
32                 {
33                         if (!channel->IsModeSet('Q'))
34                         {
35                                 channel->SetMode('Q',true);
36                                 return MODEACTION_ALLOW;
37                         }
38                 }
39                 else
40                 {
41                         if (channel->IsModeSet('Q'))
42                         {
43                                 channel->SetMode('Q',false);
44                                 return MODEACTION_ALLOW;
45                         }
46                 }
47
48                 return MODEACTION_DENY;
49         }
50 };
51
52 class ModuleNoKicks : public Module
53 {
54         
55         NoKicks* nk;
56         
57  public:
58  
59         ModuleNoKicks(InspIRCd* Me)
60                 : Module::Module(Me)
61         {
62                 
63                 nk = new NoKicks(ServerInstance);
64                 ServerInstance->AddMode(nk, 'Q');
65         }
66
67         void Implements(char* List)
68         {
69                 List[I_OnAccessCheck] = 1;
70         }
71
72         virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
73         {
74                 if (access_type == AC_KICK)
75                 {
76                         if (channel->IsModeSet('Q'))
77                         {
78                                 if ((ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server))
79                                 {
80                                         // ulines can still kick with +Q in place
81                                         return ACR_ALLOW;
82                                 }
83                                 else
84                                 {
85                                         // nobody else can (not even opers with override, and founders)
86                                         source->WriteServ("484 %s %s :Can't kick user %s from channel (+Q set)",source->nick, channel->name,dest->nick);
87                                         return ACR_DENY;
88                                 }
89                         }
90                 }
91                 return ACR_DEFAULT;
92         }
93
94         virtual ~ModuleNoKicks()
95         {
96                 ServerInstance->Modes->DelMode(nk);
97                 DELETE(nk);
98         }
99         
100         virtual Version GetVersion()
101         {
102                 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
103         }
104 };
105
106
107 class ModuleNoKicksFactory : public ModuleFactory
108 {
109  public:
110         ModuleNoKicksFactory()
111         {
112         }
113         
114         ~ModuleNoKicksFactory()
115         {
116         }
117         
118         virtual Module * CreateModule(InspIRCd* Me)
119         {
120                 return new ModuleNoKicks(Me);
121         }
122         
123 };
124
125
126 extern "C" void * init_module( void )
127 {
128         return new ModuleNoKicksFactory;
129 }
130