Changeset

108:ded3938232f0

clix.roster: Add a sub-command that exports a prosody-style roster data structure
author Kim Alvefur <zash@zash.se>
date Mon, 01 Apr 2013 21:25:31 +0200
parents 107:67ff8f55db4a
children 109:ab7e4845b6c1
files clix/roster.lua
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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");