Comparison

plugins/mod_groups.lua @ 3168:20c851616ade

Add the ability to have names in group files, by putting them with an = sign after the jid: myname@mydomain.com=My Name This is then passed on to rosters.
author Jeff Mitchell <jeff@jefferai.org>
date Fri, 28 May 2010 18:01:53 -0400
parent 3125:f2d1079a758d
child 4312:bcdff2b1d3ec
comparison
equal deleted inserted replaced
3167:546695e80e0a 3168:20c851616ade
27 -- Add them to roster 27 -- Add them to roster
28 --module:log("debug", "processing jid %s in group %s", tostring(jid), tostring(group_name)); 28 --module:log("debug", "processing jid %s in group %s", tostring(jid), tostring(group_name));
29 if jid ~= bare_jid then 29 if jid ~= bare_jid then
30 if not roster[jid] then roster[jid] = {}; end 30 if not roster[jid] then roster[jid] = {}; end
31 roster[jid].subscription = "both"; 31 roster[jid].subscription = "both";
32 if groups[group_name][jid] then
33 roster[jid].name = groups[group_name][jid];
34 end
32 if not roster[jid].groups then 35 if not roster[jid].groups then
33 roster[jid].groups = { [group_name] = true }; 36 roster[jid].groups = { [group_name] = true };
34 end 37 end
35 roster[jid].groups[group_name] = true; 38 roster[jid].groups[group_name] = true;
36 roster[jid].persist = false; 39 roster[jid].persist = false;
98 end 101 end
99 module:log("debug", "New group: %s", tostring(curr_group)); 102 module:log("debug", "New group: %s", tostring(curr_group));
100 groups[curr_group] = groups[curr_group] or {}; 103 groups[curr_group] = groups[curr_group] or {};
101 else 104 else
102 -- Add JID 105 -- Add JID
103 local jid = jid_prep(line:match("%S+")); 106 local entryjid, name = line:match("([^=]*)=?(.*)");
107 module:log("debug", "entryjid = '%s', name = '%s'", entryjid, name);
108 local jid;
109 jid = jid_prep(entryjid:match("%S+"));
104 if jid then 110 if jid then
105 module:log("debug", "New member of %s: %s", tostring(curr_group), tostring(jid)); 111 module:log("debug", "New member of %s: %s", tostring(curr_group), tostring(jid));
106 groups[curr_group][jid] = true; 112 groups[curr_group][jid] = name or false;
107 members[jid] = members[jid] or {}; 113 members[jid] = members[jid] or {};
108 members[jid][#members[jid]+1] = curr_group; 114 members[jid][#members[jid]+1] = curr_group;
109 end 115 end
110 end 116 end
111 end 117 end