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