Mercurial > prosody-modules
changeset 2990:cb8d65b40fb4
mod_query_client_ver: Add a simple adhoc command that queries all currently connected clients
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 04 Apr 2018 16:31:44 +0200 (2018-04-04) |
parents | 926aaaeb0d21 |
children | 9d205ec1fa00 |
files | mod_query_client_ver/mod_query_client_ver.lua |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_query_client_ver/mod_query_client_ver.lua Wed Apr 04 15:55:09 2018 +0200 +++ b/mod_query_client_ver/mod_query_client_ver.lua Wed Apr 04 16:31:44 2018 +0200 @@ -56,3 +56,15 @@ module:hook("iq-error/host/"..disco_id, function() return true; -- Doesn't reply to disco#info? Weird, but ignore for now. end); + +module:add_item("adhoc", + module:require "adhoc".new("Query all currently connected clients", "ping", + function (self, data, state) + for jid, session in pairs(prosody.full_sessions) do + if session.jid == module.host then + session.send(st.iq({ id = version_id, type = "get", from = module.host, to = session.full_jid }):query(xmlns_iq_version)); + end + end + return { info = "Ok, check your logs for results", status = "completed" } + end)); +