1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
21 /** Handle user mode +W
23 class SeeWhois : public ModeHandler
26 SeeWhois(InspIRCd* Instance) : ModeHandler(Instance, 'W', 0, 0, false, MODETYPE_USER, true) { }
28 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
30 /* Only opers can change other users modes */
31 if ((source != dest) && (!*source->oper))
32 return MODEACTION_DENY;
36 if (!dest->IsModeSet('W'))
38 dest->SetMode('W',true);
39 return MODEACTION_ALLOW;
44 if (dest->IsModeSet('W'))
46 dest->SetMode('W',false);
47 return MODEACTION_ALLOW;
51 return MODEACTION_DENY;
55 class ModuleShowwhois : public Module
62 ModuleShowwhois(InspIRCd* Me) : Module::Module(Me)
65 sw = new SeeWhois(ServerInstance);
66 if (!ServerInstance->AddMode(sw, 'W'))
67 throw ModuleException("Could not add new modes!");
72 ServerInstance->Modes->DelMode(sw);
76 void Implements(char* List)
81 virtual Version GetVersion()
83 return Version(1,1,0,3,VF_COMMON|VF_VENDOR,API_VERSION);
86 virtual void OnWhois(userrec* source, userrec* dest)
88 if ((dest->IsModeSet('W')) && (source != dest))
90 dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
96 class ModuleShowwhoisFactory : public ModuleFactory
99 ModuleShowwhoisFactory()
103 ~ModuleShowwhoisFactory()
107 virtual Module* CreateModule(InspIRCd* Me)
109 return new ModuleShowwhois(Me);
114 extern "C" void* init_module()
116 return new ModuleShowwhoisFactory;