<commit_before>-- 
-- ¼
-- ¼Ŷ/// պѯ
-- ߣһ @ tinymins
-- վZhaiYiMing.CoM
-- 
local _L  = MY.LoadLangPack(MY.GetAddonInfo().szRoot.."Chat/lang/")
local _C  = {}
local Log = {}
local tinsert = table.insert
local tremove = table.remove
MY_ChatLog = MY_ChatLog or {}

function _C.OnMsg(szMsg, szChannel, nFont, bRich, r, g, b)
	if not bRich then
		szMsg = GetFormatText(szMsg, nil, r, g, b)
	end
	-- generate rec
	szMsg = MY.Chat.GetTimeLinkText({r=r, g=g, b=b, f=nFont, s='[MM/dd|hh:mm:ss]'}) .. szMsg
	szMsg = MY.Chat.RenderLink(szMsg)
	if MY_Farbnamen and MY_Farbnamen.Render then
		szMsg = MY_Farbnamen.Render(szMsg)
	end
	-- save rec
	tinsert(Log[szChannel], szMsg)
	while #Log[szChannel] > Log.nMax do
		tremove(Log[szChannel], 1)
	end
	_C.AppendLog(szChannel, szMsg)
end

function _C.OnTongMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_GUILD', nFont, bRich, r, g, b)
end
function _C.OnWisperMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_WHISPER', nFont, bRich, r, g, b)
end
function _C.OnRaidMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_TEAM', nFont, bRich, r, g, b)
end
function _C.OnFriendMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_FRIEND', nFont, bRich, r, g, b)
end

MY.RegisterInit(function()
	Log = MY.Json.Decode(MY.LoadUserData('cache/CHAT_LOG/log')) or {}
	for k, v in pairs({
		nMax       = 50,
		MSG_GUILD  = {},
		MSG_WHISPER= {},
		MSG_TEAM   = {},
		MSG_FRIEND = {},
		Active     = 'MSG_WHISPER',
	}) do
		if type(Log[k]) ~= type(v) then
			Log[k] = v
		end
	end
	RegisterMsgMonitor(_C.OnTongMsg  , { 'MSG_GUILD', 'MSG_GUILD_ALLIANCE' })
	RegisterMsgMonitor(_C.OnWisperMsg, { 'MSG_WHISPER' })
	RegisterMsgMonitor(_C.OnRaidMsg  , { 'MSG_TEAM', 'MSG_GROUP' })
	RegisterMsgMonitor(_C.OnFriendMsg, { 'MSG_FRIEND' })
end)

MY.RegisterExit(function()
	MY.SaveUserData('cache/CHAT_LOG/log', MY.Json.Encode(Log))<commit_msg>聊天助手：更改数据文件位置<commit_after>-- 
-- ¼
-- ¼Ŷ/// պѯ
-- ߣһ @ tinymins
-- վZhaiYiMing.CoM
-- 
local _L  = MY.LoadLangPack(MY.GetAddonInfo().szRoot.."Chat/lang/")
local _C  = {}
local Log = {}
local tinsert = table.insert
local tremove = table.remove
MY_ChatLog = MY_ChatLog or {}

function _C.OnMsg(szMsg, szChannel, nFont, bRich, r, g, b)
	if not bRich then
		szMsg = GetFormatText(szMsg, nil, r, g, b)
	end
	-- generate rec
	szMsg = MY.Chat.GetTimeLinkText({r=r, g=g, b=b, f=nFont, s='[MM/dd|hh:mm:ss]'}) .. szMsg
	szMsg = MY.Chat.RenderLink(szMsg)
	if MY_Farbnamen and MY_Farbnamen.Render then
		szMsg = MY_Farbnamen.Render(szMsg)
	end
	-- save rec
	tinsert(Log[szChannel], szMsg)
	while #Log[szChannel] > Log.nMax do
		tremove(Log[szChannel], 1)
	end
	_C.AppendLog(szChannel, szMsg)
end

function _C.OnTongMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_GUILD', nFont, bRich, r, g, b)
end
function _C.OnWisperMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_WHISPER', nFont, bRich, r, g, b)
end
function _C.OnRaidMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_TEAM', nFont, bRich, r, g, b)
end
function _C.OnFriendMsg(szMsg, nFont, bRich, r, g, b)
	_C.OnMsg(szMsg, 'MSG_FRIEND', nFont, bRich, r, g, b)
end

MY.RegisterInit(function()
	Log = MY.Json.Decode(MY.LoadUserData('cache/CHAT_LOG/')) or {}
	for k, v in pairs({
		nMax       = 50,
		MSG_GUILD  = {},
		MSG_WHISPER= {},
		MSG_TEAM   = {},
		MSG_FRIEND = {},
		Active     = 'MSG_WHISPER',
	}) do
		if type(Log[k]) ~= type(v) then
			Log[k] = v
		end
	end
	RegisterMsgMonitor(_C.OnTongMsg  , { 'MSG_GUILD', 'MSG_GUILD_ALLIANCE' })
	RegisterMsgMonitor(_C.OnWisperMsg, { 'MSG_WHISPER' })
	RegisterMsgMonitor(_C.OnRaidMsg  , { 'MSG_TEAM', 'MSG_GROUP' })
	RegisterMsgMonitor(_C.OnFriendMsg, { 'MSG_FRIEND' })
end)

MY.RegisterExit(function()
	MY.SaveUserData('cache/CHAT_LOG/', MY.Json.Encode(Log))
{'fraction_non_alphanumeric': 0.16524292578750668, 'fraction_numerical': 0.001601708489054992, 'mean_word_length': 4.2114047287899865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1270614', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1700, 'n_words': 349}