summaryrefslogtreecommitdiff
path: root/modules/commands/cs_seen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/commands/cs_seen.cpp')
-rw-r--r--modules/commands/cs_seen.cpp55
1 files changed, 18 insertions, 37 deletions
diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp
index 610ad4475..aacd3c168 100644
--- a/modules/commands/cs_seen.cpp
+++ b/modules/commands/cs_seen.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
@@ -290,14 +288,28 @@ class CommandSeen : public Command
}
};
-class DataBasePurger : public Timer
+class CSSeen : public Module
{
+ Serialize::Type seeninfo_type;
+ CommandSeen commandseen;
+ CommandOSSeen commandosseen;
public:
- DataBasePurger(Module *o) : Timer(o, 300, Anope::CurTime, true) { }
+ CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this)
+ {
+
+ Implementation eventlist[] = { I_OnExpireTick,
+ I_OnUserConnect,
+ I_OnUserNickChange,
+ I_OnUserQuit,
+ I_OnJoinChannel,
+ I_OnPartChannel,
+ I_OnPreUserKicked };
+ ModuleManager::Attach(eventlist, this, sizeof(eventlist) / sizeof(Implementation));
+ }
- void Tick(time_t) anope_override
+ void OnExpireTick() anope_override
{
- size_t previous_size = database.size(), purgetime = Config->GetModule(this->GetOwner())->Get<time_t>("purgetime");
+ size_t previous_size = database.size(), purgetime = Config->GetModule(this)->Get<time_t>("purgetime");
if (!purgetime)
purgetime = Anope::DoTime("30d");
for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;)
@@ -314,37 +326,6 @@ class DataBasePurger : public Timer
}
Log(LOG_DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries.";
}
-};
-
-class CSSeen : public Module
-{
- Serialize::Type seeninfo_type;
- CommandSeen commandseen;
- CommandOSSeen commandosseen;
- DataBasePurger purger;
- public:
- CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this), purger(this)
- {
-
- Implementation eventlist[] = { I_OnReload,
- I_OnUserConnect,
- I_OnUserNickChange,
- I_OnUserQuit,
- I_OnJoinChannel,
- I_OnPartChannel,
- I_OnPreUserKicked };
- ModuleManager::Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
- }
-
- void OnReload(Configuration::Conf *conf) anope_override
- {
- time_t expiretimeout = conf->GetModule(this)->Get<time_t>("expiretimeout");
- if (!expiretimeout)
- expiretimeout = Anope::DoTime("1d");
-
- if (purger.GetSecs() != expiretimeout)
- purger.SetSecs(expiretimeout);
- }
void OnUserConnect(User *u, bool &exempt) anope_override
{