]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
Forward port r9825: Fix bug found by the atheme migration testing: +V should never...
[user/henk/code/inspircd.git] / src / modules / m_noinvite.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Provides support for unreal-style channel mode +V */
17
18 class NoInvite : public SimpleChannelModeHandler
19 {
20  public:
21         NoInvite(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'V') { }
22 };
23
24 class ModuleNoInvite : public Module
25 {
26         NoInvite *ni;
27  public:
28
29         ModuleNoInvite(InspIRCd* Me) : Module(Me)
30         {
31                 ni = new NoInvite(ServerInstance);
32                 if (!ServerInstance->Modes->AddMode(ni))
33                         throw ModuleException("Could not add new modes!");
34                 Implementation eventlist[] = { I_OnUserPreInvite };
35                 ServerInstance->Modules->Attach(eventlist, this, 1);
36         }
37
38
39         virtual int OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
40         {
41                 if (IS_LOCAL(user))
42                 {
43                         if (channel->IsModeSet('V'))
44                         {
45                                 user->WriteNumeric(492, "%s %s :Can't invite %s to channel (+V set)",user->nick.c_str(), channel->name.c_str(), dest->nick.c_str());
46                                 return 1;
47                         }
48                         return 0;
49                 }
50         }
51
52         virtual ~ModuleNoInvite()
53         {
54                 ServerInstance->Modes->DelMode(ni);
55                 delete ni;
56         }
57         
58         virtual Version GetVersion()
59         {
60                 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
61         }
62 };
63
64 MODULE_INIT(ModuleNoInvite)