]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
Phew. Fix a bunch of method sigs to stop warnings.
[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 ModeHandler
19 {
20  public:
21         NoKicks(InspIRCd* Instance) : ModeHandler(Instance, 'Q', 0, 0, false, MODETYPE_CHANNEL, false) { }
22
23         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
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->Modes->AddMode(nk))
59                         throw ModuleException("Could not add new modes!");
60                 Implementation eventlist[] = { I_OnAccessCheck };
61                 ServerInstance->Modules->Attach(eventlist, this, 1);
62         }
63
64
65         virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type)
66         {
67                 if (access_type == AC_KICK)
68                 {
69                         if (channel->IsModeSet('Q'))
70                         {
71                                 if ((ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server))
72                                 {
73                                         // ulines can still kick with +Q in place
74                                         return ACR_ALLOW;
75                                 }
76                                 else
77                                 {
78                                         // nobody else can (not even opers with override, and founders)
79                                         source->WriteServ("484 %s %s :Can't kick user %s from channel (+Q set)",source->nick, channel->name,dest->nick);
80                                         return ACR_DENY;
81                                 }
82                         }
83                 }
84                 return ACR_DEFAULT;
85         }
86
87         virtual ~ModuleNoKicks()
88         {
89                 ServerInstance->Modes->DelMode(nk);
90                 delete nk;
91         }
92         
93         virtual Version GetVersion()
94         {
95                 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
96         }
97 };
98
99
100 MODULE_INIT(ModuleNoKicks)