# HG changeset patch # User Kim Alvefur # Date 1545597966 -3600 # Node ID 1534d0715d354ee2de9bbdddb59227c3f719becc # Parent c6dd65354db06869af5d879ec6e654e674748380 mod_muc_limits: Add support for new MUC API in Prosody 0.11 diff -r c6dd65354db0 -r 1534d0715d35 mod_muc_limits/README.markdown --- 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 diff -r c6dd65354db0 -r 1534d0715d35 mod_muc_limits/mod_muc_limits.lua --- 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