]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / modules / m_noinvite.cpp
1 /*   +------------------------------------+
2  *   | Inspire Internet Relay Chat Daemon |
3  *   +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 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 +V */
26
27 class NoInvite : public ModeHandler
28 {
29  public:
30         NoInvite() : ModeHandler('V', 0, 0, false, MODETYPE_CHANNEL, false) { }
31
32         ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
33         {
34                 if (adding)
35                 {
36                         if (!channel->IsModeSet('V'))
37                         {
38                                 channel->SetMode('V',true);
39                                 return MODEACTION_ALLOW;
40                         }
41                 }
42                 else
43                 {
44                         if (channel->IsModeSet('V'))
45                         {
46                                 channel->SetMode('V',false);
47                                 return MODEACTION_ALLOW;
48                         }
49                 }
50
51                 return MODEACTION_DENY;
52         }
53 };
54
55 class ModuleNoInvite : public Module
56 {
57         Server *Srv;
58         NoInvite *ni;
59         
60         public:
61  
62                 ModuleNoInvite(Server* Me) : Module::Module(Me)
63                 {
64                         Srv = Me;
65                         ni = new NoInvite();
66                         Srv->AddMode(ni, 'V');
67                 }
68
69                 void Implements(char* List)
70                 {
71                         List[I_On005Numeric] = List[I_OnUserPreInvite] = 1;
72                 }
73
74                 virtual void On005Numeric(std::string &output)
75                 {
76                         InsertMode(output,"V",4);
77                 }
78
79
80                 virtual int OnUserPreInvite(userrec* user,userrec* dest,chanrec* channel)
81                 {
82                         if (channel->IsModeSet('V'))
83                         {
84                                 WriteServ(user->fd,"492 %s %s :Can't invite %s to channel (+V set)",user->nick, channel->name, dest->nick);
85                                 return 1;
86                         }
87                         return 0;
88                 }
89
90                 virtual ~ModuleNoInvite()
91                 {
92                         DELETE(ni);
93                 }
94         
95                 virtual Version GetVersion()
96                 {
97                         return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
98                 }
99 };
100
101
102 class ModuleNoInviteFactory : public ModuleFactory
103 {
104         public:
105                 ModuleNoInviteFactory()
106                 {
107                 }
108         
109                 ~ModuleNoInviteFactory()
110                 {
111                 }
112         
113                 virtual Module * CreateModule(Server* Me)
114                 {
115                         return new ModuleNoInvite(Me);
116                 }
117         
118 };
119
120
121 extern "C" void * init_module( void )
122 {
123         return new ModuleNoInviteFactory;
124 }
125