plugins/resolvejid.lua

Sun, 20 May 2018 03:14:32 +0200

author
Kim Alvefur <zash@zash.se>
date
Sun, 20 May 2018 03:14:32 +0200
changeset 142
211fa13c7ca2
parent 105
4234c8789cc6
permissions
-rw-r--r--

riddim.plugins.pubsub2room: Don't create an invalid stanza with an empty name

Caught by sanity checks in util.stanza from Prosody trunk

function riddim.plugins.resolvejid(bot)
	function bot:resolvejid(jid, room)
		local nows = jid:match"%S+"
		local trimd = jid:match"^%s*(.-)%s*$"
		if room then
			local occupant = room.occupants[jid]
			or room.occupants[trimd]
			or room.occupants[nows]
			if occupant then return occupant.jid end
		end
		return nows
	end
end

mercurial