1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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, bool)
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->Modes->AddMode(sw))
64 throw ModuleException("Could not add new modes!");
65 Implementation eventlist[] = { I_OnWhois };
66 ServerInstance->Modules->Attach(eventlist, this, 1);
71 ServerInstance->Modes->DelMode(sw);
76 virtual Version GetVersion()
78 return Version(1,1,0,3,VF_COMMON|VF_VENDOR,API_VERSION);
81 virtual void OnWhois(User* source, User* dest)
83 if ((dest->IsModeSet('W')) && (source != dest))
87 dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host);
91 std::deque<std::string> params;
92 params.push_back(dest->nick);
93 std::string msg = ":";
94 msg = msg + dest->server + " NOTICE " + dest->nick + " :*** " + source->nick + " (" + source->ident + "@" + source->host + ") did a /whois on you.";
95 params.push_back(msg);
96 Event ev((char *) ¶ms, NULL, "send_push");
97 ev.Send(ServerInstance);
104 MODULE_INIT(ModuleShowwhois)