]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
Converted more stuff to 'Implements' system
[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 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                 virtual void On005Numeric(std::string &output)
41                 {
42                         std::stringstream line(output);
43                         std::string temp1, temp2;
44
45                         while (!line.eof())
46                         {
47                                 line >> temp1;
48                                 if (temp1.substr(0,10) == "CHANMODES=")
49                                 {
50                                         // append the chanmode to the end
51                                         temp1 = temp1.substr(10,temp1.length());
52                                         temp1 = "CHANMODES=" + temp1 + "V";
53                                 }
54                                 temp2 = temp2 + temp1 + " ";
55                         }
56                         if (temp2.length())
57                                 output = temp2.substr(0,temp2.length()-1);
58                 }
59
60
61                 virtual int OnUserPreInvite(userrec* user,userrec* dest,chanrec* channel)
62                 {
63                         if (channel->IsCustomModeSet('V'))
64                         {
65                                 WriteServ(user->fd,"492 %s %s :Can't invite %s to channel (+V set)",user->nick, channel->name, dest->nick);
66                                 return 1;
67                         }
68                         return 0;
69                 }
70         
71                 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
72                 {
73                         // check if this is our mode character...
74                         if ((modechar == 'V') && (type == MT_CHANNEL))
75                         {
76                                 return 1;
77                         }
78                         else
79                         {
80                                 return 0;
81                         }
82                 }
83
84                 virtual ~ModuleNoInvite()
85                 {
86                 }
87         
88                 virtual Version GetVersion()
89                 {
90                         return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
91                 }
92 };
93
94
95 class ModuleNoInviteFactory : public ModuleFactory
96 {
97         public:
98                 ModuleNoInviteFactory()
99                 {
100                 }
101         
102                 ~ModuleNoInviteFactory()
103                 {
104                 }
105         
106                 virtual Module * CreateModule(Server* Me)
107                 {
108                         return new ModuleNoInvite(Me);
109                 }
110         
111 };
112
113
114 extern "C" void * init_module( void )
115 {
116         return new ModuleNoInviteFactory;
117 }
118