Merge
[prosody.git] / plugins / mod_version.lua
1 -- Prosody IM v0.4
2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
4 -- 
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9
10
11 local st = require "util.stanza";
12
13 local xmlns_version = "jabber:iq:version"
14
15 module:add_feature(xmlns_version);
16
17 local version = "the best operating system ever!";
18
19 if not require "core.configmanager".get("*", "core", "hide_os_type") then
20         if os.getenv("WINDIR") then
21                 version = "Windows";
22         else
23                 local uname = io.popen("uname");
24                 if uname then
25                         version = uname:read("*a");
26                 else
27                         version = "an OS";
28                 end
29         end
30 end
31
32 version = version:match("^%s*(.-)%s*$") or version;
33
34 module:add_iq_handler({"c2s", "s2sin"}, xmlns_version, function(session, stanza)
35         if stanza.attr.type == "get" then
36                 session.send(st.reply(stanza):query(xmlns_version)
37                         :tag("name"):text("Prosody"):up()
38                         :tag("version"):text("0.4"):up()
39                         :tag("os"):text(version));
40         end
41 end);