Changeset

1039:3f91f17ddaca

mod_lastlog: Add prosodyctl command (prosodyctl mod_lastlog JID) to show last login time and IP of user (if available)
author Matthew Wild <mwild1@gmail.com>
date Sat, 01 Jun 2013 23:29:21 +0100
parents 1038:edb06824a5a4
children 1040:6574303a8169
files mod_lastlog/mod_lastlog.lua
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_lastlog/mod_lastlog.lua	Sat Jun 01 23:21:48 2013 +0100
+++ b/mod_lastlog/mod_lastlog.lua	Sat Jun 01 23:29:21 2013 +0100
@@ -11,3 +11,13 @@
 		});
 	end
 end);
+
+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 "<unknown>"));
+	if lastlog.ip then
+		print("IP address: "..lastlog.ip);
+	end
+	return 0;
+end