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 ServerInstance->AddMode(sw, 'W');
71 ServerInstance->Modes->DelMode(sw);
75 void Implements(char* List)
80 virtual Version GetVersion()
82 return Version(1,1,0,3,VF_COMMON|VF_VENDOR,API_VERSION);
85 virtual void OnWhois(userrec* source, userrec* dest)
87 if ((dest->IsModeSet('W')) && (source != dest))
89 dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
95 class ModuleShowwhoisFactory : public ModuleFactory
98 ModuleShowwhoisFactory()
102 ~ModuleShowwhoisFactory()
106 virtual Module* CreateModule(InspIRCd* Me)
108 return new ModuleShowwhois(Me);
113 extern "C" void* init_module()
115 return new ModuleShowwhoisFactory;