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