124 return st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#items", }); |
124 return st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#items", }); |
125 end |
125 end |
126 end; |
126 end; |
127 }; |
127 }; |
128 |
128 |
|
129 -- XEP-0050: Ad-Hoc Commands |
|
130 command = {"func", "http://jabber.org/protocol/commands", "command", |
|
131 function (s) |
|
132 local cmd = { |
|
133 action = s.attr.action, |
|
134 node = s.attr.node, |
|
135 sessionid = s.attr.sessionid, |
|
136 status = s.attr.status, |
|
137 }; |
|
138 local actions = s:get_child("actions"); |
|
139 local note = s:get_child("note"); |
|
140 -- TODO -- local form = s:get_child("x", "jabber:x:data"); |
|
141 if actions then |
|
142 cmd.actions = { |
|
143 execute = actions.attr.execute, |
|
144 }; |
|
145 for action in actions:childtags() do |
|
146 cmd.actions[action.name] = true |
|
147 end |
|
148 elseif note then |
|
149 cmd.note = { |
|
150 type = note.attr.type; |
|
151 text = note:get_text(); |
|
152 }; |
|
153 end |
|
154 return cmd; |
|
155 end; |
|
156 function (s) |
|
157 if type(s) == "table" and s ~= json.null then |
|
158 local cmd = st.stanza("command", { |
|
159 xmlns = "http://jabber.org/protocol/commands", |
|
160 action = s.action, |
|
161 node = s.node, |
|
162 sessionid = s.sessionid, |
|
163 status = s.status, |
|
164 }); |
|
165 return cmd; |
|
166 elseif type(s) == "string" then -- assume node |
|
167 return st.stanza("command", { xmlns = "http://jabber.org/protocol/commands", node = s }); |
|
168 end |
|
169 -- else .. missing required attribute |
|
170 end; |
|
171 }; |
|
172 |
129 -- XEP-0066: Out of Band Data |
173 -- XEP-0066: Out of Band Data |
130 oob_url = {"func", "jabber:iq:oob", "query", |
174 oob_url = {"func", "jabber:iq:oob", "query", |
131 function (s) |
175 function (s) |
132 return s:get_child_text("url"); |
176 return s:get_child_text("url"); |
133 end; |
177 end; |