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

fix a rare bug with mentions

This commit is contained in:
Earu 2022-12-17 13:35:49 +01:00
parent 1565609995
commit 00df91dc09

View File

@ -232,7 +232,11 @@ function mentions:IsMention(msg)
local stripped_msg = ec_markup.GetText(msg):lower()
if filter_match(stripped_msg) then return true end
local ply_name = LocalPlayer():Nick():lower():PatternSafe()
local ply = LocalPlayer()
if not IsValid(ply) then return false end
if not ply.Nick then return false end
local ply_name = (ply:Nick() or ""):lower():PatternSafe()
local nick_mention = stripped_msg:match(ply_name)
local is_nick_match = not stripped_msg:match("^[%!%.%/]") and nick_mention
return is_nick_match and #nick_mention > 1