From c35af037203ac5c39a4f704d5343bc2b5cc56a0c Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Thu, 21 Nov 2024 18:15:01 +0300 Subject: Feat: add tools to tool map --- main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 1dc387a..6a1311e 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,9 @@ package main import ( + "elefant/models" + "encoding/json" "fmt" - "path" "strconv" "time" "unicode" @@ -73,8 +74,19 @@ func main() { case "new": // set chat body chatBody.Messages = defaultStarter + // TODO: use predefined var since it is the same each time + msgsBytes, err := json.Marshal(chatBody.Messages) + if err != nil { + logger.Error(err.Error()) + } textView.SetText(chatToText(showSystemMsgs)) - activeChatName = path.Join(historyDir, fmt.Sprintf("%d_chat.json", time.Now().Unix())) + newChat := &models.Chat{ + Name: fmt.Sprintf("%v_%v", "new", time.Now().Unix()), + Msgs: string(msgsBytes), + } + // activeChatName = path.Join(historyDir, fmt.Sprintf("%d_chat.json", time.Now().Unix())) + activeChatName = newChat.Name + chatMap[newChat.Name] = newChat pages.RemovePage("history") return // set text @@ -141,7 +153,6 @@ func main() { editArea.SetText(m.Content, true) } if !editMode && event.Key() == tcell.KeyEnter { - // TODO: add notification that text was copied copyToClipboard(m.Content) notification := fmt.Sprintf("msg '%s' was copied to the clipboard", m.Content[:30]) notifyUser("copied", notification) -- cgit v1.2.3