]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_showwhois.cpp
Converted to 'Implements' system
[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                 void Implements(char* List)
29                 {
30                         List[I_OnWhois] = List[I_OnExtendedMode] = 1;
31                 }
32
33                 virtual Version GetVersion()
34                 {
35                         return Version(1,0,0,3,VF_STATIC);
36                 }
37
38                 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list& params)
39                 {
40                         if((type == MT_CLIENT) && (modechar == 'W'))
41                         {
42                                 return 1;
43                         }
44
45                         return 0;
46                 }
47
48                 virtual void OnWhois(userrec* source, userrec* dest)
49                 {
50                         if(strchr(dest->modes,'W'))
51                         {
52                                 WriteServ(dest->fd,"NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
53                         }
54                 }
55
56 };
57
58 class ModuleShowwhoisFactory : public ModuleFactory
59 {
60         public:
61                 ModuleShowwhoisFactory()
62                 {
63                 }
64
65                 ~ModuleShowwhoisFactory()
66                 {
67                 }
68
69                 virtual Module* CreateModule(Server* Me)
70                 {
71                         return new ModuleShowwhois(Me);
72                 }
73
74 };
75
76 extern "C" void* init_module()
77 {
78         return new ModuleShowwhoisFactory;
79 }