3 // showwhois module by typobox43
9 #include "helperfuncs.h"
11 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
13 class SeeWhois : public ModeHandler
16 SeeWhois() : ModeHandler('W', 0, 0, false, MODETYPE_CHANNEL, false) { }
18 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
20 /* Only opers can change other users modes */
21 if ((source != dest) && (!*source->oper))
22 return MODEACTION_DENY;
26 if (!channel->IsModeSet('W'))
28 dest->SetMode('W',true);
29 return MODEACTION_ALLOW;
34 if (channel->IsModeSet('W'))
36 dest->SetMode('W',false);
37 return MODEACTION_ALLOW;
41 return MODEACTION_DENY;
45 class ModuleShowwhois : public Module
52 ModuleShowwhois(Server* Me) : Module::Module(Me)
56 Srv->AddMode(sw, 'W');
64 void Implements(char* List)
69 virtual Version GetVersion()
71 return Version(1,0,0,3,VF_STATIC);
74 virtual void OnWhois(userrec* source, userrec* dest)
76 if ((dest->IsModeSet('W')) && (source != dest))
78 WriteServ(dest->fd,"NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
84 class ModuleShowwhoisFactory : public ModuleFactory
87 ModuleShowwhoisFactory()
91 ~ModuleShowwhoisFactory()
95 virtual Module* CreateModule(Server* Me)
97 return new ModuleShowwhois(Me);
102 extern "C" void* init_module()
104 return new ModuleShowwhoisFactory;