Software / code / prosody-modules
Comparison
mod_pubsub_text_interface/mod_pubsub_text_interface.lua @ 3250:5801b5cf8f54
mod_pubsub_text_interface: Ignore whitespace after all commands
Case insensitivity only on command name, not the node
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 20 Aug 2018 23:20:01 +0200 |
| parent | 3249:8f4a7084c466 |
| child | 3293:f728c8c42860 |
comparison
equal
deleted
inserted
replaced
| 3249:8f4a7084c466 | 3250:5801b5cf8f54 |
|---|---|
| 17 | 17 |
| 18 module:hook("message/host", function (event) | 18 module:hook("message/host", function (event) |
| 19 local origin, stanza = event.origin, event.stanza; | 19 local origin, stanza = event.origin, event.stanza; |
| 20 local body = stanza:get_child_text("body"); | 20 local body = stanza:get_child_text("body"); |
| 21 if not body then return end -- bail out | 21 if not body then return end -- bail out |
| 22 body = body:lower(); | |
| 23 | 22 |
| 24 local from = stanza.attr.from; | 23 local from = stanza.attr.from; |
| 25 | 24 |
| 26 local reply = st.reply(stanza); | 25 local reply = st.reply(stanza); |
| 27 reply.attr.id = id.medium(); | 26 reply.attr.id = id.medium(); |
| 28 | 27 |
| 29 local command, node_arg = body:match("^(%a+)%s+(.*)"); | 28 local command, node_arg = body:match("^(%a+)%s+(.*)"); |
| 29 command = (command or body):lower(); | |
| 30 | 30 |
| 31 if body == "help" then | 31 if command == "help" then |
| 32 reply:body(help); | 32 reply:body(help); |
| 33 elseif body == "list" then | 33 elseif command == "list" then |
| 34 local ok, nodes = pubsub:get_nodes(from); | 34 local ok, nodes = pubsub:get_nodes(from); |
| 35 if ok then | 35 if ok then |
| 36 local list = {}; | 36 local list = {}; |
| 37 for node, node_obj in pairs(nodes) do | 37 for node, node_obj in pairs(nodes) do |
| 38 table.insert(list, ("- `%s` %s"):format(node, node_obj.config.title or "")); | 38 table.insert(list, ("- `%s` %s"):format(node, node_obj.config.title or "")); |