]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_showwhois.cpp
Fix by om for 'mode change while not on channel' bug
[user/henk/code/inspircd.git] / src / modules / m_showwhois.cpp
1 // showwhois module by typobox43
2
3 #include "users.h"
4 #include "channels.h"
5 #include "modules.h"
6
7 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
8
9 Server *Srv;
10
11 class ModuleShowwhois : public Module {
12
13         public:
14
15                 ModuleShowwhois() {
16
17                         Srv = new Server;
18
19                         Srv->AddExtendedMode('W',MT_CLIENT,true,0,0);
20
21                 }
22
23                 ~ModuleShowwhois() {
24
25                         delete Srv;
26
27                 }
28
29                 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list& params) {
30
31                         if((type == MT_CLIENT) && (modechar == 'W')) {
32
33                                 return 1;
34
35                         }
36
37                         return 0;
38
39                 }
40
41                 virtual void OnWhois(userrec* source, userrec* dest) {
42
43                         if(strchr(dest->modes,'W')) {
44
45                                 WriteServ(dest->fd,"NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
46                                 
47                         }
48
49                 }
50
51 };
52
53 class ModuleShowwhoisFactory : public ModuleFactory {
54
55         public:
56
57                 ModuleShowwhoisFactory() {
58
59                 }
60
61                 ~ModuleShowwhoisFactory() {
62
63                 }
64
65                 virtual Module* CreateModule() {
66
67                         return new ModuleShowwhois;
68
69                 }
70
71 };
72
73 extern "C" void* init_module() {
74
75         return new ModuleShowwhoisFactory;
76
77 }