MUC

This is general documentation for developers wanting to interface with Prosody's MUC module.

Loading modules

It is recommended that MUC-focused modules are loaded directly onto the appropriate host by the user. This means they cannot go in the global modules_enabled list, because those modules get loaded for all VirtualHosts, but not Components.

The correct config would look like:

Hooking/filtering messages

This is easy, as MUC messages fire the standard stanza events. As per XEP-0045 room messages are sent to the room's bare JID, so they trigger "message/bare". Private messages between occupants go to full JIDs, and you can get those with "message/full". Other stanza types are allowed too.

Accessing room data

mod_muc has a room object for each room to hold data and methods. You can access the room list this way:

Your module will automatically be reloaded or unloaded if mod_muc is.

The rooms table has an entry for each room's bare JID, and the value is the room object.

Config forms

You can add an item to the room's configuration form by hooking the "muc-config-form" event, which receives a util.dataforms object. When (and if) the form is submitted by the user, the "muc-config-submitted" event is fired, which receives the values extracted from the submitted form.

If the config has changed, you must let mod_muc know, so that it can notify the user according to XEP-0045. Simply set event.changed = true for this.