Annotate

mod_csi_muc_priorities/mod_csi_muc_priorities.lua @ 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
child 3533:d8c4543f1b19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3532
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local jid = require "util.jid";
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 module:depends"track_muc_joins"
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 module:hook("csi-is-stanza-important", function (event)
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 local stanza, session = event.stanza, event.session;
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 if stanza.name == "message" then
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 if stanza.attr.type == "groupchat" then
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 local body = stanza:get_child_text("body");
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 if not body then return end
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 local rooms = session.rooms_joined;
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 if not rooms then return false; end
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 -- TODO optional?
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 local room_nick = rooms[jid.bare(stanza.attr.from)];
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 if room_nick and body:find(room_nick, 1, true) then return true; end
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 return false;
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 end
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 end
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 end);
85c357b69eec mod_csi_muc_priorities: Reduce importance of group chat messages
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23