mirror of
https://github.com/Earu/EasyChat.git
synced 2025-03-04 03:13:20 -05:00
Add a convenient message history across sessions
This commit is contained in:
parent
3a3f6bbdf3
commit
17861c88c7
25
lua/easychat/modules/client/global_msg_history.lua
Normal file
25
lua/easychat/modules/client/global_msg_history.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local HISTORY_PATH = "easychat/msg_history.txt"
|
||||
local function save_history()
|
||||
if not file.Exists("easychat", "DATA") then
|
||||
file.CreateDir("easychat")
|
||||
end
|
||||
|
||||
if not IsValid(EasyChat.GUI.TextEntry) then return end
|
||||
|
||||
local history_length = #EasyChat.GUI.TextEntry.History
|
||||
local start_pos = history_length > 100 and history_length - 100 or 1
|
||||
local contents = table.concat(EasyChat.GUI.TextEntry.History, "\n", start_pos, history_length)
|
||||
file.Write(HISTORY_PATH, contents)
|
||||
end
|
||||
|
||||
hook.Add("ECPreDestroy", "EasyChatModuleMsgHistory", save_history)
|
||||
hook.Add("ShutDown", "EasyChatModuleMsgHistory", save_history)
|
||||
|
||||
hook.Add("ECInitialized", "EasyChatModuleMsgHistory", function()
|
||||
if not IsValid(EasyChat.GUI.TextEntry) then return end
|
||||
local contents = file.Read(HISTORY_PATH, "DATA") or ""
|
||||
EasyChat.GUI.TextEntry.History = contents:Split("\n")
|
||||
EasyChat.GUI.TextEntry.HistoryPos = 0
|
||||
end)
|
||||
|
||||
return "Message History"
|
@ -2,6 +2,7 @@
|
||||
title EasyChat Update
|
||||
set /p changes="Changes: "
|
||||
|
||||
git add *
|
||||
git commit -a -m "%changes%"
|
||||
git push
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user