Software /
code /
prosody-modules
Comparison
mod_candy/mod_candy.lua @ 2450:36ffe9d11132
mod_candy: Add config option for a list of rooms to join
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 20 Jan 2017 01:24:32 +0100 |
parent | 2449:c9372cfac3b7 |
child | 2451:56bab95e57f0 |
comparison
equal
deleted
inserted
replaced
2449:c9372cfac3b7 | 2450:36ffe9d11132 |
---|---|
3 | 3 |
4 local json_encode = require"util.json".encode; | 4 local json_encode = require"util.json".encode; |
5 local is_module_loaded = require "core.modulemanager".is_loaded; | 5 local is_module_loaded = require "core.modulemanager".is_loaded; |
6 | 6 |
7 local serve = module:depends"http_files".serve; | 7 local serve = module:depends"http_files".serve; |
8 | |
9 local candy_rooms = module:get_option_array("candy_rooms"); | |
10 | |
11 local function get_autojoin() | |
12 if candy_rooms then | |
13 -- Configured room list, if any | |
14 return candy_rooms; | |
15 end | |
16 -- Check out mod_default_bookmarks | |
17 return true; | |
18 end | |
8 | 19 |
9 local function get_connect_path() | 20 local function get_connect_path() |
10 if is_module_loaded(module.host, "websocket") then | 21 if is_module_loaded(module.host, "websocket") then |
11 return module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws"); | 22 return module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws"); |
12 end | 23 end |
23 | 34 |
24 return ("// Generated by Prosody\n" | 35 return ("// Generated by Prosody\n" |
25 .."var Prosody = %s;\n") | 36 .."var Prosody = %s;\n") |
26 :format(json_encode({ | 37 :format(json_encode({ |
27 connect_path = get_connect_path(); | 38 connect_path = get_connect_path(); |
39 autojoin = get_autojoin(); | |
28 version = prosody.version; | 40 version = prosody.version; |
29 host = module:get_host(); | 41 host = module:get_host(); |
30 anonymous = module:get_option_string("authentication") == "anonymous"; | 42 anonymous = module:get_option_string("authentication") == "anonymous"; |
31 })); | 43 })); |
32 end; | 44 end; |