clix/roster.lua

changeset 122
1dfd28db10bd
parent 121
896a25ed6b1b
child 123
c61fadb9d4fa
equal deleted inserted replaced
103:45843df81db0 122:1dfd28db10bd
68 param = nil 68 param = nil
69 end 69 end
70 for jid, item in pairs(conn.roster.items) do 70 for jid, item in pairs(conn.roster.items) do
71 local name, host = item.name or split_jid(jid); 71 local name, host = item.name or split_jid(jid);
72 local groups = table.concat(item.groups or {}, ", "); 72 local groups = table.concat(item.groups or {}, ", ");
73 if not param or ( (name and name:match(param)) or jid:match(param) ) then 73 if not param or ( (name and name:find(param, 1, true)) or jid:find(param, 1, true) ) then
74 print(jid, name or host, groups); 74 print(jid, name or host, groups);
75 end 75 end
76 end 76 end
77 end; 77 end;
78 listgroups = function(param) 78 listgroups = function(param)
95 95
96 for k,v in pairs(item) do 96 for k,v in pairs(item) do
97 print(k,type(v) == "table" and table.concat(v, ", ") or v) 97 print(k,type(v) == "table" and table.concat(v, ", ") or v)
98 end 98 end
99 end; 99 end;
100 export = function()
101 local stored_roster = { [false] = { version = conn.roster.ver } }
102 for jid, item in pairs(conn.roster.items) do
103 stored_roster[jid] = {
104 name = item.name;
105 subscription = item.subscription;
106 groups = { unpack(item.groups) };
107 }
108 end
109 print("return "..require"util.serialization".serialize(stored_roster));
110 end
100 } 111 }
101 function commands.help () 112 function commands.help ()
102 print("Roster commands"); 113 print("Roster commands");
103 for cmd in pairs(commands) do 114 for cmd in pairs(commands) do
104 print(" * " .. cmd); 115 print(" * " .. cmd);

mercurial