comparison mod_lastlog/mod_lastlog.lua @ 1048:50bed746aa16

mod_lastlog: Fix command
author Kim Alvefur <zash@zash.se>
date Mon, 03 Jun 2013 19:35:13 +0200
parents 38781835c911
children 59f031d1cd38
comparison
equal deleted inserted replaced
1047:38781835c911 1048:50bed746aa16
25 end 25 end
26 end); 26 end);
27 27
28 function module.command(arg) 28 function module.command(arg)
29 local user, host = require "util.jid".prepped_split(table.remove(arg, 1)); 29 local user, host = require "util.jid".prepped_split(table.remove(arg, 1));
30 local lastlog = datamanager.load(user, host, "lastlog") or {}; 30 require"core.storagemanager".initialize_host(host);
31 print("Last login: "..(lastlog and os.date("%Y-%m-%d %H:%m:%s", datamanager.load(user, host, "lastlog").time) or "<unknown>")); 31 local lastlog = assert(datamanager.load(user, host, "lastlog"));
32 if lastlog.ip then 32 if lastlog then
33 print("IP address: "..lastlog.ip); 33 print(("Last %s: %s"):format(lastlog.event or "login",
34 lastlog.timestamp and os.date("%Y-%m-%d %H:%M:%S", lastlog.timestamp) or "<unknown>"));
35 if lastlog.ip then
36 print("IP address: "..lastlog.ip);
37 end
38 else
39 print("No record found");
34 end 40 end
35 return 0; 41 return 0;
36 end 42 end