From 90b6de173ed1321e721599fcfd322b4ba616427f Mon Sep 17 00:00:00 2001 From: Ryan Newell Date: Wed, 8 Oct 2014 17:11:44 -0500 Subject: Add last_login field to auth.txt Also shortens some related code and adds more parameters to string.split. --- builtin/game/chatcommands.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'builtin/game/chatcommands.lua') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index d7ef712ae..c215a75c3 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -723,3 +723,20 @@ core.register_chatcommand("msg", { end, }) +core.register_chatcommand("last-login", { + params = "[name]", + description = "Get the last login time of a player", + func = function(name, param) + if param == "" then + param = name + end + local pauth = core.get_auth_handler().get_auth(param) + if pauth and pauth.last_login then + -- Time in UTC, ISO 8601 format + return true, "Last login time was " .. + os.date("!%Y-%m-%dT%H:%M:%SZ", pauth.last_login) + end + return false, "Last login time is unknown" + end, +}) + -- cgit v1.2.3