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 * ---------------------------------------------------
16 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
18 /** Handle user mode +W
20 class SeeWhois : public ModeHandler
23 SeeWhois(InspIRCd* Instance) : ModeHandler(Instance, 'W', 0, 0, false, MODETYPE_USER, true) { }
25 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
27 /* Only opers can change other users modes */
29 return MODEACTION_DENY;
33 if (!dest->IsModeSet('W'))
35 dest->SetMode('W',true);
36 return MODEACTION_ALLOW;
41 if (dest->IsModeSet('W'))
43 dest->SetMode('W',false);
44 return MODEACTION_ALLOW;
48 return MODEACTION_DENY;
52 class ModuleShowwhois : public Module
59 ModuleShowwhois(InspIRCd* Me) : Module(Me)
62 sw = new SeeWhois(ServerInstance);
63 if (!ServerInstance->AddMode(sw))
64 throw ModuleException("Could not add new modes!");
69 ServerInstance->Modes->DelMode(sw);
73 void Implements(char* List)
78 virtual Version GetVersion()
80 return Version(1,1,0,3,VF_COMMON|VF_VENDOR,API_VERSION);
83 virtual void OnWhois(User* source, User* dest)
85 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);
93 std::deque<std::string> params;
94 params.push_back(dest->nick);
95 std::string msg = ":";
96 msg = msg + dest->server + " NOTICE " + dest->nick + " :*** " + source->nick + " (" + source->ident + "@" + source->host + ") did a /whois on you.";
97 params.push_back(msg);
98 Event ev((char *) ¶ms, NULL, "send_push");
99 ev.Send(ServerInstance);
106 MODULE_INIT(ModuleShowwhois)