The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_noinvite.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 
00016 /* $ModDesc: Provides support for unreal-style channel mode +V */
00017 
00018 class NoInvite : public SimpleChannelModeHandler
00019 {
00020  public:
00021         NoInvite(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'V') { }
00022 };
00023 
00024 class ModuleNoInvite : public Module
00025 {
00026         NoInvite *ni;
00027  public:
00028 
00029         ModuleNoInvite(InspIRCd* Me) : Module(Me)
00030         {
00031                 ni = new NoInvite(ServerInstance);
00032                 if (!ServerInstance->Modes->AddMode(ni))
00033                         throw ModuleException("Could not add new modes!");
00034                 Implementation eventlist[] = { I_OnUserPreInvite, I_On005Numeric };
00035                 ServerInstance->Modules->Attach(eventlist, this, 2);
00036         }
00037 
00038         virtual void On005Numeric(std::string &output)
00039         {
00040                 ServerInstance->AddExtBanChar('V');
00041         }
00042 
00043         virtual int OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
00044         {
00045                 if (IS_LOCAL(user))
00046                 {
00047                         if (CHANOPS_EXEMPT(ServerInstance, 'c') && channel->GetStatus(user) == STATUS_OP)
00048                         {
00049                                 return 0;
00050                         }
00051 
00052                         if (channel->IsModeSet('V') || channel->IsExtBanned(user, 'V'))
00053                         {
00054                                 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());
00055                                 return 1;
00056                         }
00057                 }
00058 
00059                 return 0;
00060         }
00061 
00062         virtual ~ModuleNoInvite()
00063         {
00064                 ServerInstance->Modes->DelMode(ni);
00065                 delete ni;
00066         }
00067 
00068         virtual Version GetVersion()
00069         {
00070                 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
00071         }
00072 };
00073 
00074 MODULE_INIT(ModuleNoInvite)