comparison mod_csi_muc_priorities/mod_csi_muc_priorities.lua @ 3533:d8c4543f1b19

mod_csi_muc_priorities: Remove dependency on mod_track_muc_joins Load it manually to enable mention support.
author Kim Alvefur <zash@zash.se>
date Mon, 01 Apr 2019 08:07:41 +0200
parents 85c357b69eec
children 700340b57851
comparison
equal deleted inserted replaced
3532:85c357b69eec 3533:d8c4543f1b19
1 local jid = require "util.jid"; 1 local jid = require "util.jid";
2
3 module:depends"track_muc_joins"
4 2
5 module:hook("csi-is-stanza-important", function (event) 3 module:hook("csi-is-stanza-important", function (event)
6 local stanza, session = event.stanza, event.session; 4 local stanza, session = event.stanza, event.session;
7 if stanza.name == "message" then 5 if stanza.name == "message" then
8 if stanza.attr.type == "groupchat" then 6 if stanza.attr.type == "groupchat" then
9 local body = stanza:get_child_text("body"); 7 local body = stanza:get_child_text("body");
10 if not body then return end 8 if not body then return end
11 9
12 local rooms = session.rooms_joined; 10 local rooms = session.rooms_joined;
13 if not rooms then return false; end 11 if not rooms then return; end
14 12
15 -- TODO optional?
16 local room_nick = rooms[jid.bare(stanza.attr.from)]; 13 local room_nick = rooms[jid.bare(stanza.attr.from)];
17 if room_nick and body:find(room_nick, 1, true) then return true; end 14 if room_nick and body:find(room_nick, 1, true) then return true; end
18 15
19 return false; 16 return false;
20 end 17 end