1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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, bool IsOpersOnly) : ModeHandler(Instance, 'W', 0, 0, false, MODETYPE_USER, IsOpersOnly) { }
25 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
29 if (!dest->IsModeSet('W'))
31 dest->SetMode('W',true);
32 return MODEACTION_ALLOW;
37 if (dest->IsModeSet('W'))
39 dest->SetMode('W',false);
40 return MODEACTION_ALLOW;
44 return MODEACTION_DENY;
48 class ModuleShowwhois : public Module
50 bool ShowWhoisFromOpers;
55 ModuleShowwhois(InspIRCd* Me) : Module(Me)
57 ConfigReader conf(ServerInstance);
58 bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0);
59 ShowWhoisFromOpers = conf.ReadFlag("showwhois", "showfromopers", "yes", 0);
61 sw = new SeeWhois(ServerInstance, OpersOnly);
62 if (!ServerInstance->Modes->AddMode(sw))
63 throw ModuleException("Could not add new modes!");
64 Implementation eventlist[] = { I_OnWhois };
65 ServerInstance->Modules->Attach(eventlist, this, 1);
70 ServerInstance->Modes->DelMode(sw);
74 virtual Version GetVersion()
76 return Version("$Id$",VF_COMMON|VF_VENDOR,API_VERSION);
79 virtual void OnWhois(User* source, User* dest)
81 if ((dest->IsModeSet('W')) && (source != dest))
83 if (!ShowWhoisFromOpers && IS_OPER(source))
86 std::string wmsg = "*** ";
87 wmsg += source->nick + " (" + source->ident + "@";
89 /* XXX HasPrivPermission doesn't work correctly for remote users */
90 if (IS_LOCAL(dest) && dest->HasPrivPermission("users/auspex"))
96 wmsg += source->dhost;
99 wmsg += ") did a /whois on you";
103 dest->WriteServ("NOTICE %s :%s", dest->nick.c_str(), wmsg.c_str());
107 std::string msg = std::string("::") + dest->server + " NOTICE " + dest->nick + " :" + wmsg;
108 ServerInstance->PI->PushToClient(dest, msg);
115 MODULE_INIT(ModuleShowwhois)