Some variables do not change during runtime
This commit is contained in:
parent
cb6dde19e5
commit
a6707a0816
20
init.lua
20
init.lua
@ -34,11 +34,14 @@ local http = core.request_http_api()
|
||||
|
||||
assert(http, "[MOD] yl_matterbridge: Please add yl_matterbridge to secure.http_mods")
|
||||
|
||||
local post_headers = {"Content-Type: application/json"}
|
||||
if token and token ~= "" then
|
||||
table.insert(post_headers, "Authorization: Bearer " .. token)
|
||||
end
|
||||
local url_send = "http://" .. address .. ":" .. port .. "/api/message"
|
||||
local url_receive = "http://" .. address .. ":" .. port .. "/api/messages"
|
||||
|
||||
function send(user_name, message_text)
|
||||
local url = "http://" .. address .. ":" .. port .. "/api/message"
|
||||
local post_headers = {"Content-Type: application/json"}
|
||||
if token and token ~= "" then table.insert(post_headers,"Authorization: Bearer "..token) end
|
||||
core.log("action", "[MOD] yl_matterbridge : Posted " .. dump(post_headers))
|
||||
local timeout = 10
|
||||
local data = {
|
||||
text = message_text,
|
||||
@ -48,7 +51,7 @@ function send(user_name, message_text)
|
||||
|
||||
http.fetch(
|
||||
{
|
||||
url = url,
|
||||
url = url_send,
|
||||
extra_headers = post_headers,
|
||||
timeout = timeout,
|
||||
post_data = core.write_json(data)
|
||||
@ -67,14 +70,11 @@ function send(user_name, message_text)
|
||||
end
|
||||
|
||||
local function receive()
|
||||
local url = "http://" .. address .. ":" .. port .. "/api/messages"
|
||||
local post_headers = {"Content-Type: application/json"}
|
||||
if token and token ~= "" then table.insert(post_headers,"Authorization: Bearer "..token) end
|
||||
local timeout = 0
|
||||
|
||||
http.fetch(
|
||||
{
|
||||
url = url,
|
||||
url = url_receive,
|
||||
extra_headers = post_headers,
|
||||
timeout = timeout
|
||||
},
|
||||
@ -100,7 +100,7 @@ end
|
||||
-- Don't forget to add an optional dependency to yl_matterbridge
|
||||
|
||||
function yl_matterbridge.receive_from_bridge(user_name, message_text, account_name)
|
||||
core.chat_send_all("<"..account_name.."|" .. user_name .. "> " .. message_text)
|
||||
core.chat_send_all("<" .. account_name .. "|" .. user_name .. "> " .. message_text)
|
||||
end
|
||||
|
||||
function yl_matterbridge.send_to_bridge(user_name, message_text)
|
||||
|
Loading…
Reference in New Issue
Block a user