Mercurial > prosody-modules
comparison mod_lastlog/mod_lastlog.lua @ 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 | 884ae37d76bf |
| children | 38781835c911 |
comparison
equal
deleted
inserted
replaced
| 1038:edb06824a5a4 | 1039:3f91f17ddaca |
|---|---|
| 9 timestamp = time(), | 9 timestamp = time(), |
| 10 ip = log_ip and session.ip or nil, | 10 ip = log_ip and session.ip or nil, |
| 11 }); | 11 }); |
| 12 end | 12 end |
| 13 end); | 13 end); |
| 14 | |
| 15 function module.command(arg) | |
| 16 local user, host = require "util.jid".prepped_split(table.remove(arg, 1)); | |
| 17 local lastlog = datamanager.load(user, host, "lastlog") or {}; | |
| 18 print("Last login: "..(lastlog and os.date("%Y-%m-%d %H:%m:%s", datamanager.load(user, host, "lastlog").time) or "<unknown>")); | |
| 19 if lastlog.ip then | |
| 20 print("IP address: "..lastlog.ip); | |
| 21 end | |
| 22 return 0; | |
| 23 end |
