diff options
Diffstat (limited to 'modules/commands/os_stats.cpp')
-rw-r--r-- | modules/commands/os_stats.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 1251226c3..a4a2a858a 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -14,7 +14,12 @@ struct Stats : Serializable { - Stats() : Serializable("Stats") { } + static Stats *me; + + Stats() : Serializable("Stats") + { + me = this; + } void Serialize(Serialize::Data &data) const override { @@ -26,10 +31,12 @@ struct Stats : Serializable { data["maxusercnt"] >> MaxUserCount; data["maxusertime"] >> MaxUserTime; - return NULL; + return me; } }; +Stats *Stats::me; + /** * Count servers connected to server s * @param s The server to start counting from @@ -237,6 +244,7 @@ class CommandOSStats : public Command }; class OSStats : public Module + , public EventHook<Event::UserConnect> { CommandOSStats commandosstats; Serialize::Type stats_type; @@ -244,11 +252,18 @@ class OSStats : public Module public: OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::UserConnect>("OnUserConnect") , commandosstats(this) , stats_type("Stats", Stats::Unserialize) { } + + void OnUserConnect(User *u, bool &exempt) override + { + if (UserListByNick.size() == MaxUserCount && Anope::CurTime == MaxUserTime) + stats_saver.QueueUpdate(); + } }; MODULE_INIT(OSStats) |