]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonotice.cpp
Fix various rline bugs, implement /stats R, and fix the issue where you get no error...
[user/henk/code/inspircd.git] / src / modules / m_nonotice.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 +T */
17
18 class NoNotice : public SimpleChannelModeHandler
19 {
20  public:
21         NoNotice(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'T') { }
22 };
23
24 class ModuleNoNotice : public Module
25 {
26
27         NoNotice* nt;
28  public:
29
30         ModuleNoNotice(InspIRCd* Me)
31                 : Module(Me)
32         {
33
34                 nt = new NoNotice(ServerInstance);
35                 if (!ServerInstance->Modes->AddMode(nt))
36                         throw ModuleException("Could not add new modes!");
37                 Implementation eventlist[] = { I_OnUserPreNotice, I_On005Numeric };
38                 ServerInstance->Modules->Attach(eventlist, this, 2);
39         }
40
41         virtual void On005Numeric(std::string &output)
42         {
43                 ServerInstance->AddExtBanChar('T');
44         }
45
46         virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
47         {
48                 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
49                 {
50                         Channel* c = (Channel*)dest;
51                         if (c->IsModeSet('T') || c->IsExtBanned(user, 'T'))
52                         {
53                                 if (ServerInstance->ULine(user->server))
54                                 {
55                                         // ulines are exempt.
56                                         return 0;
57                                 }
58                                 else if (CHANOPS_EXEMPT(ServerInstance, 'T') && c->GetStatus(user) == STATUS_OP)
59                                 {
60                                         // channel ops are exempt if set in conf.
61                                         return 0;
62                                 }
63                                 else
64                                 {
65                                         user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Can't send NOTICE to channel (+T set)",user->nick.c_str(), c->name.c_str());
66                                         return 1;
67                                 }
68                         }
69                 }
70                 return 0;
71         }
72
73         virtual ~ModuleNoNotice()
74         {
75                 ServerInstance->Modes->DelMode(nt);
76                 delete nt;
77         }
78
79         virtual Version GetVersion()
80         {
81                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
82         }
83 };
84
85 MODULE_INIT(ModuleNoNotice)