3 // showwhois module by typobox43
11 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
13 /** Handle user mode +W
15 class SeeWhois : public ModeHandler
18 SeeWhois(InspIRCd* Instance) : ModeHandler(Instance, 'W', 0, 0, false, MODETYPE_USER, true) { }
20 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
22 /* Only opers can change other users modes */
23 if ((source != dest) && (!*source->oper))
24 return MODEACTION_DENY;
28 if (!dest->IsModeSet('W'))
30 dest->SetMode('W',true);
31 return MODEACTION_ALLOW;
36 if (dest->IsModeSet('W'))
38 dest->SetMode('W',false);
39 return MODEACTION_ALLOW;
43 return MODEACTION_DENY;
47 class ModuleShowwhois : public Module
54 ModuleShowwhois(InspIRCd* Me) : Module::Module(Me)
57 sw = new SeeWhois(ServerInstance);
58 ServerInstance->AddMode(sw, 'W');
63 ServerInstance->Modes->DelMode(sw);
67 void Implements(char* List)
72 virtual Version GetVersion()
74 return Version(1,1,0,3,VF_COMMON|VF_VENDOR,API_VERSION);
77 virtual void OnWhois(userrec* source, userrec* dest)
79 if ((dest->IsModeSet('W')) && (source != dest))
81 dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
87 class ModuleShowwhoisFactory : public ModuleFactory
90 ModuleShowwhoisFactory()
94 ~ModuleShowwhoisFactory()
98 virtual Module* CreateModule(InspIRCd* Me)
100 return new ModuleShowwhois(Me);
105 extern "C" void* init_module()
107 return new ModuleShowwhoisFactory;