From e0af191eb76fe91fa9137cf8763b93fcaae95f63 Mon Sep 17 00:00:00 2001 From: acmgit Date: Fri, 25 Feb 2022 19:50:37 +0100 Subject: [PATCH] Support for smart_chat added. --- init.lua | 28 ++++++++++++++++++++++++---- mod.conf | 3 +++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 mod.conf diff --git a/init.lua b/init.lua index 35fa3e8..94c7d1f 100644 --- a/init.lua +++ b/init.lua @@ -21,11 +21,31 @@ yl_matterbridge.information.name = "yl_matterbridge" yl_matterbridge.information.additional = "Additional information" -- API --- Overwrite this function to grab the +-- Overwrite this function to grab the -function yl_matterbridge.publish_to_chat(username,text) - core.chat_send_all("<"..v.username.."@irc> "..v.text) -end +if(minetest.global_exists(sc)) then + function yl_matterbridge.publish_to_chat(username, text) + local all_player = minetest.get_connected_players() + for _, player in pairs(all_player) do + local pname = players:get_player_name() + if(pname ~= username) then -- Don't send to yourself + if(channel == nil) then -- Is player in the public channel? + minetest.chat_send_player(pname, "<" .. username .. "> " .. text) + + end -- if(channel + + end -- if(pname + + end -- for _,player + + end -- function yl_matterbridge + +else + function yl_matterbridge.publish_to_chat(username,text) + core.chat_send_all("<"..v.username.."@irc> "..v.text) + end + +end -- if(minetest.global_exists( local address = minetest.settings:get("yl_matterbridge.address") or false local port = minetest.settings:get("yl_matterbridge.port") or false diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..2771db2 --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name = yl_matterbridge +author = AliasAlreadyTaken +optional_dependence = smart_chat