- 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);
+ }
+
+ void OnGarbageCollect()
+ {
+ // Remove all entries older than MaxKeep
+ cmd.Maintain();
+ }
+
+ 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 ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+ {
+ ConfigTag* tag = ServerInstance->Config->ConfValue("whowas");
+ unsigned int NewGroupSize = tag->getInt("groupsize", 10, 0, 10000);
+ unsigned int NewMaxGroups = tag->getInt("maxgroups", 10240, 0, 1000000);
+ unsigned int NewMaxKeep = tag->getDuration("maxkeep", 3600, 3600);
+
+ if ((NewGroupSize == cmd.GroupSize) && (NewMaxGroups == cmd.MaxGroups) && (NewMaxKeep == cmd.MaxKeep))
+ return;
+
+ cmd.GroupSize = NewGroupSize;
+ cmd.MaxGroups = NewMaxGroups;
+ cmd.MaxKeep = NewMaxKeep;
+ cmd.Prune();