]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
b060d87f83f94538dc58c4607e9260ba8108d83b
[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, Module* Creator) : SimpleChannelModeHandler(Instance, Creator, 'Q') { }
22 };
23
24 class ModuleNoKicks : public Module
25 {
26         NoKicks nk;
27
28  public:
29         ModuleNoKicks(InspIRCd* Me)
30                 : Module(Me), nk(Me, this)
31         {
32                 if (!ServerInstance->Modes->AddMode(&nk))
33                         throw ModuleException("Could not add new modes!");
34                 Implementation eventlist[] = { I_OnUserPreKick, I_On005Numeric };
35                 ServerInstance->Modules->Attach(eventlist, this, 2);
36         }
37
38         void On005Numeric(std::string &output)
39         {
40                 ServerInstance->AddExtBanChar('Q');
41         }
42
43         ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason)
44         {
45                 if (!memb->chan->GetExtBanStatus(source, 'Q').check(!memb->chan->IsModeSet('Q')))
46                 {
47                         if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server))
48                         {
49                                 // ulines can still kick with +Q in place
50                                 return MOD_RES_PASSTHRU;
51                         }
52                         else
53                         {
54                                 // nobody else can (not even opers with override, and founders)
55                                 source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), memb->chan->name.c_str(), memb->user->nick.c_str());
56                                 return MOD_RES_DENY;
57                         }
58                 }
59                 return MOD_RES_PASSTHRU;
60         }
61
62         ~ModuleNoKicks()
63         {
64                 ServerInstance->Modes->DelMode(&nk);
65         }
66
67         Version GetVersion()
68         {
69                 return Version("Provides support for unreal-style channel mode +Q", VF_COMMON | VF_VENDOR, API_VERSION);
70         }
71 };
72
73
74 MODULE_INIT(ModuleNoKicks)