mod_csi_simple: Consider messages encrypted payload as important (fixes part of ...
[prosody.git] / plugins / mod_version.lua
blob1d24001c0f6402cd5f556d43689cdd548d39886d
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
9 local st = require "util.stanza";
11 module:add_feature("jabber:iq:version");
13 local query = st.stanza("query", {xmlns = "jabber:iq:version"})
14 :text_tag("name", "Prosody")
15 :text_tag("version", prosody.version);
17 if not module:get_option_boolean("hide_os_type") then
18 local platform;
19 if os.getenv("WINDIR") then
20 platform = "Windows";
21 else
22 local os_version_command = module:get_option_string("os_version_command");
23 local ok, pposix = pcall(require, "util.pposix");
24 if not os_version_command and (ok and pposix and pposix.uname) then
25 platform = pposix.uname().sysname;
26 end
27 if not platform then
28 local uname = io.popen(os_version_command or "uname");
29 if uname then
30 platform = uname:read("*a");
31 end
32 uname:close();
33 end
34 end
35 if platform then
36 platform = platform:match("^%s*(.-)%s*$") or platform;
37 query:text_tag("os", platform);
38 end
39 end
41 module:hook("iq-get/host/jabber:iq:version:query", function(event)
42 local origin, stanza = event.origin, event.stanza;
43 origin.send(st.reply(stanza):add_child(query));
44 return true;
45 end);