More logs ..
This commit is contained in:
parent
1ec1ba186a
commit
76d2058fd4
@ -65,13 +65,13 @@ sc.registered_commands[cname] = function(player, parameter)
|
||||
line = "[" .. player .. "@" .. sc.servername .. "] " .. message
|
||||
if(sc.irc_on) then
|
||||
all_send_to_irc(line)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module cmd_all : [IRC] " .. line)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " :Module cmd_all: [IRC] " .. line)
|
||||
|
||||
end -- if(sc.irc_on)
|
||||
|
||||
if(sc.matterbridge) then
|
||||
all_send_to_bridge(player, line)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module cmd_all : [matterbridge]" .. line)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module cmd_all: [Matterbridge] " .. line)
|
||||
|
||||
end -- if(sc.matterbridge
|
||||
|
||||
@ -83,13 +83,13 @@ sc.registered_commands[cname] = function(player, parameter)
|
||||
line = "[" .. player .. "@" .. sc.servername .. "] " .. message
|
||||
if(sc.irc_on) then
|
||||
all_send_to_irc(line)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module cmd_all : [IRC] " .. line)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module cmd_all: [IRC] " .. line)
|
||||
|
||||
end -- if(sc.irc_on)
|
||||
|
||||
if(sc.matterbridge) then
|
||||
all_send_to_bridge(player, line)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module cmd_all : [matterbridge] " .. line)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module cmd_all [Matterbridge] " .. line)
|
||||
|
||||
end -- if(matterbridge
|
||||
|
||||
|
@ -67,14 +67,13 @@ sc.registered_commands[cname] = function(player, parameter)
|
||||
line = "[" .. player .. "@" .. sc.servername .. "]" .. message
|
||||
if(sc.irc_on) then
|
||||
all_send_to_irc(line)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module talk2public: <" .. player
|
||||
.. "@" .. sc.servername .. "> " .. line)
|
||||
minetest.log("action", "[MOD] .. " .. sc.modname .. " : Module cmd_talk2public : " .. line)
|
||||
|
||||
end
|
||||
|
||||
if(sc.matterbridge) then
|
||||
all_send_to_bridge(player, line)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module talk2public: [Matterbridge] " .. line)
|
||||
minetest.log("action", "[MOD] .. " .. sc.modname .. " : Module cmd_talk2public : [Matterbridge] " .. line)
|
||||
|
||||
end -- if(matterbridge)
|
||||
|
||||
|
31
core.lua
31
core.lua
@ -3,10 +3,6 @@ local S = sc.S
|
||||
|
||||
sc.crlf = "\r\n"
|
||||
|
||||
-- Function forwarding
|
||||
sc.send_2_irc = function() return end
|
||||
sc.send_2_matterbridge = function() return end
|
||||
|
||||
minetest.register_on_chat_message(function(player, message)
|
||||
|
||||
if(player ~= "" or player ~= nil) then
|
||||
@ -26,35 +22,22 @@ end) -- register_on_chatmessage()
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local playername = player:get_player_name()
|
||||
local message = "*** joins the World."
|
||||
local line = "*** <" .. playername .. "@" .. sc.servername .. "> " .. message
|
||||
local message = "joins the World."
|
||||
playername = playername or S("unknown")
|
||||
|
||||
sc.send_2_irc(playername, line)
|
||||
sc.send_2_irc(playername, "*** " ..message)
|
||||
sc.player[playername] = nil -- the public Chat
|
||||
sc.public[playername] = nil
|
||||
if(sc.matterbridge) then
|
||||
sc.send_2_matterbridge(playername, message)
|
||||
|
||||
end -- if(sc.matterbridge
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module core: <" .. playername
|
||||
.. "@" .. sc.servername .. "> *** joins the World)")
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module core: *** " .. message)
|
||||
end) -- register_on_joinplayer()
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local playername = player:get_player_name() or S("unknown")
|
||||
local line = "*** <" .. playername .. "@" .. sc.modname .. "> leaves the World."
|
||||
local line = "leaves the World."
|
||||
|
||||
sc.player[playername] = nil
|
||||
sc.public[playername] = nil
|
||||
sc.send_2_irc(playername, line)
|
||||
if(sc.matterbridge) then
|
||||
sc.send_2_matterbridge(playername, "*** leaves the World.")
|
||||
|
||||
end -- if(sc.matterbridge
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module core: <" .. playername
|
||||
.. "@" .. sc.servername .. "> *** leaves the World)")
|
||||
sc.send_2_irc(playername, "*** " .. line .. ".")
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module core: *** " .. line)
|
||||
end) -- minetest.register_on_leaveplayer
|
||||
|
||||
|
21
init.lua
21
init.lua
@ -60,16 +60,7 @@ else
|
||||
|
||||
end
|
||||
|
||||
if(minetest.get_modpath("yl_matterbridge") == nil) then
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Init: yl_matterbridge not available.")
|
||||
sc.matterbridge = false
|
||||
sc.matterbridge_irc = false
|
||||
|
||||
else
|
||||
if(sc.matterbridge_irc) then sc.irc_on = false end
|
||||
|
||||
end
|
||||
|
||||
if((sc.matterbridge_irc) and (sc.matterbridge)) then sc.irc_on = false end
|
||||
|
||||
if (sc.irc_on) then
|
||||
|
||||
@ -78,13 +69,13 @@ if (sc.irc_on) then
|
||||
env = request_env()
|
||||
|
||||
if (not request_env) then
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Init: Could not initalise insequre_environment.")
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. ": Init: Could not initalise insequre_environment.")
|
||||
sc.irc_on = false
|
||||
|
||||
end -- if(request_env
|
||||
|
||||
if (not env) then
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Init: Please add the mod to secure.trusted_mods to run.")
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. ": Init: Please add the mod to secure.trusted_mods to run.")
|
||||
sc.irc_on = false
|
||||
|
||||
end -- if (not env
|
||||
@ -104,9 +95,9 @@ sc.S = S
|
||||
|
||||
dofile(path .. "/lib.lua")
|
||||
dofile(path .. "/core.lua")
|
||||
dofile(path .. "/matterbridge.lua")
|
||||
dofile(path .. "/irc.lua")
|
||||
dofile(path .. "/cmd_help.lua")
|
||||
dofile(path .. "/irc.lua")
|
||||
dofile(path .. "/matterbridge.lua")
|
||||
dofile(path .. "/cmd_join.lua")
|
||||
dofile(path .. "/cmd_leave.lua")
|
||||
dofile(path .. "/cmd_list.lua")
|
||||
@ -153,4 +144,4 @@ minetest.register_chatcommand("c",{
|
||||
|
||||
}) -- minetest.register_chatcommand
|
||||
|
||||
minetest.log("action", "[MOD]" .. sc.modname .. " v " .. sc.version .. "." .. sc.revision .. " loaded.")
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " v " .. sc.version .. "." .. sc.revision .. " loaded.")
|
||||
|
35
irc.lua
35
irc.lua
@ -40,35 +40,34 @@ if (sc.irc_on) then
|
||||
function sc.irc_connect()
|
||||
if(not sc.irc_running) then
|
||||
sc.irc_running = true
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Try to connect to: "
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: Try to connect to: "
|
||||
.. sc.host_ip .. ":" .. sc.host_port)
|
||||
local cl, err = assert(socket.connect(sc.host_ip, sc.host_port)) -- connect to irc
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Start connection: ", err)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: Start connection: " .. err)
|
||||
sc.client = cl
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Set client_timeout to: "
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: Set client_timeout to: "
|
||||
.. sc.client_timeout)
|
||||
err = sc.client:settimeout(sc.client_timeout) -- and set timeout
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Settimeout: ", err)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: Settimeout: " .. err)
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Set Nick: " .. sc.servername)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: Set Nick: " .. sc.servername)
|
||||
local line = "NICK " .. sc.servername .. " " .. sc.crlf
|
||||
err = sc.client:send(line)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : IRC-Module: " .. line .. "Error: " .. err)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: " .. line .. " Error: " .. err)
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Set User: " .. sc.servername
|
||||
.. " 0 0 " .. sc.servername)
|
||||
minetest.log("action", "Set User: " .. sc.servername .. " 0 0 " .. sc.servername)
|
||||
line = "USER " .. sc.servername .. " 0 0 " .. sc.servername .. sc.crlf
|
||||
err = sc.client:send(line)
|
||||
minetest.log("action",line, err)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module Irc: " .. line .. " Error: " .. err)
|
||||
|
||||
if(sc.irc_user_password ~= "") then
|
||||
line = "PASS " .. sc.user_password .. sc.crlf
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: " .. line .. "Error: " .. err)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module Irc: " .. line .. "Error: " .. err)
|
||||
|
||||
end -- if(sc.irc_user_password =~ ""
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Join Channel: " .. sc.irc_channel)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: Join Channel: " .. sc.irc_channel)
|
||||
if(sc.irc_channel_password ~= "") then
|
||||
line = "JOIN " .. sc.irc_channel .. " " .. sc.irc_channel_password .. sc.crlf
|
||||
|
||||
@ -78,27 +77,25 @@ if (sc.irc_on) then
|
||||
end -- if(not sc.irc_password
|
||||
|
||||
err = sc.client:send(line)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : IRC-Module: " ..line, err)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Moldule Irc: " .. line .. "Error: " .. err)
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: Set Channeltopic: "
|
||||
.. sc.irc_channel_topic)
|
||||
line = "TOPIC " .. sc.irc_channel .. " :" .. sc.irc_channel_topic .. sc.crlf
|
||||
err = sc.client:send(line)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: Set Channeltopic: "
|
||||
.. sc.irc_channel_topic)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: " .. line .. "Error: " .. err)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module Irc: " .. line .. "Error:" .. err)
|
||||
|
||||
else
|
||||
sc.report("SYS", "IRC is already connected.")
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : IRC-Module: already connected.")
|
||||
|
||||
end -- if(−sc.irc_running
|
||||
|
||||
|
||||
end -- sc.connect
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
-- Close the Connection to IRC-Server and close the network
|
||||
if (sc.client ~= nil) then
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : IRC-Module: Shutdown IRC.")
|
||||
minetest.log("action", "Shutdown IRC.")
|
||||
sc.client:send("QUIT" .. sc.crlf)
|
||||
sc.client:close()
|
||||
sc.client = nil
|
||||
@ -133,7 +130,7 @@ if (sc.irc_on) then
|
||||
|
||||
elseif ((err ~= nil) and (err ~= "timeout")) then
|
||||
if(err == "closed") then -- Connection closed?
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : IRC-Module: " .. err)
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module Irc: " .. err)
|
||||
sc.client:close() -- Close the Connection
|
||||
sc.irc_running = false
|
||||
|
||||
|
72
lib.lua
72
lib.lua
@ -31,6 +31,7 @@ function lib.check(player, cmd)
|
||||
if(lib.registered_commands[cmd[1]] ~= nil) then
|
||||
-- Command is valid, execute it with parameter
|
||||
lib.registered_commands[cmd[1]](player, cmd)
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: " .. player .. " executes " .. cmd)
|
||||
|
||||
else -- A command is given, but
|
||||
-- Command not found, report it.
|
||||
@ -87,7 +88,7 @@ end
|
||||
function lib.print(player, text)
|
||||
local lprint = minetest.chat_send_player
|
||||
lprint(player, text)
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : Print <" .. player .. "> " .. text)
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: " .. text .. " to " .. player)
|
||||
|
||||
end -- function lib.print(
|
||||
|
||||
@ -143,7 +144,6 @@ function lib.channel_report(channel, message, color)
|
||||
color = lib.orange
|
||||
|
||||
end -- if(color
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : Channel: " .. channel .. " Report: " .. message)
|
||||
|
||||
for _,players in pairs(all_player) do
|
||||
local pname = players:get_player_name()
|
||||
@ -154,6 +154,7 @@ function lib.channel_report(channel, message, color)
|
||||
end -- if(check_channel
|
||||
|
||||
end -- for _,players
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: channel_report: " .. channel .. ": " .. message)
|
||||
|
||||
end -- lib.report(
|
||||
|
||||
@ -168,7 +169,7 @@ end -- lib.report(
|
||||
function lib.report(player, message)
|
||||
local all_player = minetest.get_connected_players()
|
||||
local channel = lib.player[player]
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : Report: " .. message)
|
||||
|
||||
for _,players in pairs(all_player) do
|
||||
local pname = players:get_player_name()
|
||||
|
||||
@ -179,6 +180,8 @@ function lib.report(player, message)
|
||||
|
||||
end -- for _,players
|
||||
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: report" .. player .. " " .. message)
|
||||
|
||||
end -- lib.report(
|
||||
|
||||
--[[
|
||||
@ -192,9 +195,8 @@ Writes the Text from IRC to the Public Channel
|
||||
function lib.receive_from_irc(line)
|
||||
if(not lib.irc_running) then return end
|
||||
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : From IRC :" .. line)
|
||||
|
||||
local playername, msg
|
||||
|
||||
local pos1, pos2
|
||||
pos1 = string.find(line,"!",2)
|
||||
pos2 = string.find(line,":",3,true)
|
||||
@ -203,8 +205,7 @@ function lib.receive_from_irc(line)
|
||||
playername = lib.get_nick_from_irc(line)
|
||||
msg = string.sub(line, string.find(line,":",3,true)+1)
|
||||
local a, e = string.find(msg, "ACTION") -- was /ME-Command from irc
|
||||
|
||||
if( (a) and (a >= 1) ) then -- Found ACTION in line
|
||||
if( (a) and (a >= 1) ) then
|
||||
msg = string.sub(msg, e + 1)
|
||||
line = lib.orange .. playername .. "@IRC " .. msg
|
||||
|
||||
@ -225,14 +226,16 @@ function lib.receive_from_irc(line)
|
||||
|
||||
end -- if((pos1 ~= 1
|
||||
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: receive_from_irc: <" .. playername .. "> " .. msg)
|
||||
|
||||
end -- function lib.receive()
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function send_to_irc ******
|
||||
******* Function send_2_irc ******
|
||||
****************************************************************
|
||||
|
||||
Sends a Text as playername to the IRC
|
||||
Sends a Text as playername to the IRC
|
||||
]]--
|
||||
|
||||
function lib.send_2_irc(playername, text)
|
||||
@ -244,25 +247,29 @@ function lib.send_2_irc(playername, text)
|
||||
if(not lib.irc_running) then return end
|
||||
|
||||
local line = string.gsub(text, "\27%([^()]*%)", "")
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : To IRC : " .. line)
|
||||
|
||||
--print(line)
|
||||
line = "PRIVMSG " .. lib.irc_channel .. " :<" .. playername
|
||||
.. "@" .. lib.servername .. "> " .. line .. lib.crlf
|
||||
lib.client:send(line)
|
||||
lib.irc_message_count = 0 -- This prevents for IRC-Echos of multiple player
|
||||
lib.irc_message = text -- and remembers the last message
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: send_2_irc: " .. line)
|
||||
|
||||
else
|
||||
lib.irc_message_count = lib.irc_message_count + 1 -- IRC-Message was the same as the lasts
|
||||
if(lib.irc_message.count == 1) then -- clear the counter after 2 second from the
|
||||
minetest.after(2, function() -- last message automatical
|
||||
local line = string.gsub(text, "\27%([^()]*%)", "")
|
||||
line = "PRIVMSG " .. lib.irc_channel .. " :<" .. playername
|
||||
.. "@" .. lib.servername .. "> " .. line .. lib.crlf
|
||||
lib.irc_message_count = lib.irc_message_count + 1 -- IRC-Message was the same
|
||||
if( (lib.irc_message.count == 1) and
|
||||
(lib.irc.message == line) ) then -- clear counter after second
|
||||
minetest.after(2, function() -- last message automatical
|
||||
lib.irc_message_count = 0
|
||||
|
||||
end) -- function
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: Message counts: "
|
||||
.. lib.irc_message_count)
|
||||
|
||||
else -- if(lib.irc_message > 1
|
||||
return -- do nothing
|
||||
else -- if(lib.irc_message > 1
|
||||
return -- do nothing
|
||||
|
||||
end -- if(lib.irc_message_count
|
||||
|
||||
@ -298,15 +305,6 @@ function lib.chat(playername, text)
|
||||
local all_player = minetest.get_connected_players()
|
||||
local channel = lib.player[playername] -- Get the Channel of the player
|
||||
|
||||
if(channel ~= nil) then
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : chat:<" .. playername .. "@" .. channel
|
||||
.. "> " .. text)
|
||||
|
||||
else
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : chat:<" .. playername .. "> " .. text)
|
||||
|
||||
end
|
||||
|
||||
for _,players in pairs(all_player) do
|
||||
local pname = players:get_player_name()
|
||||
|
||||
@ -318,7 +316,6 @@ function lib.chat(playername, text)
|
||||
|
||||
if(lib.public[pname] and pname ~= playername) then -- name is in public-mode and not the player self
|
||||
minetest.chat_send_player(pname, "<" .. playername .. "> " .. text)
|
||||
|
||||
end
|
||||
|
||||
if(lib.irc_on ~= nil) then
|
||||
@ -331,11 +328,13 @@ function lib.chat(playername, text)
|
||||
|
||||
end -- if(lib.matterbridge)
|
||||
|
||||
elseif(lib.check_channel(pname, channel)) then -- chan.(receive)=chan.(send)
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: chat: <" .. playername .. "> " .. text)
|
||||
|
||||
elseif(lib.check_channel(pname, channel)) then
|
||||
minetest.chat_send_player(pname, lib.yellow .. "<" .. lib.orange .. playername .. "@"
|
||||
.. channel .. lib.yellow .. "> " .. text)
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib : CHAT: # <" .. playername
|
||||
.. "@" .. channel .. "> " .. text)
|
||||
.. channel .. lib.yellow .. "> " .. text)
|
||||
minetest.log("action", "[MOD] " .. lib.modname .. " : Module lib: chat: <"
|
||||
.. playername .. "@" .. channel .. "> " .. text)
|
||||
|
||||
end -- if(channel == nil
|
||||
|
||||
@ -379,14 +378,3 @@ function lib.is_channeladmin(player)
|
||||
return power
|
||||
|
||||
end
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function show_version() ******
|
||||
****************************************************************
|
||||
]]--
|
||||
|
||||
function lib.show_version()
|
||||
print("[MOD]" .. lib.modname .. " v " .. lib.version .. "." .. lib.revision .. " loaded. \n")
|
||||
|
||||
end -- lib.show_version
|
||||
|
131
matterbridge.lua
131
matterbridge.lua
@ -10,74 +10,71 @@
|
||||
|
||||
local sc = smart_chat
|
||||
|
||||
if(sc.matterbridge == true) then
|
||||
if(sc.matterbridge_irc) then
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module matterbridge: yl_matterbridge_irc is on.")
|
||||
if( sc.matterbridge == true) then
|
||||
|
||||
if ( minetest.get_modpath("yl_matterbridge")) then
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function yl_matterbridge.chat_message ******
|
||||
****************************************************************
|
||||
|
||||
turns the on_register_chat_messages() from matterbridge off
|
||||
because smart_chat has register his own event
|
||||
]]--
|
||||
|
||||
function yl_matterbridge.chat_message(username, message_text)
|
||||
end
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function yl_matterbridge.receive_from_bridge ******
|
||||
****************************************************************
|
||||
|
||||
Overwrites the function handle the message about smart_chat
|
||||
]]--
|
||||
|
||||
function yl_matterbridge.receive_from_bridge(user_name, message_text, account)
|
||||
local line = "<"..account .."|" .. user_name .. "> " .. message_text
|
||||
local all_player = minetest.get_connected_players()
|
||||
|
||||
for _,player in pairs(all_player) do
|
||||
local pname = player:get_player_name()
|
||||
if(sc.check_global(pname) or sc.public[pname]) then -- Player is in Pub-Channel
|
||||
sc.chat(pname, line)
|
||||
|
||||
end -- if(lib.check_global
|
||||
|
||||
end -- func(user_name
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module matterbridge: receive_from_bridge: " .. line)
|
||||
|
||||
end -- function yl_matterbridge
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function yl_matterbridge.send_2_bridge ******
|
||||
****************************************************************
|
||||
|
||||
Function to send a message to the matterbridge
|
||||
]]--
|
||||
|
||||
function sc.send_2_bridge(user_name, message_text)
|
||||
|
||||
if(sc.player[user_name] ~= nil) then return end -- is User in public-channel?
|
||||
|
||||
local line = "<" .. user_name .. "@" .. sc.servername .. "> " .. message_text
|
||||
yl_matterbridge.send_to_bridge(user_name, line)
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module matterbridge: send_2_bridge: " .. line)
|
||||
|
||||
end -- function sc.send_2_bridge
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname ..
|
||||
" : Module matterbridge: Mod yl_matterbridge successfully loaded.")
|
||||
|
||||
else
|
||||
minetest.log("action","[MOD] " .. sc.modname .. " : Module matterbridge: yl_matterbridge_irc is off.")
|
||||
|
||||
end -- if(sc.matterbridge_irc
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function yl_matterbridge.chat_message ******
|
||||
****************************************************************
|
||||
|
||||
turns the on_register_chat_messages() from matterbridge off
|
||||
because smart_chat has register his own event
|
||||
]]--
|
||||
|
||||
function yl_matterbridge.chat_message(username, message_text)
|
||||
yl_matterbridge.receive_from_bridge(user_name, message_text)
|
||||
|
||||
end
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function yl_matterbridge.receive_from_bridge ******
|
||||
****************************************************************
|
||||
|
||||
Overwrites the function handle the message about smart_chat
|
||||
]]--
|
||||
|
||||
function yl_matterbridge.receive_from_bridge(user_name, message_text, account)
|
||||
|
||||
local line = "<"..account .."|" .. user_name .. "> " .. message_text
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module matterbridge: From Bridge: " .. line)
|
||||
local all_player = minetest.get_connected_players()
|
||||
|
||||
for _,player in pairs(all_player) do
|
||||
local pname = player:get_player_name()
|
||||
if(sc.check_global(pname) or sc.public[pname] and (user_name ~= pname)) then -- Player is in Pub-Channel
|
||||
sc.print(pname, line)
|
||||
|
||||
end -- if(lib.check_global
|
||||
|
||||
end -- func(user_name
|
||||
|
||||
end -- function yl_matterbridge
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function yl_matterbridge.send_2_bridge ******
|
||||
****************************************************************
|
||||
|
||||
Function to send a message to the matterbridge
|
||||
]]--
|
||||
|
||||
function sc.send_2_bridge(user_name, message_text)
|
||||
|
||||
if(sc.player[user_name] ~= nil) then return end -- is User in public-channel?
|
||||
|
||||
--local line = "<" .. user_name .. "@" .. sc.servername .. "> " .. message_text
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " Module matterbridge: To Bridge : " .. message_text)
|
||||
yl_matterbridge.send_to_bridge(user_name, message_text)
|
||||
|
||||
end -- function sc.send_2_bridge
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " Module matterbridge: : yl_matterbridge loaded.")
|
||||
|
||||
end -- if(ylmatterbridge exist
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " : Module matterbridge: Mod yl_matterbridge not found.")
|
||||
|
||||
end -- if( minetest.get_modpath
|
||||
|
||||
end -- if( sc.matterbridge == true
|
||||
|
Loading…
x
Reference in New Issue
Block a user