]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nokicks.cpp
Moved a ton of functions into helperfuncs.h to speed up recompiles
[user/henk/code/inspircd.git] / src / modules / m_nokicks.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include <stdio.h>
18 #include "users.h"
19 #include "channels.h"
20 #include "modules.h"
21 #include "helperfuncs.h"
22
23 /* $ModDesc: Provides support for unreal-style channel mode +Q */
24
25 class ModuleNoKicks : public Module
26 {
27         Server *Srv;
28         
29  public:
30  
31         ModuleNoKicks()
32         {
33                 Srv = new Server;
34                 Srv->AddExtendedMode('Q',MT_CHANNEL,false,0,0);
35         }
36
37         virtual void On005Numeric(std::string &output)
38         {
39                 std::stringstream line(output);
40                 std::string temp1, temp2;
41                 while (!line.eof())
42                 {
43                         line >> temp1;
44                         if (temp1.substr(0,10) == "CHANMODES=")
45                         {
46                                 // append the chanmode to the end
47                                 temp1 = temp1.substr(10,temp1.length());
48                                 temp1 = "CHANMODES=" + temp1 + "Q";
49                         }
50                         temp2 = temp2 + temp1 + " ";
51                 }
52                 if (temp2.length())
53                         output = temp2.substr(0,temp2.length()-1);
54         }
55
56         virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
57         {
58                 if (access_type == AC_KICK)
59                 {
60                         if (channel->IsCustomModeSet('Q'))
61                         {
62                                 if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!strcmp(source->server,"")))
63                                 {
64                                         // ulines can still kick with +Q in place
65                                         return ACR_ALLOW;
66                                 }
67                                 else
68                                 {
69                                         // nobody else can (not even opers with override, and founders)
70                                         WriteServ(source->fd,"484 %s %s :Can't kick user %s from channel (+Q set)",source->nick, channel->name,dest->nick);
71                                         return ACR_DENY;
72                                 }
73                         }
74                 }
75                 return ACR_DEFAULT;
76         }
77         
78         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
79         {
80                 // check if this is our mode character...
81                 if ((modechar == 'Q') && (type == MT_CHANNEL))
82                 {
83                         return 1;
84                 }
85                 else
86                 {
87                         return 0;
88                 }
89         }
90
91         virtual ~ModuleNoKicks()
92         {
93                 delete Srv;
94         }
95         
96         virtual Version GetVersion()
97         {
98                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
99         }
100 };
101
102
103 class ModuleNoKicksFactory : public ModuleFactory
104 {
105  public:
106         ModuleNoKicksFactory()
107         {
108         }
109         
110         ~ModuleNoKicksFactory()
111         {
112         }
113         
114         virtual Module * CreateModule()
115         {
116                 return new ModuleNoKicks;
117         }
118         
119 };
120
121
122 extern "C" void * init_module( void )
123 {
124         return new ModuleNoKicksFactory;
125 }
126