Mercurial > prosody-modules
changeset 3532:85c357b69eec
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 01 Apr 2019 00:15:13 +0200 |
parents | 3bece2db869c |
children | d8c4543f1b19 |
files | mod_csi_muc_priorities/mod_csi_muc_priorities.lua |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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); +