]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
Extra debug
[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 ModeHandler
19 {
20  public:
21         NoInvite(InspIRCd* Instance) : ModeHandler(Instance, 'V', 0, 0, false, MODETYPE_CHANNEL, false) { }
22
23         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
24         {
25                 if (adding)
26                 {
27                         if (!channel->IsModeSet('V'))
28                         {
29                                 channel->SetMode('V',true);
30                                 return MODEACTION_ALLOW;
31                         }
32                 }
33                 else
34                 {
35                         if (channel->IsModeSet('V'))
36                         {
37                                 channel->SetMode('V',false);
38                                 return MODEACTION_ALLOW;
39                         }
40                 }
41
42                 return MODEACTION_DENY;
43         }
44 };
45
46 class ModuleNoInvite : public Module
47 {
48         NoInvite *ni;
49  public:
50
51         ModuleNoInvite(InspIRCd* Me) : Module(Me)
52         {
53                 ni = new NoInvite(ServerInstance);
54                 if (!ServerInstance->Modes->AddMode(ni))
55                         throw ModuleException("Could not add new modes!");
56                 Implementation eventlist[] = { I_OnUserPreInvite };
57                 ServerInstance->Modules->Attach(eventlist, this, 1);
58         }
59
60
61         virtual int OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
62         {
63                 if (channel->IsModeSet('V'))
64                 {
65                         user->WriteNumeric(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 ~ModuleNoInvite()
72         {
73                 ServerInstance->Modes->DelMode(ni);
74                 delete ni;
75         }
76         
77         virtual Version GetVersion()
78         {
79                 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
80         }
81 };
82
83 MODULE_INIT(ModuleNoInvite)