Skip to content

Commit 4fd0113

Browse files
committed
feat: 聊天屏蔽增加过滤历史显示
1 parent 8aa5a0b commit 4fd0113

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

MY_Chat/lang/zhcn.jx3dat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ return {
132132
['If talker\'s tong name equals with keyword, chat message will be blocked, only apply for target you\'ve met.'] = '��������߰��������ؼ�����ͬ����˷��ԣ�ע��ù��ܽ�������������ʿ��Ч��',
133133
['Edit'] = '�༭',
134134
['Please input keyword:'] = '������ؼ��֣�',
135+
['Total %d messages blocked, recently blocked %d:'] = '����Ŀ�ѹ�����Ϣ�ܼ� %d �������������Ϣ %d ����',
136+
['No messages blocked yet.'] = '����Ŀ��δ������Ϣ��',
135137
['Add'] = '����',
136138
['Delete'] = 'ɾ��',
137139

MY_Chat/lang/zhtw.jx3dat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ return {
132132
['If talker\'s tong name equals with keyword, chat message will be blocked, only apply for target you\'ve met.'] = '如果發言者幫會名稱與關鍵字相同則過濾發言,注意該功能僅對遇見過的俠士生效。',
133133
['Edit'] = '編輯',
134134
['Please input keyword:'] = '請輸入關鍵字:',
135+
['Total %d messages blocked, recently blocked %d:'] = '該條目已過濾消息總計 %d 條,最近過濾消息 %d 條:',
136+
['No messages blocked yet.'] = '該條目尚未過濾消息。',
135137
['Add'] = '添加',
136138
['Delete'] = '刪除',
137139

MY_Chat/src/MY_ChatBlock.lua

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ local O = X.CreateUserSettingsModule('MY_ChatBlock', _L['Chat'], {
7979
})),
8080
xDefaultValue = {},
8181
},
82+
tBlockHistory = {
83+
ePathType = X.PATH_TYPE.GLOBAL,
84+
szLabel = _L['MY_ChatBlock'],
85+
bDataSet = true,
86+
xSchema = X.Schema.Record({
87+
nCount = X.Schema.Number,
88+
aRecent = X.Schema.Collection(X.Schema.String),
89+
}),
90+
xDefaultValue = { nCount = 0, aRecent = {} },
91+
},
8292
})
8393
local D = {}
8494

@@ -89,12 +99,12 @@ function D.IsBlockMsg(szText, szMsgType, dwTalkerID)
8999
for _, bw in ipairs(D.aBlockWords) do
90100
if bw.tMsgType[szMsgType] and (not bAcquaintance or not bw.bIgnoreAcquaintance) then
91101
if X.StringSimpleMatch(szText, bw.szKeyword, not bw.bIgnoreCase, not bw.bIgnoreEnEm, bw.bIgnoreSpace) then
92-
return true
102+
return true, bw.uuid
93103
end
94104
if bw.bTongName and _G.MY_Farbnamen and _G.MY_Farbnamen.Get then
95105
local info = _G.MY_Farbnamen.Get(dwTalkerID)
96106
if info and info.szTongName == bw.szKeyword then
97-
return true
107+
return true, bw.uuid
98108
end
99109
end
100110
end
@@ -108,13 +118,48 @@ function D.OnTalkFilter(nChannel, t, dwTalkerID, szName, bEcho, bOnlyShowBallon,
108118
return
109119
end
110120
local szText = X.StringifyChatText(t)
111-
if D.IsBlockMsg(szText, szType, dwTalkerID) then
121+
local bBlock, uuid = D.IsBlockMsg(szText, szType, dwTalkerID)
122+
if bBlock then
123+
if D.bReady and uuid then
124+
O.tBlockHistory[uuid].nCount = O.tBlockHistory[uuid].nCount + 1
125+
if #O.tBlockHistory[uuid].aRecent >= 10 then
126+
table.remove(O.tBlockHistory[uuid].aRecent, 1)
127+
end
128+
local szType, r, g, b, nFont = X.CONSTANT.PLAYER_TALK_CHANNEL_TO_FONT[nChannel]
129+
if szType then
130+
nFont = GetMsgFont(szType)
131+
r, g, b = GetMsgFontColor(nFont)
132+
end
133+
table.insert(
134+
O.tBlockHistory[uuid].aRecent,
135+
X.GetChatTimeXML(GetCurrentTime(), {
136+
r = r, g = g, b = b, f = nFont,
137+
s = '[%yyyy/%MM/%dd][%hh:%mm:%ss]',
138+
}) .. X.XmlifyChatData(t, r, g, b, nFont)
139+
)
140+
O.tBlockHistory[uuid] = O.tBlockHistory[uuid]
141+
end
112142
return true
113143
end
114144
end
115145

116146
function D.OnMsgFilter(szMsg, nFont, bRich, r, g, b, szType, dwTalkerID, szName)
117-
if D.IsBlockMsg(bRich and GetPureText(szMsg) or szMsg, szType, dwTalkerID) then
147+
local bBlock, uuid = D.IsBlockMsg(bRich and GetPureText(szMsg) or szMsg, szType, dwTalkerID)
148+
if bBlock then
149+
if D.bReady and uuid then
150+
O.tBlockHistory[uuid].nCount = O.tBlockHistory[uuid].nCount + 1
151+
if #O.tBlockHistory[uuid].aRecent >= 10 then
152+
table.remove(O.tBlockHistory[uuid].aRecent, 1)
153+
end
154+
table.insert(
155+
O.tBlockHistory[uuid].aRecent,
156+
X.GetChatTimeXML(GetCurrentTime(), {
157+
r = r, g = g, b = b, f = nFont,
158+
s = '[%yyyy/%MM/%dd][%hh:%mm:%ss]',
159+
}) .. (bRich and szMsg or GetFormatText(szMsg, nFont, r, g, b))
160+
)
161+
O.tBlockHistory[uuid] = O.tBlockHistory[uuid]
162+
end
118163
return true
119164
end
120165
end
@@ -456,6 +501,27 @@ function PS.OnPanelActive(wnd)
456501
end):ListBox('onlclick', function(id, text, data, selected)
457502
edit:Text(text)
458503
end)
504+
:ListBox(
505+
'onhover',
506+
function(id, text, data, selected)
507+
local history = O.tBlockHistory[id]
508+
local aXml = {}
509+
if history.nCount > 0 then
510+
table.insert(aXml, X.GetFormatText(_L('Total %d messages blocked, recently blocked %d:', history.nCount, #history.aRecent), 162, 192, 192, 192))
511+
table.insert(aXml, X.CONSTANT.XML_LINE_BREAKER)
512+
table.insert(aXml, X.CONSTANT.XML_LINE_BREAKER)
513+
else
514+
table.insert(aXml, X.GetFormatText(_L('No messages blocked yet.'), 162, 192, 192, 192))
515+
end
516+
for _, v in ipairs(history.aRecent) do
517+
table.insert(aXml, v)
518+
end
519+
X.OutputTip(X.UI(this):HoverItemRect(), table.concat(aXml, '\n'), true, ALW.BOTTOM_TOP)
520+
end,
521+
function(id, text, data)
522+
HideTip()
523+
end
524+
)
459525
-- add
460526
ui:Append('WndButton', {
461527
x = nW - 160, y= 0, w = 80,

0 commit comments

Comments
 (0)