# HG changeset patch # User Kim Alvefur # Date 1370280913 -7200 # Node ID 50bed746aa1618c146db50d75cf258c3170af30b # Parent 38781835c911ff195e34805e9d24f2332ce75a5c mod_lastlog: Fix command diff -r 38781835c911 -r 50bed746aa16 mod_lastlog/mod_lastlog.lua --- a/mod_lastlog/mod_lastlog.lua Mon Jun 03 19:03:42 2013 +0200 +++ b/mod_lastlog/mod_lastlog.lua Mon Jun 03 19:35:13 2013 +0200 @@ -27,10 +27,16 @@ function module.command(arg) local user, host = require "util.jid".prepped_split(table.remove(arg, 1)); - local lastlog = datamanager.load(user, host, "lastlog") or {}; - print("Last login: "..(lastlog and os.date("%Y-%m-%d %H:%m:%s", datamanager.load(user, host, "lastlog").time) or "")); - if lastlog.ip then - print("IP address: "..lastlog.ip); + require"core.storagemanager".initialize_host(host); + local lastlog = assert(datamanager.load(user, host, "lastlog")); + if lastlog then + print(("Last %s: %s"):format(lastlog.event or "login", + lastlog.timestamp and os.date("%Y-%m-%d %H:%M:%S", lastlog.timestamp) or "")); + if lastlog.ip then + print("IP address: "..lastlog.ip); + end + else + print("No record found"); end return 0; end