comparison mod_lastlog/mod_lastlog.lua @ 1103:59657e03c25c

mod_lastlog: Make the command show a help message instead of a traceback when no user given
author Kim Alvefur <zash@zash.se>
date Tue, 09 Jul 2013 09:38:10 +0200
parents 59f031d1cd38
children 1e8b793d8ff9
comparison
equal deleted inserted replaced
1102:bfde5e5318d7 1103:59657e03c25c
46 module:hook("pre-presence/bare", offline_stamp); 46 module:hook("pre-presence/bare", offline_stamp);
47 module:hook("pre-presence/full", offline_stamp); 47 module:hook("pre-presence/full", offline_stamp);
48 end 48 end
49 49
50 function module.command(arg) 50 function module.command(arg)
51 if not arg[1] or arg[1] == "--help" then
52 require"util.prosodyctl".show_usage([[mod_lastlog <user@host>]], [[Show when user last logged in or out]]);
53 return 1;
54 end
51 local user, host = jid.prepped_split(table.remove(arg, 1)); 55 local user, host = jid.prepped_split(table.remove(arg, 1));
52 require"core.storagemanager".initialize_host(host); 56 require"core.storagemanager".initialize_host(host);
53 local lastlog = assert(datamanager.load(user, host, "lastlog")); 57 local lastlog = assert(datamanager.load(user, host, "lastlog"));
54 if lastlog then 58 if lastlog then
55 print(("Last %s: %s"):format(lastlog.event or "login", 59 print(("Last %s: %s"):format(lastlog.event or "login",