<commit_before>MY_ChatFilter = {}
local _C = {}
local _L = MY.LoadLangPack(MY.GetAddonInfo().szRoot .. "Chat/lang/")
local MY_ChatFilter = MY_ChatFilter
local MAX_CHAT_RECORD = 10
local MAX_UUID_RECORD = 10
MY_ChatFilter.bFilterDuplicate           = true   -- ظ
MY_ChatFilter.bFilterDuplicateIgnoreID   = false  -- ͬظҲ
MY_ChatFilter.bFilterDuplicateContinuous = true   -- ظ
MY_ChatFilter.bFilterDuplicateAddonTalk  = true   -- UUIDͬĲϢ
RegisterCustomData("MY_ChatFilter.bFilterDuplicate")
RegisterCustomData("MY_ChatFilter.bFilterDuplicateIgnoreID")
RegisterCustomData("MY_ChatFilter.bFilterDuplicateContinuous")
RegisterCustomData("MY_ChatFilter.bFilterDuplicateAddonTalk")

MY_ChatFilter.tApplyDuplicateChannels = {
	["MSG_SYS"           ] = false,
	["MSG_NORMAL"        ] = true,
	["MSG_PARTY"         ] = false,
	["MSG_MAP"           ] = true,
	["MSG_BATTLE_FILED"  ] = true,
	["MSG_GUILD"         ] = true,
	["MSG_GUILD_ALLIANCE"] = true,
	["MSG_SCHOOL"        ] = true,
	["MSG_WORLD"         ] = true,
	["MSG_TEAM"          ] = false,
	["MSG_CAMP"          ] = true,
	["MSG_GROUP"         ] = true,
	["MSG_WHISPER"       ] = false,
	["MSG_SEEK_MENTOR"   ] = true,
	["MSG_FRIEND"        ] = false,
}
for k, _ in pairs(MY_ChatFilter.tApplyDuplicateChannels) do
	RegisterCustomData("MY_ChatFilter.tApplyDuplicateChannels." .. k)
end

local l_tChannelHeader = {
	["MSG_WHISPER"] = g_tStrings.STR_TALK_HEAD_SAY,
	["MSG_NORMAL"] = g_tStrings.STR_TALK_HEAD_SAY,
	["MSG_NPC_NEARBY"] = g_tStrings.STR_TALK_HEAD_SAY,
	["MSG_PARTY"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_GUILD"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_GUILD_ALLIANCE"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_WORLD"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_SCHOOL"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_CAMP"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_FRIEND"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_TEAM"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_MAP"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_BATTLE_FILED"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_NPC_PARTY"] = g_tStrings.STR_TALK_HEAD_SAY1,
}

