Mercurial > prosody-modules
comparison mod_candy/mod_candy.lua @ 2451:56bab95e57f0
mod_candy: If no room list is set, try to find a MUC domain and guess a room name of 'candy'
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 20 Jan 2017 01:25:11 +0100 |
parents | 36ffe9d11132 |
children | f36a6dcc05ef |
comparison
equal
deleted
inserted
replaced
2450:36ffe9d11132 | 2451:56bab95e57f0 |
---|---|
1 -- mod_candy.lua | 1 -- mod_candy.lua |
2 -- Copyright (C) 2013-2017 Kim Alvefur | 2 -- Copyright (C) 2013-2017 Kim Alvefur |
3 | 3 |
4 local json_encode = require"util.json".encode; | 4 local json_encode = require"util.json".encode; |
5 local get_host_children = require "core.hostmanager".get_children; | |
5 local is_module_loaded = require "core.modulemanager".is_loaded; | 6 local is_module_loaded = require "core.modulemanager".is_loaded; |
6 | 7 |
7 local serve = module:depends"http_files".serve; | 8 local serve = module:depends"http_files".serve; |
8 | 9 |
9 local candy_rooms = module:get_option_array("candy_rooms"); | 10 local candy_rooms = module:get_option_array("candy_rooms"); |
11 local function get_autojoin() | 12 local function get_autojoin() |
12 if candy_rooms then | 13 if candy_rooms then |
13 -- Configured room list, if any | 14 -- Configured room list, if any |
14 return candy_rooms; | 15 return candy_rooms; |
15 end | 16 end |
17 for subdomain in pairs(get_host_children(module.host)) do | |
18 -- Attempt autodetect a MUC host | |
19 if is_module_loaded(subdomain, "muc") then | |
20 return { "candy@" .. subdomain } | |
21 end | |
22 end | |
23 -- Autojoin bookmarks then? | |
16 -- Check out mod_default_bookmarks | 24 -- Check out mod_default_bookmarks |
17 return true; | 25 return true; |
18 end | 26 end |
19 | 27 |
20 local function get_connect_path() | 28 local function get_connect_path() |