mod_csi_muc_priorities/mod_csi_muc_priorities.lua
author Kim Alvefur <zash@zash.se>
Mon, 01 Apr 2019 08:07:41 +0200
changeset 3537 d8c4543f1b19
parent 3536 85c357b69eec
child 3538 700340b57851
permissions -rw-r--r--
mod_csi_muc_priorities: Remove dependency on mod_track_muc_joins Load it manually to enable mention support.

local jid = require "util.jid";

module:hook("csi-is-stanza-important", function (event)
	local stanza, session = event.stanza, event.session;
	if stanza.name == "message" then
		if stanza.attr.type == "groupchat" then
			local body = stanza:get_child_text("body");
			if not body then return end

			local rooms = session.rooms_joined;
			if not rooms then return; end

			local room_nick = rooms[jid.bare(stanza.attr.from)];
			if room_nick and body:find(room_nick, 1, true) then return true; end

			return false;
		end
	end
end);