]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
Stylistic stuff: The evil infidelic spaces must DIE.
[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()
34                 {
35                         Srv = new Server;
36                         Srv->AddExtendedMode('V',MT_CHANNEL,false,0,0);
37                 }
38
39                 virtual void On005Numeric(std::string &output)
40                 {
41                         std::stringstream line(output);
42                         std::string temp1, temp2;
43
44                         while (!line.eof())
45                         {
46                                 line >> temp1;
47                                 if (temp1.substr(0,10) == "CHANMODES=")
48                                 {
49                                         // append the chanmode to the end
50                                         temp1 = temp1.substr(10,temp1.length());
51                                         temp1 = "CHANMODES=" + temp1 + "V";
52                                 }
53                                 temp2 = temp2 + temp1 + " ";
54                         }
55                         if (temp2.length())
56                                 output = temp2.substr(0,temp2.length()-1);
57                 }
58
59
60                 virtual int OnUserPreInvite(userrec* user,userrec* dest,chanrec* channel)
61                 {
62                         if (channel->IsCustomModeSet('V'))
63                         {
64                                 WriteServ(user->fd,"492 %s %s :Can't invite %s to channel (+V set)",user->nick, channel->name, dest->nick);
65                                 return 1;
66                         }
67                         return 0;
68                 }
69         
70                 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
71                 {
72                         // check if this is our mode character...
73                         if ((modechar == 'V') && (type == MT_CHANNEL))
74                         {
75                                 return 1;
76                         }
77                         else
78                         {
79                                 return 0;
80                         }
81                 }
82
83                 virtual ~ModuleNoInvite()
84                 {
85                         delete Srv;
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()
107                 {
108                         return new ModuleNoInvite;
109                 }
110         
111 };
112
113
114 extern "C" void * init_module( void )
115 {
116         return new ModuleNoInviteFactory;
117 }
118