]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
These too
[user/henk/code/inspircd.git] / src / modules / m_nokicks.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 SimpleChannelModeHandler
19 {
20  public:
21         NoKicks(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'Q') { }
22 };
23
24 class ModuleNoKicks : public Module
25 {
26         
27         NoKicks* nk;
28         
29  public:
30  
31         ModuleNoKicks(InspIRCd* Me)
32                 : Module(Me)
33         {
34                 
35                 nk = new NoKicks(ServerInstance);
36                 if (!ServerInstance->Modes->AddMode(nk))
37                         throw ModuleException("Could not add new modes!");
38                 Implementation eventlist[] = { I_OnAccessCheck };
39                 ServerInstance->Modules->Attach(eventlist, this, 1);
40         }
41
42
43         virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type)
44         {
45                 if (access_type == AC_KICK)
46                 {
47                         if (channel->IsModeSet('Q'))
48                         {
49                                 if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server))
50                                 {
51                                         // ulines can still kick with +Q in place
52                                         return ACR_ALLOW;
53                                 }
54                                 else
55                                 {
56                                         // nobody else can (not even opers with override, and founders)
57                                         source->WriteNumeric(484, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), channel->name,dest->nick.c_str());
58                                         return ACR_DENY;
59                                 }
60                         }
61                 }
62                 return ACR_DEFAULT;
63         }
64
65         virtual ~ModuleNoKicks()
66         {
67                 ServerInstance->Modes->DelMode(nk);
68                 delete nk;
69         }
70         
71         virtual Version GetVersion()
72         {
73                 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
74         }
75 };
76
77
78 MODULE_INIT(ModuleNoKicks)