]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_showwhois.cpp
Speaking of forgetting things, someone forgot to change the name of the function
[user/henk/code/inspircd.git] / src / modules / m_showwhois.cpp
1 using namespace std;
2
3 // showwhois module by typobox43
4 // Modified by Craig
5
6 #include "users.h"
7 #include "channels.h"
8 #include "modules.h"
9
10 #include "inspircd.h"
11
12 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
13
14
15
16 class SeeWhois : public ModeHandler
17 {
18  public:
19         SeeWhois(InspIRCd* Instance) : ModeHandler(Instance, 'W', 0, 0, false, MODETYPE_CHANNEL, false) { }
20
21         ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
22         {
23                 /* Only opers can change other users modes */
24                 if ((source != dest) && (!*source->oper))
25                         return MODEACTION_DENY;
26
27                 if (adding)
28                 {
29                         if (!channel->IsModeSet('W'))
30                         {
31                                 dest->SetMode('W',true);
32                                 return MODEACTION_ALLOW;
33                         }
34                 }
35                 else
36                 {
37                         if (channel->IsModeSet('W'))
38                         {
39                                 dest->SetMode('W',false);
40                                 return MODEACTION_ALLOW;
41                         }
42                 }
43
44                 return MODEACTION_DENY;
45         }
46 };
47
48 class ModuleShowwhois : public Module
49 {
50         
51         SeeWhois* sw;
52
53  public:
54
55         ModuleShowwhois(InspIRCd* Me) : Module::Module(Me)
56         {
57                 
58                 sw = new SeeWhois(ServerInstance);
59                 ServerInstance->AddMode(sw, 'W');
60         }
61
62         ~ModuleShowwhois()
63         {
64                 DELETE(sw);
65         }
66
67         void Implements(char* List)
68         {
69                 List[I_OnWhois] = 1;
70         }
71
72         virtual Version GetVersion()
73         {
74                 return Version(1,0,0,3,VF_STATIC);
75         }
76
77         virtual void OnWhois(userrec* source, userrec* dest)
78         {
79                 if ((dest->IsModeSet('W')) && (source != dest))
80                 {
81                         dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
82                 }
83         }
84
85 };
86
87 class ModuleShowwhoisFactory : public ModuleFactory
88 {
89         public:
90                 ModuleShowwhoisFactory()
91                 {
92                 }
93
94                 ~ModuleShowwhoisFactory()
95                 {
96                 }
97
98                 virtual Module* CreateModule(InspIRCd* Me)
99                 {
100                         return new ModuleShowwhois(Me);
101                 }
102
103 };
104
105 extern "C" void* init_module()
106 {
107         return new ModuleShowwhoisFactory;
108 }