]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonotice.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_nonotice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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(Module* Creator) : SimpleChannelModeHandler(Creator, 'T') { }
22 };
23
24 class ModuleNoNotice : public Module
25 {
26         NoNotice nt;
27  public:
28
29         ModuleNoNotice()
30                 : nt(this)
31         {
32                 if (!ServerInstance->Modes->AddMode(&nt))
33                         throw ModuleException("Could not add new modes!");
34                 Implementation eventlist[] = { I_OnUserPreNotice, I_On005Numeric };
35                 ServerInstance->Modules->Attach(eventlist, this, 2);
36         }
37
38         virtual void On005Numeric(std::string &output)
39         {
40                 ServerInstance->AddExtBanChar('T');
41         }
42
43         virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
44         {
45                 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
46                 {
47                         Channel* c = (Channel*)dest;
48                         if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet('T')))
49                         {
50                                 if (ServerInstance->ULine(user->server))
51                                 {
52                                         // ulines are exempt.
53                                         return MOD_RES_PASSTHRU;
54                                 }
55                                 else if (CHANOPS_EXEMPT('T') && c->GetPrefixValue(user) == OP_VALUE)
56                                 {
57                                         // channel ops are exempt if set in conf.
58                                         return MOD_RES_PASSTHRU;
59                                 }
60                                 else
61                                 {
62                                         user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Can't send NOTICE to channel (+T set)",user->nick.c_str(), c->name.c_str());
63                                         return MOD_RES_DENY;
64                                 }
65                         }
66                 }
67                 return MOD_RES_PASSTHRU;
68         }
69
70         virtual ~ModuleNoNotice()
71         {
72                 ServerInstance->Modes->DelMode(&nt);
73         }
74
75         virtual Version GetVersion()
76         {
77                 return Version("Provides support for unreal-style channel mode +T", VF_COMMON | VF_VENDOR, API_VERSION);
78         }
79 };
80
81 MODULE_INIT(ModuleNoNotice)