# HG changeset patch # User Kim Alvefur # Date 1484871911 -3600 # Node ID 56bab95e57f04d578cc53db1f15077b65e105cb9 # Parent 36ffe9d1113232efe41aa4fd0bb019d9c6828b50 mod_candy: If no room list is set, try to find a MUC domain and guess a room name of 'candy' diff -r 36ffe9d11132 -r 56bab95e57f0 mod_candy/README.markdown --- a/mod_candy/README.markdown Fri Jan 20 01:24:32 2017 +0100 +++ b/mod_candy/README.markdown Fri Jan 20 01:25:11 2017 +0100 @@ -32,7 +32,9 @@ You can configure what rooms to join using either `candy_rooms` (an array) or [mod\_default\_bookmarks]. By default, Candy will attempt to -join rooms that the current user has bookmarked. If there are no rooms +join rooms that the current user has bookmarked. +If `candy_rooms` is not set, mod\_candy will attempt to find a MUC +component and join a room called "candy" there. If there are no rooms to join, then Candy will show an emtpy screen. Compatibility diff -r 36ffe9d11132 -r 56bab95e57f0 mod_candy/mod_candy.lua --- a/mod_candy/mod_candy.lua Fri Jan 20 01:24:32 2017 +0100 +++ b/mod_candy/mod_candy.lua Fri Jan 20 01:25:11 2017 +0100 @@ -2,6 +2,7 @@ -- Copyright (C) 2013-2017 Kim Alvefur local json_encode = require"util.json".encode; +local get_host_children = require "core.hostmanager".get_children; local is_module_loaded = require "core.modulemanager".is_loaded; local serve = module:depends"http_files".serve; @@ -13,6 +14,13 @@ -- Configured room list, if any return candy_rooms; end + for subdomain in pairs(get_host_children(module.host)) do + -- Attempt autodetect a MUC host + if is_module_loaded(subdomain, "muc") then + return { "candy@" .. subdomain } + end + end + -- Autojoin bookmarks then? -- Check out mod_default_bookmarks return true; end