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