Software /
code /
prosody
Comparison
plugins/mod_version.lua @ 3421:d3852a4d37e2
mod_version: Leave out the os element if hide_os_type is set
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 01 Aug 2010 15:58:10 +0200 |
parent | 3420:9be46a3466ef |
child | 3483:443139c396c5 |
comparison
equal
deleted
inserted
replaced
3420:9be46a3466ef | 3421:d3852a4d37e2 |
---|---|
10 | 10 |
11 module:add_feature("jabber:iq:version"); | 11 module:add_feature("jabber:iq:version"); |
12 | 12 |
13 local version = "the best operating system ever!"; | 13 local version = "the best operating system ever!"; |
14 | 14 |
15 local query = st.stanza("query", {xmlns = "jabber:iq:version"}) | |
16 :tag("name"):text("Prosody"):up() | |
17 :tag("version"):text(prosody.version):up(); | |
18 | |
15 if not module:get_option("hide_os_type") then | 19 if not module:get_option("hide_os_type") then |
16 if os.getenv("WINDIR") then | 20 if os.getenv("WINDIR") then |
17 version = "Windows"; | 21 version = "Windows"; |
18 else | 22 else |
19 local uname = io.popen(module:get_option("os_version_command") or "uname"); | 23 local uname = io.popen(module:get_option("os_version_command") or "uname"); |
21 version = uname:read("*a"); | 25 version = uname:read("*a"); |
22 else | 26 else |
23 version = "an OS"; | 27 version = "an OS"; |
24 end | 28 end |
25 end | 29 end |
30 version = version:match("^%s*(.-)%s*$") or version; | |
31 query:tag("os"):text(version):up(); | |
26 end | 32 end |
27 | |
28 version = version:match("^%s*(.-)%s*$") or version; | |
29 | |
30 local query = st.stanza("query", {xmlns = "jabber:iq:version"}) | |
31 :tag("name"):text("Prosody"):up() | |
32 :tag("version"):text(prosody.version):up() | |
33 :tag("os"):text(version); | |
34 | 33 |
35 module:hook("iq/host/jabber:iq:version:query", function(event) | 34 module:hook("iq/host/jabber:iq:version:query", function(event) |
36 local stanza = event.stanza; | 35 local stanza = event.stanza; |
37 if stanza.attr.type == "get" and stanza.attr.to == module.host then | 36 if stanza.attr.type == "get" and stanza.attr.to == module.host then |
38 event.origin.send(st.reply(stanza):add_child(query)); | 37 event.origin.send(st.reply(stanza):add_child(query)); |