Search code examples
luaprosody-im

LUA - Calling function from other module without exporting table


I try to setup a special behavior with Jitsi, but have not that much LUA knowlege.

A Jitsi/Prosody module "mod_muc_lobby_rooms.lua" is implementing some function like handle_create_lobby(event);. handle_create_lobby is calling other sub-function from inside.

https://github.com/jitsi/jitsi-meet/blob/master/resources/prosody-plugins/mod_muc_lobby_rooms.lua

But the module itself is not a library module, so no table is exported and another code can use "require". So my understanding from LUA yet.

For a own module, I just want use this functions from the other side, without reimplement or copy/paste it.

Is there any solution, how I can "source" the function into my module?

If possible, I want let "mod_muc_lobby_room.lua" unchanged, if some updates from Jitsi are coming.

Thanks in advance.

A lua beginner, Uwe


Solution

  • You can fire an event because it listen for it.

    prosody.events.fire_event("create-lobby-room", event)
    

    Or you can use the module function like this:

    local muc_lobby_rooms = module:depends("muc_lobby_rooms");
    muc_lobby_rooms.handle_create_lobby(event);