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_nonotice.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 +T */
00017 
00018 class NoNotice : public SimpleChannelModeHandler
00019 {
00020  public:
00021         NoNotice(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'T') { }
00022 };
00023 
00024 class ModuleNoNotice : public Module
00025 {
00026 
00027         NoNotice* nt;
00028  public:
00029 
00030         ModuleNoNotice(InspIRCd* Me)
00031                 : Module(Me)
00032         {
00033 
00034                 nt = new NoNotice(ServerInstance);
00035                 if (!ServerInstance->Modes->AddMode(nt))
00036                         throw ModuleException("Could not add new modes!");
00037                 Implementation eventlist[] = { I_OnUserPreNotice, I_On005Numeric };
00038                 ServerInstance->Modules->Attach(eventlist, this, 2);
00039         }
00040 
00041         virtual void On005Numeric(std::string &output)
00042         {
00043                 ServerInstance->AddExtBanChar('T');
00044         }
00045 
00046         virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
00047         {
00048                 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
00049                 {
00050                         Channel* c = (Channel*)dest;
00051                         if (c->IsModeSet('T') || c->IsExtBanned(user, 'T'))
00052                         {
00053                                 if (ServerInstance->ULine(user->server))
00054                                 {
00055                                         // ulines are exempt.
00056                                         return 0;
00057                                 }
00058                                 else if (CHANOPS_EXEMPT(ServerInstance, 'T') && c->GetStatus(user) == STATUS_OP)
00059                                 {
00060                                         // channel ops are exempt if set in conf.
00061                                         return 0;
00062                                 }
00063                                 else
00064                                 {
00065                                         user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Can't send NOTICE to channel (+T set)",user->nick.c_str(), c->name.c_str());
00066                                         return 1;
00067                                 }
00068                         }
00069                 }
00070                 return 0;
00071         }
00072 
00073         virtual ~ModuleNoNotice()
00074         {
00075                 ServerInstance->Modes->DelMode(nt);
00076                 delete nt;
00077         }
00078 
00079         virtual Version GetVersion()
00080         {
00081                 return Version("$Id: m_nonotice.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00082         }
00083 };
00084 
00085 MODULE_INIT(ModuleNoNotice)