view plugins/mod_welcome.lua @ 14020:3c2bfa6a69df

prosodyctl shell: Move non-error result lines back to stdout, suppress with --quiet We're figuring out how to keep usability and support machine-readability too. We moved the status line (repl-result) to stderr so that when parsing something like a table, it didn't get in the way. However sometimes the status line is the thing we want to parse (e.g. invite creation). Parsing stderr loses one of the purposes of stderr - to have an error-only channel to emit stuff out of band (such as error messages). So the new approach is: - Status line on stdout, unless it's an error - If you're parsing the output ("content") of the command, pass --quiet to suppress the status line.
author Matthew Wild <mwild1@gmail.com>
date Tue, 30 Dec 2025 16:30:43 +0000
parents 74b9e05af71e
children
line wrap: on
line source

-- Prosody IM
-- Copyright (C) 2008-2010 Matthew Wild
-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--

local host = module:get_host();
local welcome_text = module:get_option_string("welcome_message", "Hello $username, welcome to the $host IM server!");

local st = require "prosody.util.stanza";

module:hook("user-registered",
	function (user)
		local welcome_stanza =
			st.message({ to = user.username.."@"..user.host, from = host },
				welcome_text:gsub("$(%w+)", user));
		module:send(welcome_stanza);
		module:log("debug", "Welcomed user %s@%s", user.username, user.host);
	end);