Where do I see which events are there and what triggers them?

Hello, I’m very new to this and was going through documentation of prosody to try and understand how events work.

Basically, where do I read about which events can be triggered and when? For example, a user tries to enter a room, I want to hook a function when that happens, what event would that be to put on the hook?

Sorry if this has already been asked before, I did not find it, or if it’s a silly question, I’d just like to have some directions to where to look at.

There is no doc for it

Or get examples from the jitsi-meet plugins, here is the pre-join event

So the only way of knowing the events is by reading existing code?

These events look much different from those “presence/bare”, I thought these were the events. What does it mean then?

Thank you for your reply tho, appreciate the help.

In general, yes. My understanding is that there are standard prosody events which you will see in the docs, but modules that you use or write yourself can also fire custom events. So unless a module maintainer documents the events and keeps it updated, the only way to know all available events is to search in code.

To know what events are trigger when users joins/leaves a room, you can:
a) Look at the source for muc.lib.lua and search for module:fire_event
b) Or, explore prosody-plugins provided by jitsi-meet or by the community, and when you find one that intersects with what you’re trying to build, you can use that as a reference.

For example, when I wanted to build event_sync I pretty much followed the steps above and eventually modelled my implementation after the speaker_stats module.

Thank you for the great answer, I understand now how it is done.

I have one other question, because I’m really new to this.
For example, i have this code:

local log = module._log;

log("info", "Hello world!");
log("info", "*******************************************************************");

module:hook("muc-room-pre-create", function(event)
    log("info", "No pre-create +++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
end, 99);

module:hook("muc-occupant-pre-join", function(event)
	log("info", "No pre-join +++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
end, 99);

The first “hello world” works fine when I start the server, but the events are not being triggered on my testings when I create a room and join it with multiple users. I suppose I have to enable the events(?) in some configuration folder, but I’m not understanding what and where.
(I’m running a local instance on a docker container)

It depends where you have enabled the module. It needs to be under the muc component for the conference.

I guess that is missing. I have this on my logs:

2022-11-22 14:24:14 meet.jitsi:muc_breakout_rooms                                info   Hook to muc events on breakout.meet.jitsi
2022-11-22 14:24:14 meet.jitsi:muc_breakout_rooms                                info   Hook to muc events on muc.meet.jitsi
2022-11-22 14:24:14 general                                                      error  No muc_component specified. No muc to operate on!

Do you have an example of where I specify the muc_component?

This is the muc component:

And this module is loaded for it:

1 Like

Oh I see.

If I put that on my config.cfg.lua file I’ll be getting the hooks to work with such events I’ve mentioned on my example?

Is there a documentation about components and how they work?

Sorry about the maybe obvious questions, but I’m trying to put the basis together on how prosody works and discover for myself the events with debugging and testing.

There prosody documentation is here: Developer Documentation – Prosody IM

Thank you for the previous example. I managed to make it work with it.

Can you show me the github with the code where custom prosody events like “muc-occupant-joined”, “muc-occupant-left” are defined? I’d like to understand how they are differentiated and what the base events look like.

Search there ^

1 Like

Oh! Thanks again, now I get it why you told me to search for fire_event… Amazing.

Have a nice weekend!

One last question.

Where in the code would this function be fired?

This is not an event that is fired, but a function to the room executed when a presence is received in this room.