Make send and receive overwriteable
This commit is contained in:
parent
da66fd0654
commit
fe0be3e170
35
init.lua
35
init.lua
@ -20,13 +20,6 @@ yl_matterbridge.information.license = "MIT"
|
|||||||
yl_matterbridge.information.name = "yl_matterbridge"
|
yl_matterbridge.information.name = "yl_matterbridge"
|
||||||
yl_matterbridge.information.additional = "Additional information"
|
yl_matterbridge.information.additional = "Additional information"
|
||||||
|
|
||||||
-- API
|
|
||||||
-- Overwrite this function to grab the
|
|
||||||
|
|
||||||
function yl_matterbridge.publish_to_chat(username,text)
|
|
||||||
core.chat_send_all("<"..v.username.."@irc> "..v.text)
|
|
||||||
end
|
|
||||||
|
|
||||||
local address = minetest.settings:get("yl_matterbridge.address") or false
|
local address = minetest.settings:get("yl_matterbridge.address") or false
|
||||||
local port = minetest.settings:get("yl_matterbridge.port") or false
|
local port = minetest.settings:get("yl_matterbridge.port") or false
|
||||||
local gateway = minetest.settings:get("yl_matterbridge.gateway") or false
|
local gateway = minetest.settings:get("yl_matterbridge.gateway") or false
|
||||||
@ -64,13 +57,7 @@ function send(user_name, message_text)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_chat_message(
|
local function receive(dtime)
|
||||||
function(user_name, message_text)
|
|
||||||
send(user_name, message_text)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
local gs = function(dtime)
|
|
||||||
local url = "http://" .. address .. ":" .. port .. "/api/messages"
|
local url = "http://" .. address .. ":" .. port .. "/api/messages"
|
||||||
local timeout = 0
|
local timeout = 0
|
||||||
|
|
||||||
@ -96,7 +83,25 @@ local gs = function(dtime)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(gs)
|
-- API
|
||||||
|
-- Overwrite these function in your chat mod, if you want to govern sending and receveiving yourself
|
||||||
|
-- Don't forget to add an optional dependency to yl_matterbridge
|
||||||
|
|
||||||
|
function yl_matterbridge.publish_to_chat(user_name,message_text)
|
||||||
|
core.chat_send_all("<"..user_name.."@irc> "..message_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
function yl_matterbridge.send_to_bridge(user_name,message_text)
|
||||||
|
send(user_name, message_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- connect to Minetest
|
||||||
|
|
||||||
|
minetest.register_on_chat_message(
|
||||||
|
yl_matterbridge.send_to_bridge
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_globalstep(receive)
|
||||||
|
|
||||||
local mod_end_time = (core.get_us_time() - mod_start_time) / 1000000
|
local mod_end_time = (core.get_us_time() - mod_start_time) / 1000000
|
||||||
core.log("action", "[MOD] yl_matterbridge loaded in [" .. mod_end_time .. "s]")
|
core.log("action", "[MOD] yl_matterbridge loaded in [" .. mod_end_time .. "s]")
|
||||||
|
Loading…
Reference in New Issue
Block a user