Skip to content

Commit 23caf4e

Browse files
committed
基础库增加StringifyChatContent通过Talk函数发布的系统消息进行转义
1 parent e30c22b commit 23caf4e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

MY_!Base/src/Chat.lua

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function LIB.FormatChatContent(szMsg)
479479
table.insert(t2, {type = 'iteminfo', text = ndata.text, innerText = ndata.text:sub(2, -2), version = version, tabtype = tab, index = index})
480480
-- 姓名
481481
elseif ndata.name:sub(1, 9) == 'namelink_' then
482-
table.insert(t2, {type = 'name', text = ndata.text, innerText = ndata.text, name = ndata.text:sub(2, -2)})
482+
table.insert(t2, {type = 'name', text = ndata.text, innerText = ndata.text, name = ndata.text:sub(2, -2), id = ndata.name:sub(10)})
483483
-- 任务
484484
elseif ndata.name == 'questlink' then
485485
table.insert(t2, {type = 'quest', text = ndata.text, innerText = ndata.text:sub(2, -2), questid = ndata.userdata})
@@ -537,6 +537,18 @@ function LIB.FormatChatContent(szMsg)
537537
return t2
538538
end
539539

540+
function LIB.StringifyChatContent(t, r, g, b)
541+
local aContent = {}
542+
for _, v in ipairs(t) do
543+
if v.type == 'text' then
544+
insert(aContent, GetFormatText(v.text, nil, r, g, b))
545+
elseif v.type == 'name' then
546+
insert(aContent, GetFormatText(v.text, nil, r, g, b, 515, nil, 'namelink_' .. (v.id or 0)))
547+
end
548+
end
549+
return concat(aContent)
550+
end
551+
540552
-- 字符串化一个聊天table结构体
541553
function LIB.StringfyChatContent(t)
542554
local t1 = {}
@@ -810,8 +822,6 @@ function LIB.Talk(nChannel, szText, szUUID, bNoEscape, bSaveDeny, bPushToChatBox
810822
end
811823
elseif nChannel == PLAYER_TALK_CHANNEL.RAID and me.GetScene().nType == MAP_TYPE.BATTLE_FIELD then
812824
nChannel = PLAYER_TALK_CHANNEL.BATTLE_FIELD
813-
elseif nChannel == PLAYER_TALK_CHANNEL.LOCAL_SYS then
814-
return LIB.Sysmsg(CONSTANT.EMPTY_TABLE, szText)
815825
end
816826
-- say body
817827
local tSay = nil
@@ -824,6 +834,10 @@ function LIB.Talk(nChannel, szText, szUUID, bNoEscape, bSaveDeny, bPushToChatBox
824834
tSay = ParseFaceIcon(tSay)
825835
tSay = ParseName(tSay)
826836
end
837+
if nChannel == PLAYER_TALK_CHANNEL.LOCAL_SYS then
838+
local szXml = LIB.StringifyChatContent(tSay, GetMsgFontColor('MSG_SYS'))
839+
return LIB.Sysmsg({ szXml, rich = true })
840+
end
827841
tSay = ParseAntiSWS(tSay)
828842
if LIB.IsShieldedVersion() then
829843
local nLen = 0

0 commit comments

Comments
 (0)