]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_noinvite.cpp
Initial commit of m_satopic, provides /satopic. Needs testing on a multi-server network.
[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, I_On005Numeric };
35                 ServerInstance->Modules->Attach(eventlist, this, 2);
36         }
37
38         virtual void On005Numeric(std::string &output)
39         {
40                 ServerInstance->AddExtBanChar('V');
41         }
42
43         virtual int OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
44         {
45                 if (IS_LOCAL(user))
46                 {
47                         if (CHANOPS_EXEMPT(ServerInstance, 'c') && channel->GetStatus(user) == STATUS_OP)
48                         {
49                                 return 0;
50                         }
51
52                         if (channel->IsModeSet('V') || channel->IsExtBanned(user, 'V'))
53                         {
54                                 user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't invite %s to channel (+V set)",user->nick.c_str(), channel->name.c_str(), dest->nick.c_str());
55                                 return 1;
56                         }
57                 }
58
59                 return 0;
60         }
61
62         virtual ~ModuleNoInvite()
63         {
64                 ServerInstance->Modes->DelMode(ni);
65                 delete ni;
66         }
67
68         virtual Version GetVersion()
69         {
70                 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
71         }
72 };
73
74 MODULE_INIT(ModuleNoInvite)