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, 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
55 ModuleShowwhois(InspIRCd* Me) : Module(Me)
59 Implementation eventlist[] = { I_OnWhois, I_OnRehash };
60 ServerInstance->Modules->Attach(eventlist, this, 2);
65 ServerInstance->Modes->DelMode(sw);
69 virtual Version GetVersion()
71 return Version("$Id$",VF_COMMON|VF_VENDOR,API_VERSION);
74 virtual void OnRehash(User *user, const std::string ¶meter)
76 ConfigReader conf(ServerInstance);
77 bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", 0, true);
81 ServerInstance->Modes->DelMode(sw);
85 sw = new SeeWhois(ServerInstance, OpersOnly);
86 if (!ServerInstance->Modes->AddMode(sw))
87 throw ModuleException("Could not add new modes!");
90 virtual void OnWhois(User* source, User* dest)
92 if ((dest->IsModeSet('W')) && (source != dest))
94 std::string wmsg = "*** ";
95 wmsg += source->nick + "(" + source->ident + "@";
97 if (dest->HasPrivPermission("users/auspex"))
103 wmsg += source->dhost;
106 wmsg += ") did a /whois on you";
110 dest->WriteServ("NOTICE %s :%s", dest->nick.c_str(), wmsg.c_str());
114 std::string msg = std::string(":") + dest->server + " NOTICE " + dest->nick + " :" + wmsg;
115 ServerInstance->PI->PushToClient(dest, msg);
122 MODULE_INIT(ModuleShowwhois)