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