]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
30f313a92d27ca5070bddaab95a7dedd211a1291
[user/henk/code/inspircd.git] / src / modules / m_noinvite.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 +V */
23
24 class ModuleNoInvite : public Module
25 {
26         Server *Srv;
27         
28  public:
29  
30         ModuleNoInvite()
31         {
32                 Srv = new Server;
33                 Srv->AddExtendedMode('V',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 + "V";
48                         }
49                         temp2 = temp2 + temp1 + " ";
50                 }
51                 if (temp2.length())
52                         output = temp2.substr(0,temp2.length()-1);
53         }
54
55
56         virtual int OnUserPreInvite(userrec* user,userrec* dest,chanrec* channel)
57         {
58                 if (channel->IsCustomModeSet('V'))
59                 {
60                         WriteServ(user->fd,"492 %s %s :Can't invite %s to channel (+V set)",user->nick, channel->name, dest->nick);
61                         return 1;
62                 }
63                 return 0;
64         }
65         
66         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
67         {
68                 // check if this is our mode character...
69                 if ((modechar == 'V') && (type == MT_CHANNEL))
70                 {
71                         return 1;
72                 }
73                 else
74                 {
75                         return 0;
76                 }
77         }
78
79         virtual ~ModuleNoInvite()
80         {
81                 delete Srv;
82         }
83         
84         virtual Version GetVersion()
85         {
86                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
87         }
88 };
89
90
91 class ModuleNoInviteFactory : public ModuleFactory
92 {
93  public:
94         ModuleNoInviteFactory()
95         {
96         }
97         
98         ~ModuleNoInviteFactory()
99         {
100         }
101         
102         virtual Module * CreateModule()
103         {
104                 return new ModuleNoInvite;
105         }
106         
107 };
108
109
110 extern "C" void * init_module( void )
111 {
112         return new ModuleNoInviteFactory;
113 }
114