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 */
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(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))
92 dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
96 std::deque<std::string> params;
97 params.push_back(dest->nick);
98 std::string msg = ":";
99 msg = msg + dest->server + " NOTICE " + dest->nick + " :*** " + source->nick + " (" + source->ident + "@" + source->host + ") did a /whois on you.";
100 params.push_back(msg);
101 Event ev((char *) ¶ms, NULL, "send_push");
102 ev.Send(ServerInstance);
109 MODULE_INIT(ModuleShowwhois)