]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonotice.cpp
fixed some indentation and spacing in modules
[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 };
38                 ServerInstance->Modules->Attach(eventlist, this, 1);
39         }
40
41
42         virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
43         {
44                 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
45                 {
46                         Channel* c = (Channel*)dest;
47                         if (c->IsModeSet('T'))
48                         {
49                                 if (ServerInstance->ULine(user->server))
50                                 {
51                                         // ulines are exempt.
52                                         return 0;
53                                 }
54                                 else if (CHANOPS_EXEMPT(ServerInstance, 'T') && c->GetStatus(user) == STATUS_OP)
55                                 {
56                                         // channel ops are exempt if set in conf.
57                                         return 0;
58                                 }
59                                 else
60                                 {
61                                         user->WriteNumeric(404, "%s %s :Can't send NOTICE to channel (+T set)",user->nick.c_str(), c->name.c_str());
62                                         return 1;
63                                 }
64                         }
65                 }
66                 return 0;
67         }
68
69         virtual ~ModuleNoNotice()
70         {
71                 ServerInstance->Modes->DelMode(nt);
72                 delete nt;
73         }
74
75         virtual Version GetVersion()
76         {
77                 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
78         }
79 };
80
81 MODULE_INIT(ModuleNoNotice)