]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
a72a95db82b6af7927ca2e1756b051f4014a0239
[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 ModuleNoInvite : public Module
28 {
29         Server *Srv;
30         
31         public:
32  
33                 ModuleNoInvite(Server* Me)
34                         : Module::Module(Me)
35                 {
36                         Srv = Me;
37                         Srv->AddExtendedMode('V',MT_CHANNEL,false,0,0);
38                 }
39
40                 void Implements(char* List)
41                 {
42                         List[I_On005Numeric] = List[I_OnUserPreInvite] = List[I_OnExtendedMode] = 1;
43                 }
44
45                 virtual void On005Numeric(std::string &output)
46                 {
47                         std::stringstream line(output);
48                         std::string temp1, temp2;
49
50                         while (!line.eof())
51                         {
52                                 line >> temp1;
53                                 if (temp1.substr(0,10) == "CHANMODES=")
54                                 {
55                                         // append the chanmode to the end
56                                         temp1 = temp1.substr(10,temp1.length());
57                                         temp1 = "CHANMODES=" + temp1 + "V";
58                                 }
59                                 temp2 = temp2 + temp1 + " ";
60                         }
61                         if (temp2.length())
62                                 output = temp2.substr(0,temp2.length()-1);
63                 }
64
65
66                 virtual int OnUserPreInvite(userrec* user,userrec* dest,chanrec* channel)
67                 {
68                         if (channel->IsCustomModeSet('V'))
69                         {
70                                 WriteServ(user->fd,"492 %s %s :Can't invite %s to channel (+V set)",user->nick, channel->name, dest->nick);
71                                 return 1;
72                         }
73                         return 0;
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 == 'V') && (type == MT_CHANNEL))
80                         {
81                                 return 1;
82                         }
83                         else
84                         {
85                                 return 0;
86                         }
87                 }
88
89                 virtual ~ModuleNoInvite()
90                 {
91                 }
92         
93                 virtual Version GetVersion()
94                 {
95                         return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
96                 }
97 };
98
99
100 class ModuleNoInviteFactory : public ModuleFactory
101 {
102         public:
103                 ModuleNoInviteFactory()
104                 {
105                 }
106         
107                 ~ModuleNoInviteFactory()
108                 {
109                 }
110         
111                 virtual Module * CreateModule(Server* Me)
112                 {
113                         return new ModuleNoInvite(Me);
114                 }
115         
116 };
117
118
119 extern "C" void * init_module( void )
120 {
121         return new ModuleNoInviteFactory;
122 }
123