+class ModuleShowwhois : public Module
+{
+ bool ShowWhoisFromOpers;
+ SeeWhois* sw;
+ WhoisNoticeCmd cmd;
+
+ public:
+
+ ModuleShowwhois() : cmd(this)
+ {
+ ConfigReader conf;
+ bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0);
+ ShowWhoisFromOpers = conf.ReadFlag("showwhois", "showfromopers", "yes", 0);
+
+ sw = new SeeWhois(this, OpersOnly);
+ if (!ServerInstance->Modes->AddMode(sw))
+ throw ModuleException("Could not add new modes!");
+ ServerInstance->AddCommand(&cmd);
+ Implementation eventlist[] = { I_OnWhois };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
+ }
+
+ ~ModuleShowwhois()
+ {
+ delete sw;
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version("Allows opers to set +W to see when a user uses WHOIS on them",VF_COMMON|VF_VENDOR,API_VERSION);
+ }
+
+ virtual void OnWhois(User* source, User* dest)
+ {
+ if (!dest->IsModeSet('W') || source == dest)
+ return;
+
+ if (!ShowWhoisFromOpers && (IS_OPER(source) != IS_OPER(dest)))
+ return;
+
+ if (IS_LOCAL(dest))
+ {
+ cmd.HandleFast(dest, source);