# HG changeset patch # User Kim Alvefur # Date 1554070513 -7200 # Node ID 85c357b69eecdc52028cdd3dcb415122c158b9ee # Parent 3bece2db869c4647f602ff1f32e3a6f0b8dcc69b mod_csi_muc_priorities: Reduce importance of group chat messages This helps if you are in more noisy public channels than small private group chats. The short term plan is to give users the ability to set MUC JIDs as either high or low priority and use that. Long term it would be great to be able to automatically classify MUCs as public channels vs private group chats. diff -r 3bece2db869c -r 85c357b69eec mod_csi_muc_priorities/mod_csi_muc_priorities.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_csi_muc_priorities/mod_csi_muc_priorities.lua Mon Apr 01 00:15:13 2019 +0200 @@ -0,0 +1,23 @@ +local jid = require "util.jid"; + +module:depends"track_muc_joins" + +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 false; end + + -- TODO optional? + 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); +