summaryrefslogtreecommitdiffstats
blob: 38bf6ac607842d16612ebd7f7de670195c0dec77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--[[
	
	Copyright (c) 2010-2013 Remko Tronçon
	Licensed under the GNU General Public License v3.
	See Documentation/Licenses/GPLv3.txt for more information.

	This script logs into an XMPP server, and collects statistics about
	the server software of all contacts in your roster

--]]

require 'sluift'

c = sluift.new_client(os.getenv('SLUIFT_JID'), os.getenv('SLUIFT_PASS'))
c:connect(function () 
	versions = {}
	for jid in pairs(c:get_contacts()) do
		local v = c:get_software_version {to = sluift.jid.domain(jid), timeout = 3000} or {name = 'Unknown'}
		versions[v['name']] = (versions[v['name']] or 0) + 1
	end
	for name, count in pairs(versions) do print(name .. ': ' .. count) end
end)