]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
dz is determined to crash your ircd :P
[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 "inspircd.h"
15
16 /* $ModDesc: Provides support for unreal-style channel mode +Q */
17
18 class NoKicks : public ModeHandler
19 {
20  public:
21         NoKicks(InspIRCd* Instance) : ModeHandler(Instance, 'Q', 0, 0, false, MODETYPE_CHANNEL, false) { }
22
23         ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
24         {
25                 if (adding)
26                 {
27                         if (!channel->IsModeSet('Q'))
28                         {
29                                 channel->SetMode('Q',true);
30                                 return MODEACTION_ALLOW;
31                         }
32                 }
33                 else
34                 {
35                         if (channel->IsModeSet('Q'))
36                         {
37                                 channel->SetMode('Q',false);
38                                 return MODEACTION_ALLOW;
39                         }
40                 }
41
42                 return MODEACTION_DENY;
43         }
44 };
45
46 class ModuleNoKicks : public Module
47 {
48         
49         NoKicks* nk;
50         
51  public:
52  
53         ModuleNoKicks(InspIRCd* Me)
54                 : Module(Me)
55         {
56                 
57                 nk = new NoKicks(ServerInstance);
58                 if (!ServerInstance->AddMode(nk, 'Q'))
59                         throw ModuleException("Could not add new modes!");
60         }
61
62         void Implements(char* List)
63         {
64                 List[I_OnAccessCheck] = 1;
65         }
66
67         virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
68         {
69                 if (access_type == AC_KICK)
70                 {
71                         if (channel->IsModeSet('Q'))
72                         {
73                                 if ((ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server))
74                                 {
75                                         // ulines can still kick with +Q in place
76                                         return ACR_ALLOW;
77                                 }
78                                 else
79                                 {
80                                         // nobody else can (not even opers with override, and founders)
81                                         source->WriteServ("484 %s %s :Can't kick user %s from channel (+Q set)",source->nick, channel->name,dest->nick);
82                                         return ACR_DENY;
83                                 }
84                         }
85                 }
86                 return ACR_DEFAULT;
87         }
88
89         virtual ~ModuleNoKicks()
90         {
91                 ServerInstance->Modes->DelMode(nk);
92                 DELETE(nk);
93         }
94         
95         virtual Version GetVersion()
96         {
97                 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
98         }
99 };
100
101
102 MODULE_INIT(ModuleNoKicks)