2019-11-12 09:37:39 -08:00
|
|
|
|
2021-04-07 08:37:44 -07:00
|
|
|
beerchat.get_player_channel = function(name)
|
|
|
|
if type(name) == "string" then
|
|
|
|
local channel = beerchat.currentPlayerChannel[name]
|
|
|
|
if channel and beerchat.channels[channel] then
|
|
|
|
return channel
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
beerchat.fix_player_channel = function(name, notify)
|
|
|
|
if notify or notify == nil then
|
|
|
|
minetest.chat_send_player(
|
|
|
|
name,
|
|
|
|
"Channel "..beerchat.currentPlayerChannel[name].." does not exist, switching back to "..
|
|
|
|
beerchat.main_channel_name..". Please resend your message"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
beerchat.currentPlayerChannel[name] = beerchat.main_channel_name
|
|
|
|
minetest.get_player_by_name(name):get_meta():set_string("beerchat:current_channel", beerchat.main_channel_name)
|
|
|
|
end
|
|
|
|
|
2019-11-12 09:37:39 -08:00
|
|
|
beerchat.has_player_muted_player = function(name, other_name)
|
2020-02-11 15:05:16 -08:00
|
|
|
local cb_result = beerchat.execute_callbacks('before_check_muted', name, other_name)
|
|
|
|
if cb_result ~= nil then
|
|
|
|
return cb_result
|
2020-02-10 23:24:39 -08:00
|
|
|
end
|
2020-02-11 15:05:16 -08:00
|
|
|
|
2019-11-12 09:37:39 -08:00
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
-- check jic method is used incorrectly
|
2020-02-10 23:24:39 -08:00
|
|
|
if not player then
|
|
|
|
return true
|
|
|
|
end
|
2019-11-12 09:37:39 -08:00
|
|
|
|
|
|
|
local key = "beerchat:muted:" .. other_name
|
|
|
|
local meta = player:get_meta()
|
|
|
|
return "true" == meta:get_string(key)
|
2021-04-07 08:37:44 -07:00
|
|
|
end
|
2019-11-12 09:37:39 -08:00
|
|
|
|
|
|
|
beerchat.is_player_subscribed_to_channel = function(name, channel)
|
|
|
|
return (nil ~= beerchat.playersChannels[name])
|
|
|
|
and (nil ~= beerchat.playersChannels[name][channel])
|
2021-04-07 08:37:44 -07:00
|
|
|
end
|
2019-11-12 09:37:39 -08:00
|
|
|
|
|
|
|
beerchat.send_message = function(name, message, channel)
|
2020-02-11 15:05:16 -08:00
|
|
|
if not beerchat.execute_callbacks('before_send', name, message, channel) then
|
2020-02-10 23:24:39 -08:00
|
|
|
return
|
|
|
|
end
|
2020-02-11 15:05:16 -08:00
|
|
|
|
2019-11-12 09:37:39 -08:00
|
|
|
minetest.chat_send_player(name, message)
|
2021-04-07 08:37:44 -07:00
|
|
|
-- TODO: read player settings for channel sounds
|
2019-11-12 09:37:39 -08:00
|
|
|
if beerchat.enable_sounds and channel ~= beerchat.main_channel_name then
|
2021-04-09 03:36:49 -07:00
|
|
|
minetest.sound_play(
|
|
|
|
beerchat.channel_message_sound, {
|
|
|
|
to_player = name,
|
|
|
|
gain = beerchat.sounds_default_gain
|
|
|
|
},
|
|
|
|
true
|
|
|
|
)
|
2019-11-12 09:37:39 -08:00
|
|
|
end
|
2021-04-07 08:37:44 -07:00
|
|
|
end
|