Software /
code /
prosody-modules
Changeset
3417:1534d0715d35
mod_muc_limits: Add support for new MUC API in Prosody 0.11
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 23 Dec 2018 21:46:06 +0100 |
parents | 3416:c6dd65354db0 |
children | 3418:9be9dd434813 |
files | mod_muc_limits/README.markdown mod_muc_limits/mod_muc_limits.lua |
diffstat | 2 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_muc_limits/README.markdown Sun Dec 23 18:33:32 2018 +0100 +++ b/mod_muc_limits/README.markdown Sun Dec 23 21:46:06 2018 +0100 @@ -66,13 +66,13 @@ Compatibility ============= - ------- --------------------------------------------------------------------------------- - trunk Doesn't work since [0ebc7ff1fff5](https://hg.prosody.im/trunk/rev/0ebc7ff1fff5) - 0.11 Doesn't work + ------- ------------------ + trunk Works + 0.11 Works 0.10 Works 0.9 Works 0.8 Doesn't work[^1] - ------- --------------------------------------------------------------------------------- + ------- ------------------ [^1]: This module can be made to work in 0.8 (and *maybe* previous versions) of Prosody by copying the new
--- a/mod_muc_limits/mod_muc_limits.lua Sun Dec 23 18:33:32 2018 +0100 +++ b/mod_muc_limits/mod_muc_limits.lua Sun Dec 23 21:46:06 2018 +0100 @@ -1,9 +1,6 @@ local mod_muc = module:depends"muc"; local rooms = rawget(mod_muc, "rooms"); -- Old MUC API -if not rooms then - error "Not compatible with 0.11 MUC API" -end local jid_split, jid_bare = require "util.jid".split, require "util.jid".bare; local st = require "util.stanza"; @@ -31,7 +28,7 @@ return; end local dest_room, dest_host, dest_nick = jid_split(stanza.attr.to); - local room = rooms[dest_room.."@"..dest_host]; + local room = event.room or rooms[dest_room.."@"..dest_host]; if not room then return; end local from_jid = stanza.attr.from; local occupant = room._occupants[room._jid_nick[from_jid]]; @@ -82,7 +79,13 @@ end end -module:hook("message/bare", handle_stanza, 501); -module:hook("message/full", handle_stanza, 501); -module:hook("presence/bare", handle_stanza, 501); -module:hook("presence/full", handle_stanza, 501); +if rooms then + module:hook("message/bare", handle_stanza, 501); + module:hook("message/full", handle_stanza, 501); + module:hook("presence/bare", handle_stanza, 501); + module:hook("presence/full", handle_stanza, 501); +else + module:hook("muc-occupant-pre-join", handle_stanza); + module:hook("muc-occupant-pre-change", handle_stanza); + module:hook("muc-occupant-groupchat", handle_stanza); +end