1
0
mirror of https://github.com/Earu/EasyChat.git synced 2025-03-04 03:13:20 -05:00

Add a module to fix compability with starfall

This commit is contained in:
Earu 2021-11-12 22:35:25 +01:00
parent f0c4b9ac9b
commit 7ccd94511f
2 changed files with 34 additions and 9 deletions

View File

@ -742,16 +742,15 @@ if CLIENT then
end
EasyChat.Close = close_chatbox
local url_patterns = {
"https?://[^%s%\"%>%<]+",
"ftp://[^%s%\"%>%<]+",
"steam://[^%s%\"%>%<]+",
"www%.[^%s%\"]+%.[^%s%\"]+",
"STEAM_%d%:%d%:%d+"
}
function EasyChat.IsURL(str)
local patterns = {
"https?://[^%s%\"%>%<]+",
"ftp://[^%s%\"%>%<]+",
"steam://[^%s%\"%>%<]+",
"www%.[^%s%\"]+%.[^%s%\"]+",
"STEAM_%d%:%d%:%d+"
}
for _, pattern in ipairs(patterns) do
for _, pattern in ipairs(url_patterns) do
local start_pos, end_pos = str:find(pattern, 1, false)
if start_pos then
return start_pos, end_pos
@ -1511,6 +1510,8 @@ if CLIENT then
return { ... }
end
safe_hook_run("ECPreAddText", ...)
local data = {}
if EC_HUD_CUSTOM:GetBool() then
@ -1579,6 +1580,8 @@ if CLIENT then
chat.PlaySound()
end
safe_hook_run("ECPostAddText", ...)
return data
end

View File

@ -0,0 +1,22 @@
-- this module is a hack for fixing the following issue:
-- https://github.com/Earu/EasyChat/issues/79
-- https://github.com/thegrb93/StarfallEx/issues/1232
-- thanks for nothing thegrb93
local TAG = "EasyChatModuleSFCompat"
local function is_starfall()
return _G.SF ~= nil and _G.SF.runningOps ~= nil and _G.SF.SafeStringLib ~= nil
end
local previous_ops_state = false
hook.Add("ECPreAddText", TAG, function()
if not is_starfall() then return end
previous_ops_state = _G.SF.runningOps
end)
hook.Add("ECPostAddText", TAG, function()
_G.SF.runningOps = previous_ops_state
end)
return "SF Compat"