Comparison

util/stanza.lua @ 373:dd0345edeaf4

Add helper function for adding message bodies to stanzas
author Matthew Wild <mwild1@gmail.com>
date Sat, 22 Nov 2008 19:07:41 +0000
parent 338:804f5e62a41f
child 519:cccd610a0ef9
comparison
equal deleted inserted replaced
372:e7c1e30d06d5 373:dd0345edeaf4
28 end 28 end
29 29
30 function stanza_mt:query(xmlns) 30 function stanza_mt:query(xmlns)
31 return self:tag("query", { xmlns = xmlns }); 31 return self:tag("query", { xmlns = xmlns });
32 end 32 end
33
34 function stanza_mt:body(text, attr)
35 return self:tag("body", attr):text(text);
36 end
37
33 function stanza_mt:tag(name, attrs) 38 function stanza_mt:tag(name, attrs)
34 local s = stanza(name, attrs); 39 local s = stanza(name, attrs);
35 (self.last_add[#self.last_add] or self):add_direct_child(s); 40 (self.last_add[#self.last_add] or self):add_direct_child(s);
36 t_insert(self.last_add, s); 41 t_insert(self.last_add, s);
37 return self; 42 return self;