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

additional checks for very short nicks

This commit is contained in:
Earu 2021-12-09 21:32:33 +01:00
parent 699b08074a
commit 3b2fa624a7
2 changed files with 14 additions and 6 deletions

View File

@ -101,8 +101,16 @@ local function safe_hook_run(hook_name, ...)
end
EasyChat.SafeHookRun = safe_hook_run
function EasyChat.IsStringEmpty(str)
return #EasyChat.ExtendedStringTrim(str, true) == 0
function EasyChat.IsStringEmpty(str, is_nick)
local sanitized_str = EasyChat.ExtendedStringTrim(str, true)
if #sanitized_str == 0 then return true end
-- if its a nick dont allow under 2 chars
if is_nick and utf8.len(sanitized_str) < 2 then
return true
end
return false
end
local load_modules, get_modules = include("easychat/autoloader.lua")
@ -1460,7 +1468,7 @@ if CLIENT then
ply_col = EasyChat.PastelizeNick(nick)
end
local empty_nick = EasyChat.IsStringEmpty(nick)
local empty_nick = EasyChat.IsStringEmpty(nick, true)
if empty_nick then
ply_col = UNKNOWN_COLOR
end
@ -1815,7 +1823,7 @@ if CLIENT then
ply_col = EasyChat.PastelizeNick(stripped_ply_nick)
end
local empty_nick = EasyChat.IsStringEmpty(stripped_ply_nick)
local empty_nick = EasyChat.IsStringEmpty(stripped_ply_nick, true)
if empty_nick then
ply_col = UNKNOWN_COLOR
end

View File

@ -171,7 +171,7 @@ if CLIENT then
end
local ply_col = team.GetColor(team_id)
if EasyChat.IsStringEmpty(name) then
if EasyChat.IsStringEmpty(name, true) then
name = "[NO NAME]"
ply_col = UNKNOWN_COLOR
else
@ -209,7 +209,7 @@ if CLIENT then
if not friend_ids[network_id] then return end
if EasyChat.BlockedPlayers[network_id] then return end -- friends can block each others on steam
if EasyChat.IsStringEmpty(name) then name = "[NO NAME]" end
if EasyChat.IsStringEmpty(name, true) then name = "[NO NAME]" end
chat.AddText(green_color, " ● Friend joining ", white_color, name, gray_color, " (" .. network_id .. ")")
end)
end