Mercurial > prosody-hg
comparison plugins/mod_version.lua @ 803:5a64649f4b94
mod_version: Operating system detection. Disable with hide_os_type = true in config
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 15 Feb 2009 15:52:11 +0000 |
| parents | 90ce865eebd8 |
| children | 2c0b9e3c11c3 |
comparison
equal
deleted
inserted
replaced
| 802:33c012048492 | 803:5a64649f4b94 |
|---|---|
| 12 | 12 |
| 13 local xmlns_version = "jabber:iq:version" | 13 local xmlns_version = "jabber:iq:version" |
| 14 | 14 |
| 15 module:add_feature(xmlns_version); | 15 module:add_feature(xmlns_version); |
| 16 | 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 | |
| 17 module:add_iq_handler({"c2s", "s2sin"}, xmlns_version, function(session, stanza) | 34 module:add_iq_handler({"c2s", "s2sin"}, xmlns_version, function(session, stanza) |
| 18 if stanza.attr.type == "get" then | 35 if stanza.attr.type == "get" then |
| 19 session.send(st.reply(stanza):query(xmlns_version) | 36 session.send(st.reply(stanza):query(xmlns_version) |
| 20 :tag("name"):text("Prosody"):up() | 37 :tag("name"):text("Prosody"):up() |
| 21 :tag("version"):text("0.3"):up() | 38 :tag("version"):text("0.3"):up() |
| 22 :tag("os"):text("the best operating system ever!")); | 39 :tag("os"):text(version)); |
| 23 end | 40 end |
| 24 end); | 41 end); |
