3 // showwhois module by typobox43
12 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
16 class SeeWhois : public ModeHandler
19 SeeWhois(InspIRCd* Instance) : ModeHandler(Instance, 'W', 0, 0, false, MODETYPE_CHANNEL, false) { }
21 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
23 /* Only opers can change other users modes */
24 if ((source != dest) && (!*source->oper))
25 return MODEACTION_DENY;
29 if (!channel->IsModeSet('W'))
31 dest->SetMode('W',true);
32 return MODEACTION_ALLOW;
37 if (channel->IsModeSet('W'))
39 dest->SetMode('W',false);
40 return MODEACTION_ALLOW;
44 return MODEACTION_DENY;
48 class ModuleShowwhois : public Module
55 ModuleShowwhois(InspIRCd* Me) : Module::Module(Me)
58 sw = new SeeWhois(ServerInstance);
59 ServerInstance->AddMode(sw, 'W');
64 ServerInstance->Modes->DelMode(sw);
68 void Implements(char* List)
73 virtual Version GetVersion()
75 return Version(1,0,0,3,VF_COMMON|VF_VENDOR);
78 virtual void OnWhois(userrec* source, userrec* dest)
80 if ((dest->IsModeSet('W')) && (source != dest))
82 dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
88 class ModuleShowwhoisFactory : public ModuleFactory
91 ModuleShowwhoisFactory()
95 ~ModuleShowwhoisFactory()
99 virtual Module* CreateModule(InspIRCd* Me)
101 return new ModuleShowwhois(Me);
106 extern "C" void* init_module()
108 return new ModuleShowwhoisFactory;