- WhowasRequest* req = static_cast<WhowasRequest*>(request);
- switch (req->type)
- {
- case WhowasRequest::WHOWAS_ADD:
- cmd.AddToWhoWas(req->user);
- break;
- case WhowasRequest::WHOWAS_STATS:
- req->value = cmd.GetStats();
- break;
- case WhowasRequest::WHOWAS_PRUNE:
- cmd.PruneWhoWas(ServerInstance->Time());
- break;
- case WhowasRequest::WHOWAS_MAINTAIN:
- cmd.MaintainWhoWas(ServerInstance->Time());
- break;
- }
- return NULL;
+ ServerInstance->Modules->AddService(cmd);
+ OnRehash(NULL);
+ }
+
+ void OnGarbageCollect()
+ {
+ /* Removes all entries older than WhoWasMaxKeep */
+ cmd.MaintainWhoWas(ServerInstance->Time());
+ }
+
+ void OnUserQuit(User* user, const std::string& message, const std::string& oper_message)
+ {
+ cmd.AddToWhoWas(user);
+ }
+
+ ModResult OnStats(char symbol, User* user, string_list &results)
+ {
+ if (symbol == 'z')
+ results.push_back(ServerInstance->Config->ServerName+" 249 "+user->nick+" :"+cmd.GetStats());
+
+ return MOD_RES_PASSTHRU;
+ }
+
+ void OnRehash(User* user)
+ {
+ ConfigTag* tag = ServerInstance->Config->ConfValue("whowas");
+ int NewGroupSize = tag->getInt("groupsize", 10, 0, 10000);
+ int NewMaxGroups = tag->getInt("maxgroups", 10240, 0, 1000000);
+ int NewMaxKeep = InspIRCd::Duration(tag->getString("maxkeep"));
+
+ RangeCheck(NewMaxKeep, 3600, INT_MAX, 3600, "<whowas:maxkeep>");
+
+ if ((NewGroupSize == cmd.WhoWasGroupSize) && (NewMaxGroups == cmd.WhoWasMaxGroups) && (NewMaxKeep == cmd.WhoWasMaxKeep))
+ return;
+
+ cmd.WhoWasGroupSize = NewGroupSize;
+ cmd.WhoWasMaxGroups = NewMaxGroups;
+ cmd.WhoWasMaxKeep = NewMaxKeep;
+ cmd.PruneWhoWas(ServerInstance->Time());