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