Matterbridge the 500.
This commit is contained in:
parent
4d77735236
commit
4abb80171c
51
cmd_mark_channel.lua
Normal file
51
cmd_mark_channel.lua
Normal file
@ -0,0 +1,51 @@
|
||||
local sc = smart_chat
|
||||
local S = sc.S
|
||||
local cname = "mark_channel"
|
||||
local short = "mc"
|
||||
local activate = minetest.settings:get_bool("smart_chat.cmd_" .. cname, true)
|
||||
|
||||
if(not activate) then return end
|
||||
|
||||
sc.register_help({
|
||||
Name = cname,
|
||||
Usage = "/c " .. cname,
|
||||
Description = S("Marks a channel permanent."),
|
||||
Parameter = "",
|
||||
Shortcut = "/c " .. short,
|
||||
}
|
||||
)
|
||||
|
||||
sc.registered_commands[cname] = function(player)
|
||||
local channel = sc.player[player]
|
||||
local privs = minetest.get_player_privs(player)
|
||||
|
||||
if(not privs.channelmod) then
|
||||
sc.print(player, sc.red .. S("Error: You don't have the privileg to change channels."))
|
||||
return
|
||||
|
||||
end -- if(not privs.channelmod
|
||||
|
||||
if(sc.player[player] ~= nil) then
|
||||
if((sc.permchannel ~= nil) and (sc.permchannel[channel] ~= nil) ) then -- Channel exist
|
||||
sc.print(player, sc.red .. S("Error: Permanent Channels exist."))
|
||||
|
||||
else
|
||||
sc.permchannel[channel] = channel
|
||||
sc.report(player, sc.orange .. player .. sc.green .. S(" marks the Channel [") .. sc.yellow .. channel
|
||||
.. sc.green .. S("] as permanent."))
|
||||
sc.storage:from_table({fields=sc.permchannel})
|
||||
|
||||
end -- if(sc.permchannel[channel]
|
||||
|
||||
else
|
||||
sc.print(player, sc.red .. S("Error: You can't set the public Chat as permanent."))
|
||||
|
||||
end -- if(sc.player
|
||||
|
||||
end -- sc["store_channel"
|
||||
|
||||
sc.registered_commands[short] = function(player, parameter)
|
||||
|
||||
sc.registered_commands[cname](player, parameter)
|
||||
|
||||
end -- sc["l"
|
51
cmd_unmark_channel.lua
Normal file
51
cmd_unmark_channel.lua
Normal file
@ -0,0 +1,51 @@
|
||||
local sc = smart_chat
|
||||
local S = sc.S
|
||||
local cname = "unmark_channel"
|
||||
local short = "uc"
|
||||
local activate = minetest.settings:get_bool("smart_chat.cmd_" .. cname, true)
|
||||
|
||||
if(not activate) then return end
|
||||
|
||||
sc.register_help({
|
||||
Name = cname,
|
||||
Usage = "/c " .. cname,
|
||||
Description = S("Unmarks a channel as permanent."),
|
||||
Parameter = "",
|
||||
Shortcut = "/c " .. short,
|
||||
}
|
||||
)
|
||||
|
||||
sc.registered_commands[cname] = function(player)
|
||||
local channel = sc.player[player]
|
||||
local privs = minetest.get_player_privs(player)
|
||||
|
||||
if(not privs.channelmod) then
|
||||
sc.print(player, sc.red .. S("Error: You don't have the privileg to change channels."))
|
||||
return
|
||||
|
||||
end -- if(not privs.channelmod
|
||||
|
||||
if(sc.player[player] ~= nil) then
|
||||
if(sc.permchannel[channel] ~= nil) then
|
||||
sc.permchannel[channel] = nil
|
||||
sc.report(player, sc.orange .. player .. sc.green .. S(" Unmarks the Channel [") .. sc.yellow .. channel
|
||||
.. sc.green .. S("] from permanent."))
|
||||
sc.storage:from_table({fields=sc.permchannel})
|
||||
|
||||
else
|
||||
sc.print(player, sc.red .. S("Error: Permanent Channels not found."))
|
||||
|
||||
end -- if(sc.permchannel[channel]
|
||||
|
||||
else
|
||||
sc.print(player, sc.red .. S("Error: You can't unmarks the public Chat from permanent."))
|
||||
|
||||
end -- if(sc.player
|
||||
|
||||
end -- sc["free_channel"
|
||||
|
||||
sc.registered_commands[short] = function(player, parameter)
|
||||
|
||||
sc.registered_commands[cname](player, parameter)
|
||||
|
||||
end -- sc["l"
|
12
init.lua
12
init.lua
@ -11,8 +11,8 @@
|
||||
smart_chat = {}
|
||||
|
||||
local sc = smart_chat
|
||||
sc.player = {}
|
||||
sc.public = {}
|
||||
sc.player = {} -- Channel of Player
|
||||
sc.public = {} -- Player has toggle on
|
||||
sc.last_command = nil
|
||||
|
||||
sc.version = 1
|
||||
@ -87,8 +87,8 @@ if (sc.irc_on) then
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " Socket-Library loaded.")
|
||||
|
||||
else
|
||||
print("IRC turned off.")
|
||||
|
||||
minetest.log("action", "[MOD] " .. sc.modname .. " IRC is turned off.")
|
||||
|
||||
end -- if (sc.irc
|
||||
|
||||
sc.S = S
|
||||
@ -106,8 +106,8 @@ dofile(path .. "/cmd_all.lua")
|
||||
dofile(path .. "/cmd_invite.lua")
|
||||
dofile(path .. "/cmd_toggle.lua")
|
||||
dofile(path .. "/cmd_where.lua")
|
||||
dofile(path .. "/cmd_store_channel.lua")
|
||||
dofile(path .. "/cmd_free_channel.lua")
|
||||
dofile(path .. "/cmd_mark_channel.lua")
|
||||
dofile(path .. "/cmd_unmark_channel.lua")
|
||||
dofile(path .. "/cmd_kick.lua")
|
||||
dofile(path .. "/cmd_move.lua")
|
||||
dofile(path .. "/cmd_status.lua")
|
||||
|
2
irc.lua
2
irc.lua
@ -34,7 +34,7 @@ if (sc.irc_on) then
|
||||
]]--
|
||||
--sc.client_timeout = 0.03
|
||||
--local socket = require("socket")
|
||||
|
||||
|
||||
sc.reconnect = 0 -- counter Reconnect
|
||||
|
||||
function sc.irc_connect()
|
||||
|
55
lib.lua
55
lib.lua
@ -85,12 +85,17 @@ end
|
||||
|
||||
function lib.print(player, text)
|
||||
local lprint = minetest.chat_send_player
|
||||
--local playername = minetest.get_player_by_name(player)
|
||||
lprint(player, text)
|
||||
|
||||
end -- function distancer.print(
|
||||
end -- function lib.print(
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function check_global(player) ******
|
||||
****************************************************************
|
||||
returns true if player is in public channel
|
||||
]]--
|
||||
|
||||
-- Is player in the public channel?
|
||||
function lib.check_global(cplayer)
|
||||
if(lib.player[cplayer] == nil) then
|
||||
return true
|
||||
@ -106,6 +111,7 @@ end
|
||||
****************************************************************
|
||||
******* Function check_channel() ******
|
||||
****************************************************************
|
||||
Is the player in the channel?
|
||||
]]--
|
||||
|
||||
function lib.check_channel(cplayer, channel)
|
||||
@ -125,7 +131,7 @@ end -- lib.check_channel
|
||||
******* Function channel_report() ******
|
||||
****************************************************************
|
||||
|
||||
Send a message to a channel.
|
||||
Something happens in the Channel like leave the channel.
|
||||
channel = nil: Send a message to the public channel.
|
||||
]]--
|
||||
|
||||
@ -152,6 +158,8 @@ end -- lib.report(
|
||||
****************************************************************
|
||||
******* Function report() ******
|
||||
****************************************************************
|
||||
|
||||
Player is doing something in the Channel like leave the channel.
|
||||
]]--
|
||||
function lib.report(player, message)
|
||||
local all_player = minetest.get_connected_players()
|
||||
@ -207,7 +215,7 @@ end -- function lib.receive()
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function send_2_public() ******
|
||||
******* Function send_2_public() ******
|
||||
****************************************************************
|
||||
|
||||
Sends a Text as playername to the IRC
|
||||
@ -229,10 +237,11 @@ Sends a Text as playername to the IRC
|
||||
|
||||
function lib.send_2_irc(playername, text)
|
||||
|
||||
if(not lib.irc_on) then return end -- IRC isn't on
|
||||
|
||||
if(lib.irc_message ~= text) then
|
||||
if(not lib.irc_running) then return end
|
||||
|
||||
--local line = minetest.strip_colors(text)
|
||||
local line = string.gsub(text, "\27%([^()]*%)", "")
|
||||
|
||||
--print(line)
|
||||
@ -259,6 +268,14 @@ function lib.send_2_irc(playername, text)
|
||||
|
||||
end -- function send_2_irc
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function get_nick_from_irc ******
|
||||
****************************************************************
|
||||
|
||||
Extract the nickname from a received line from irc
|
||||
]]--
|
||||
|
||||
function lib.get_nick_from_irc(line)
|
||||
local nick
|
||||
|
||||
@ -270,8 +287,9 @@ end -- get_nick_from_irc()
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function print_all() ******
|
||||
******* Function chat() ******
|
||||
****************************************************************
|
||||
Send's a messager to public or channel
|
||||
]]--
|
||||
function lib.chat(playername, text)
|
||||
local all_player = minetest.get_connected_players()
|
||||
@ -294,12 +312,9 @@ function lib.chat(playername, text)
|
||||
lib.send_2_irc(playername, text)
|
||||
|
||||
end -- if(sc.client
|
||||
|
||||
|
||||
if(lib.matterbridge) then
|
||||
lib.send_2_bridge(playername, text)
|
||||
|
||||
end -- if(sc.matterbridge
|
||||
|
||||
lib.
|
||||
elseif(lib.check_channel(pname, channel)) then
|
||||
minetest.chat_send_player(pname, lib.yellow .. "<" .. lib.orange .. playername .. "@"
|
||||
.. channel .. lib.yellow .. "> " .. text)
|
||||
@ -319,6 +334,14 @@ function lib.chat(playername, text)
|
||||
|
||||
end -- function chat
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function is_channelmod() ******
|
||||
****************************************************************
|
||||
|
||||
if player is channelmod, power is 10, else 0
|
||||
]]--
|
||||
|
||||
function lib.is_channelmod(player)
|
||||
local power = 0
|
||||
if(minetest.get_player_privs(player).channelmod) then
|
||||
@ -329,6 +352,14 @@ function lib.is_channelmod(player)
|
||||
|
||||
end
|
||||
|
||||
--[[
|
||||
****************************************************************
|
||||
******* Function is_channeladmin() ******
|
||||
****************************************************************
|
||||
|
||||
if player is channelmod, power is 20, else 0
|
||||
]]--
|
||||
|
||||
function lib.is_channeladmin(player)
|
||||
local power = 0
|
||||
if(minetest.get_player_privs(player).channeladmin) then
|
||||
|
@ -13,27 +13,52 @@ local sc = smart_chat
|
||||
if(sc.matterbridge == true) then
|
||||
|
||||
if(minetest.global_exist(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_name.."|" .. 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(lib.check_global(pname) or lib.public[pname]) then -- Player is in Public Channel
|
||||
lib.print(pname, line)
|
||||
if(lib.check_global(pname) or lib.public[pname]) then -- Player is in Public Channel
|
||||
lib.chat(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)
|
||||
local line = "<" .. user_name .. "@" .. sc.servername .. "> " .. message_text
|
||||
if(sc.check_global(user_name)) then
|
||||
if(sc.check_global(user_name)) then -- is User in public-channel?
|
||||
yl_matterbridge.send_to_bridge(username, line)
|
||||
|
||||
end -- if(sc.check_global
|
||||
|
@ -41,3 +41,7 @@ smart_chat.irc_automatic_reconnect_max (Max. tries to connect) int 5
|
||||
smart_chat.servername (Name of the World) string Local
|
||||
smart_chat.channel_password (Password for the Channel) string ""
|
||||
smart_chat.user_password (Password for registered Users) string ""
|
||||
|
||||
#yl_Matterbridge
|
||||
sc.matterbridge (Turns yl_matterbridge on or of) bool false
|
||||
sc.matterbridge_irc (yl_matterbridge has irc on?) bool false
|
||||
|
Loading…
x
Reference in New Issue
Block a user