MY.HookChatPanel("MY_ChatFilter", function(h, szChannel, szMsg, dwTime)
	-- ϢUUID
	if MY_ChatFilter.bFilterDuplicateAddonTalk then
		local me = GetClientPlayer()
		local tSay = me.GetTalkData()
		if not h.MY_tDuplicateUUID then
			h.MY_tDuplicateUUID = {}
		elseif tSay[1] and tSay[1].type == "eventlink" then
			local data = MY.Json.Decode(tSay[1].linkinfo)
			if data and data.uuid then
				local szUUID = data.uuid
				if szUUID then
					for k, uuid in pairs(h.MY_tDuplicateUUID) do
						if uuid == szUUID then
							return ''
						end
					end
					table.insert(h.MY_tDuplicateUUID, 1, szUUID)
					local nCount = #h.MY_tDuplicateUUID - MAX_UUID_RECORD
					if nCount > 0 then
						for i = nCount, 1, -1 do
							table.remove(h.MY_tDuplicateUUID)
						end
					end
				end
			end
		end
	end
	-- ظˢΣϵͳƵ⣩
	if MY_ChatFilter.bFilterDuplicate
	and MY_ChatFilter.tApplyDuplicateChannels[szChannel] then
		-- ˼¼
		local szText = GetPureText(szMsg)
		if l_tChannelHeader[szChannel] then
			szText = szText:gsub("^.-" .. l_tChannelHeader[szChannel], "")
		end
		szText = szText:gsub("[ \n]", "")
		if MY_ChatFilter.bFilterDuplicateIgnoreID then
			local nCount = 1
			while nCount > 0 do
				szText, nCount = szText:gsub('^%[[^%[%]]+%]', '')
			end
		end
		-- жǷҪ
		if not h.MY_tDuplicateLog then
			h.MY_tDuplicateLog = {}
		elseif szText == "" then
			-- 鴿ӾͲ
		elseif MY_ChatFilter.bFilterDuplicateContinuous then
			if h.MY_tDuplicateLog[1] == szText then
				return ''
			end
			h.MY_tDuplicateLog[1] = szText
		else
			for i, szRecord in ipairs(h.MY_tDuplicateLog) do
				if szRecord == szText then
					return ''<commit_msg>刷屏屏蔽不同ID会被屏蔽的问题<commit_after>MY_ChatFilter = {}
local _C = {}
local _L = MY.LoadLangPack(MY.GetAddonInfo().szRoot .. "Chat/lang/")
local MY_ChatFilter = MY_ChatFilter
local MAX_CHAT_RECORD = 10
local MAX_UUID_RECORD = 10
MY_ChatFilter.bFilterDuplicate           = true   -- ظ
MY_ChatFilter.bFilterDuplicateIgnoreID   = false  -- ͬظҲ
MY_ChatFilter.bFilterDuplicateContinuous = true   -- ظ
MY_ChatFilter.bFilterDuplicateAddonTalk  = true   -- UUIDͬĲϢ
RegisterCustomData("MY_ChatFilter.bFilterDuplicate")
RegisterCustomData("MY_ChatFilter.bFilterDuplicateIgnoreID")
RegisterCustomData("MY_ChatFilter.bFilterDuplicateContinuous")
RegisterCustomData("MY_ChatFilter.bFilterDuplicateAddonTalk")

MY_ChatFilter.tApplyDuplicateChannels = {
	["MSG_SYS"           ] = false,
	["MSG_NORMAL"        ] = true,
	["MSG_PARTY"         ] = false,
	["MSG_MAP"           ] = true,
	["MSG_BATTLE_FILED"  ] = true,
	["MSG_GUILD"         ] = true,
	["MSG_GUILD_ALLIANCE"] = true,
	["MSG_SCHOOL"        ] = true,
	["MSG_WORLD"         ] = true,
	["MSG_TEAM"          ] = false,
	["MSG_CAMP"          ] = true,
	["MSG_GROUP"         ] = true,
	["MSG_WHISPER"       ] = false,
	["MSG_SEEK_MENTOR"   ] = true,
	["MSG_FRIEND"        ] = false,
}
for k, _ in pairs(MY_ChatFilter.tApplyDuplicateChannels) do
	RegisterCustomData("MY_ChatFilter.tApplyDuplicateChannels." .. k)
end

local l_tChannelHeader = {
	["MSG_WHISPER"] = g_tStrings.STR_TALK_HEAD_SAY,
	["MSG_NORMAL"] = g_tStrings.STR_TALK_HEAD_SAY,
	["MSG_NPC_NEARBY"] = g_tStrings.STR_TALK_HEAD_SAY,
	["MSG_PARTY"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_GUILD"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_GUILD_ALLIANCE"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_WORLD"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_SCHOOL"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_CAMP"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_FRIEND"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_TEAM"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_MAP"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_BATTLE_FILED"] = g_tStrings.STR_TALK_HEAD_SAY1,
	["MSG_NPC_PARTY"] = g_tStrings.STR_TALK_HEAD_SAY1,
}

MY.HookChatPanel("MY_ChatFilter", function(h, szChannel, szMsg, dwTime)
	-- ϢUUID
	if MY_ChatFilter.bFilterDuplicateAddonTalk then
		local me = GetClientPlayer()
		local tSay = me.GetTalkData()
		if not h.MY_tDuplicateUUID then
			h.MY_tDuplicateUUID = {}
		elseif tSay[1] and tSay[1].type == "eventlink" then
			local data = MY.Json.Decode(tSay[1].linkinfo)
			if data and data.uuid then
				local szUUID = data.uuid
				if szUUID then
					for k, uuid in pairs(h.MY_tDuplicateUUID) do
						if uuid == szUUID then
							return ''
						end
					end
					table.insert(h.MY_tDuplicateUUID, 1, szUUID)
					local nCount = #h.MY_tDuplicateUUID - MAX_UUID_RECORD
					if nCount > 0 then
						for i = nCount, 1, -1 do
							table.remove(h.MY_tDuplicateUUID)
						end
					end
				end
			end
		end
	end
	-- ظˢΣϵͳƵ⣩
	if MY_ChatFilter.bFilterDuplicate
	and MY_ChatFilter.tApplyDuplicateChannels[szChannel] then
		-- ˼¼
		local szText, szName = GetPureText(szMsg)
		if l_tChannelHeader[szChannel] then
			local nS, nE = wstring.find(szText, l_tChannelHeader[szChannel])
			if nS and nE then
				szName = ""
				szText:sub(1, nE):gsub("(%[[^%[%]%])", function(s)
					szName = szName .. s
				end)
				szText = szText:sub(nE + 1)
			end
		end
		szText = szText:gsub("[ \n]", "")
		if not MY_ChatFilter.bFilterDuplicateIgnoreID then
			szText = szText .. szName
		end
		-- жǷҪ
		if not h.MY_tDuplicateLog then
			h.MY_tDuplicateLog = {}
		elseif szText == "" then
			-- 鴿ӾͲ
		elseif MY_ChatFilter.bFilterDuplicateContinuous then
			if h.MY_tDuplicateLog[1] == szText then
				return ''
			end
			h.MY_tDuplicateLog[1] = szText
		else
			for i, szRecord in ipairs(h.MY_tDuplicateLog) do
				if szRecord == szText then
					return ''
{'fraction_non_alphanumeric': 0.11957827305485119, 'fraction_numerical': 0.0069398104897904715, 'mean_word_length': 3.773248407643312, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7027032', 'n_tokens_mistral': 3379, 'n_tokens_neox': 3099, 'n_words': 505}