Software /
code /
prosody-modules
Comparison
mod_pubsub_text_interface/mod_pubsub_text_interface.lua @ 3249:8f4a7084c466
mod_pubsub_text_interface: Rename variable to avoid name clash [luacheck]
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 20 Aug 2018 23:18:43 +0200 |
parent | 3248:ecec46f7d020 |
child | 3250:5801b5cf8f54 |
comparison
equal
deleted
inserted
replaced
3248:ecec46f7d020 | 3249:8f4a7084c466 |
---|---|
24 local from = stanza.attr.from; | 24 local from = stanza.attr.from; |
25 | 25 |
26 local reply = st.reply(stanza); | 26 local reply = st.reply(stanza); |
27 reply.attr.id = id.medium(); | 27 reply.attr.id = id.medium(); |
28 | 28 |
29 local command, node = body:match("^(%a+)%s+(.*)"); | 29 local command, node_arg = body:match("^(%a+)%s+(.*)"); |
30 | 30 |
31 if body == "help" then | 31 if body == "help" then |
32 reply:body(help); | 32 reply:body(help); |
33 elseif body == "list" then | 33 elseif body == "list" then |
34 local ok, nodes = pubsub:get_nodes(from); | 34 local ok, nodes = pubsub:get_nodes(from); |
40 reply:body(table.concat(list, "\n")); | 40 reply:body(table.concat(list, "\n")); |
41 else | 41 else |
42 reply:body(nodes); | 42 reply:body(nodes); |
43 end | 43 end |
44 elseif command == "subscribe" then | 44 elseif command == "subscribe" then |
45 local ok, err = pubsub:add_subscription(node, from, jid.bare(from), { ["pubsub#include_body"] = true }); | 45 local ok, err = pubsub:add_subscription(node_arg, from, jid.bare(from), { ["pubsub#include_body"] = true }); |
46 reply:body(ok and "OK" or err); | 46 reply:body(ok and "OK" or err); |
47 elseif command == "unsubscribe" then | 47 elseif command == "unsubscribe" then |
48 local ok, err = pubsub:remove_subscription(node, from, jid.bare(from)); | 48 local ok, err = pubsub:remove_subscription(node_arg, from, jid.bare(from)); |
49 reply:body(ok and "OK" or err); | 49 reply:body(ok and "OK" or err); |
50 else | 50 else |
51 reply:body("Unknown command. `help` to list commands."); | 51 reply:body("Unknown command. `help` to list commands."); |
52 end | 52 end |
53 origin.send(reply); | 53 origin.send(reply); |