]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
ce43e576fc1a585efaef5af028fb31d63d4636e6
[user/henk/code/inspircd.git] / src / modules / m_nokicks.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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         NoKicks nk;
27
28  public:
29         ModuleNoKicks(InspIRCd* Me)
30                 : Module(Me), nk(Me)
31         {
32                 if (!ServerInstance->Modes->AddMode(&nk))
33                         throw ModuleException("Could not add new modes!");
34                 Implementation eventlist[] = { I_OnAccessCheck, I_On005Numeric };
35                 ServerInstance->Modules->Attach(eventlist, this, 2);
36         }
37
38         virtual void On005Numeric(std::string &output)
39         {
40                 ServerInstance->AddExtBanChar('Q');
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') || channel->GetExtBanStatus(source, 'Q') < 0)
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(ERR_CHANOPRIVSNEEDED, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), channel->name.c_str(), 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         }
69
70         virtual Version GetVersion()
71         {
72                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
73         }
74 };
75
76
77 MODULE_INIT(ModuleNoKicks)