Software /
code /
verse
Diff
plugins/version.lua @ 218:39af184385cd
plugins.version: Use get_child_text() and fix traceback on empty iq-result reply.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 22 Sep 2011 19:52:06 +0200 |
parent | 104:58305b983b1a |
child | 250:a5ac643a7fd6 |
line wrap: on
line diff
--- a/plugins/version.lua Thu Sep 08 18:04:49 2011 +0200 +++ b/plugins/version.lua Thu Sep 22 19:52:06 2011 +0200 @@ -30,15 +30,15 @@ stream:send_iq(verse.iq({ type = "get", to = target_jid }) :tag("query", { xmlns = xmlns_version }), function (reply) - local query = reply:get_child("query", xmlns_version); if reply.attr.type == "result" then - local name = query:get_child("name"); - local version = query:get_child("version"); - local os = query:get_child("os"); + local query = reply:get_child("query", xmlns_version); + local name = query and query:get_child_text("name"); + local version = query and query:get_child_text("version"); + local os = query and query:get_child_text("os"); callback({ - name = name and name:get_text() or nil; - version = version and version:get_text() or nil; - platform = os and os:get_text() or nil; + name = name; + version = version; + platform = os; }); else local type, condition, text = reply:get_error();