plugins/resolvejid.lua

Sun, 05 Dec 2021 18:35:18 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 05 Dec 2021 18:35:18 +0000
changeset 164
69b508f132b5
parent 105
4234c8789cc6
permissions
-rw-r--r--

Import util.hashes from Prosody

This gives us a wider selection of hashes, including SHA256

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