Comparison

plugins/mod_version.lua @ 9435:33301038d3e4

mod_version: Rename confusingly named variable Maybe this meant the version of the OS, but it's still confusing.
author Kim Alvefur <zash@zash.se>
date Sat, 06 Oct 2018 16:32:37 +0200
parent 9434:b502766a10d7
child 9436:a950f9fa9137
comparison
equal deleted inserted replaced
9434:b502766a10d7 9435:33301038d3e4
8 8
9 local st = require "util.stanza"; 9 local st = require "util.stanza";
10 10
11 module:add_feature("jabber:iq:version"); 11 module:add_feature("jabber:iq:version");
12 12
13 local version; 13 local platform;
14 14
15 local query = st.stanza("query", {xmlns = "jabber:iq:version"}) 15 local query = st.stanza("query", {xmlns = "jabber:iq:version"})
16 :text_tag("name", "Prosody") 16 :text_tag("name", "Prosody")
17 :text_tag("version", prosody.version); 17 :text_tag("version", prosody.version);
18 18
19 if not module:get_option_boolean("hide_os_type") then 19 if not module:get_option_boolean("hide_os_type") then
20 if os.getenv("WINDIR") then 20 if os.getenv("WINDIR") then
21 version = "Windows"; 21 platform = "Windows";
22 else 22 else
23 local os_version_command = module:get_option_string("os_version_command"); 23 local os_version_command = module:get_option_string("os_version_command");
24 local ok, pposix = pcall(require, "util.pposix"); 24 local ok, pposix = pcall(require, "util.pposix");
25 if not os_version_command and (ok and pposix and pposix.uname) then 25 if not os_version_command and (ok and pposix and pposix.uname) then
26 version = pposix.uname().sysname; 26 platform = pposix.uname().sysname;
27 end 27 end
28 if not version then 28 if not platform then
29 local uname = io.popen(os_version_command or "uname"); 29 local uname = io.popen(os_version_command or "uname");
30 if uname then 30 if uname then
31 version = uname:read("*a"); 31 platform = uname:read("*a");
32 end 32 end
33 uname:close(); 33 uname:close();
34 end 34 end
35 end 35 end
36 if version then 36 if platform then
37 version = version:match("^%s*(.-)%s*$") or version; 37 platform = platform:match("^%s*(.-)%s*$") or platform;
38 query:text_tag("os", version); 38 query:text_tag("os", platform);
39 end 39 end
40 end 40 end
41 41
42 module:hook("iq-get/host/jabber:iq:version:query", function(event) 42 module:hook("iq-get/host/jabber:iq:version:query", function(event)
43 local origin, stanza = event.origin, event.stanza; 43 local origin, stanza = event.origin, event.stanza;