Software /
code /
prosody-modules
Comparison
mod_csi_muc_priorities/mod_csi_muc_priorities.lua @ 3534:700340b57851
mod_csi_muc_priorities: Break out room jid into a variable
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 01 Apr 2019 08:21:57 +0200 |
parent | 3533:d8c4543f1b19 |
child | 3535:bcb0eb9121a9 |
comparison
equal
deleted
inserted
replaced
3533:d8c4543f1b19 | 3534:700340b57851 |
---|---|
1 local jid = require "util.jid"; | 1 local jid_bare = require "util.jid".bare; |
2 | 2 |
3 module:hook("csi-is-stanza-important", function (event) | 3 module:hook("csi-is-stanza-important", function (event) |
4 local stanza, session = event.stanza, event.session; | 4 local stanza, session = event.stanza, event.session; |
5 if stanza.name == "message" then | 5 if stanza.name == "message" then |
6 if stanza.attr.type == "groupchat" then | 6 if stanza.attr.type == "groupchat" then |
7 local body = stanza:get_child_text("body"); | 7 local body = stanza:get_child_text("body"); |
8 if not body then return end | 8 if not body then return end |
9 | 9 |
10 local room_jid = jid_bare(stanza.attr.from); | |
11 | |
10 local rooms = session.rooms_joined; | 12 local rooms = session.rooms_joined; |
11 if not rooms then return; end | 13 if not rooms then return; end |
12 | 14 |
13 local room_nick = rooms[jid.bare(stanza.attr.from)]; | 15 local room_nick = rooms[room_jid]; |
14 if room_nick and body:find(room_nick, 1, true) then return true; end | 16 if room_nick and body:find(room_nick, 1, true) then return true; end |
15 | 17 |
16 return false; | 18 return false; |
17 end | 19 end |
18 end | 20 end |