LUA - Calling function from other module without exporting table

421 Views Asked by At

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

2

There are 2 best solutions below

1
L3opold On BEST ANSWER

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);
1
Artur Bieniek On

You can do it like that:

file=io.open("mod_muc_lobby_room.lua")
io.input(file)
load(io.read("*a"))()
io.close(file)

And the code located in mod_muc_lobby_room.lua will be executed.