Mercurial > prosody-hg
comparison plugins/mod_version.lua @ 1646:21bcc7b8b4d8
mod_version: Rewritten to use new API. Added reply caching, and fixed some issues.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Fri, 07 Aug 2009 18:29:14 +0500 |
| parents | 8ce5da8d24a0 |
| children | b7049746bd29 |
comparison
equal
deleted
inserted
replaced
| 1645:8ce5da8d24a0 | 1646:21bcc7b8b4d8 |
|---|---|
| 4 -- | 4 -- |
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 | |
| 10 local prosody = prosody; | |
| 11 local st = require "util.stanza"; | 9 local st = require "util.stanza"; |
| 12 | 10 |
| 13 local xmlns_version = "jabber:iq:version" | 11 module:add_feature("jabber:iq:version"); |
| 14 | |
| 15 module:add_feature(xmlns_version); | |
| 16 | 12 |
| 17 local version = "the best operating system ever!"; | 13 local version = "the best operating system ever!"; |
| 18 | 14 |
| 19 if not module:get_option("hide_os_type") then | 15 if not module:get_option("hide_os_type") then |
| 20 if os.getenv("WINDIR") then | 16 if os.getenv("WINDIR") then |
| 29 end | 25 end |
| 30 end | 26 end |
| 31 | 27 |
| 32 version = version:match("^%s*(.-)%s*$") or version; | 28 version = version:match("^%s*(.-)%s*$") or version; |
| 33 | 29 |
| 34 module:add_iq_handler({"c2s", "s2sin"}, xmlns_version, function(session, stanza) | 30 local query = st.stanza("query", {xmlns = "jabber:iq:version"}) |
| 35 if stanza.attr.type == "get" then | 31 :tag("name"):text("Prosody"):up() |
| 36 session.send(st.reply(stanza):query(xmlns_version) | 32 :tag("version"):text(prosody.version):up() |
| 37 :tag("name"):text("Prosody"):up() | 33 :tag("os"):text(version); |
| 38 :tag("version"):text(prosody.version):up() | 34 |
| 39 :tag("os"):text(version)); | 35 module:hook("iq/host/jabber:iq:version:query", function(event) |
| 36 local stanza = event.stanza; | |
| 37 if stanza.attr.type == "get" and stanza.attr.to == module.host then | |
| 38 event.origin.send(st.reply(stanza):add_child(query)); | |
| 39 return true; | |
| 40 end | 40 end |
| 41 end); | 41 end); |
