clix.roster: Add a sub-command that exports a prosody-style roster data structure

Mon, 01 Apr 2013 21:25:31 +0200

author
Kim Alvefur <zash@zash.se>
date
Mon, 01 Apr 2013 21:25:31 +0200
changeset 110
ded3938232f0
parent 109
67ff8f55db4a
child 111
ab7e4845b6c1

clix.roster: Add a sub-command that exports a prosody-style roster data structure

clix/roster.lua file | annotate | diff | comparison | revisions
--- a/clix/roster.lua	Mon Apr 01 21:29:59 2013 +0200
+++ b/clix/roster.lua	Mon Apr 01 21:25:31 2013 +0200
@@ -97,6 +97,17 @@
 					print(k,type(v) == "table" and table.concat(v, ", ") or v)
 				end
 			end;
+			export = function()
+				local stored_roster = { [false] = { version = conn.roster.ver } }
+				for jid, item in pairs(conn.roster.items) do
+					stored_roster[jid] = {
+						name = item.name;
+						subscription = item.subscription;
+						groups = { unpack(item.groups) };
+					}
+				end
+				print("return "..require"util.serialization".serialize(stored_roster));
+			end
 		}
 		function commands.help ()
 			print("Roster commands");

mercurial