plugins/mod_muc_unique.lua
author Matthew Wild <mwild1@gmail.com>
Fri, 07 Apr 2023 12:47:24 +0100
changeset 13052 946442df65d3
parent 12981 74b9e05af71e
permissions -rw-r--r--
util.human.io: table: Return determined width as a second result This allows callers to adjust other things based on the width of the rows (such as header lines).

-- XEP-0307: Unique Room Names for Multi-User Chat
local st = require "prosody.util.stanza";
local unique_name = require "prosody.util.id".medium;
module:add_feature "http://jabber.org/protocol/muc#unique"
module:hook("iq-get/host/http://jabber.org/protocol/muc#unique:unique", function(event)
	local origin, stanza = event.origin, event.stanza;
	origin.send(st.reply(stanza)
		:tag("unique", {xmlns = "http://jabber.org/protocol/muc#unique"})
		:text(unique_name():lower())
	);
	return true;
end,-1);