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