]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
Use Utils->ServerUser instead of ServerInstance->FakeClient in m_spanningtree
[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)
31         {
32                 nk = new NoKicks(ServerInstance);
33                 if (!ServerInstance->Modes->AddMode(nk))
34                         throw ModuleException("Could not add new modes!");
35                 Implementation eventlist[] = { I_OnAccessCheck, I_On005Numeric };
36                 ServerInstance->Modules->Attach(eventlist, this, 2);
37         }
38
39         virtual void On005Numeric(std::string &output)
40         {
41                 ServerInstance->AddExtBanChar('Q');
42         }
43
44         virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type)
45         {
46                 if (access_type == AC_KICK)
47                 {
48                         if (channel->IsModeSet('Q') || channel->GetExtBanStatus(source, 'Q') < 0)
49                         {
50                                 if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server))
51                                 {
52                                         // ulines can still kick with +Q in place
53                                         return ACR_ALLOW;
54                                 }
55                                 else
56                                 {
57                                         // nobody else can (not even opers with override, and founders)
58                                         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());
59                                         return ACR_DENY;
60                                 }
61                         }
62                 }
63                 return ACR_DEFAULT;
64         }
65
66         virtual ~ModuleNoKicks()
67         {
68                 ServerInstance->Modes->DelMode(nk);
69                 delete nk;
70         }
71
72         virtual Version GetVersion()
73         {
74                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
75         }
76 };
77
78
79 MODULE_INIT(ModuleNoKicks)