]> git.giacomolli.uk - onechat/blobdiff - memory.go
Talk to the agent through a Telegram bot
[onechat] / memory.go
index ca8277c629889037c17c4ef221bcf94c049f0e8c..a3665a1d64a57d91e9b4255178b09dba63e66c8c 100644 (file)
--- a/memory.go
+++ b/memory.go
@@ -543,6 +543,39 @@ func (m *Memory) View() string {
        return m.chat.Render()
 }
 
+// ViewLines returns the lines of the chat view, each with its newline, without
+// the leaf lines of the messages in skip.
+func (m *Memory) ViewLines(skip map[int]bool) []string {
+       m.mutex.Lock()
+       defer m.mutex.Unlock()
+
+       return m.chat.LinesWithout(skip)
+}
+
+// Len returns the number of messages in the log.
+func (m *Memory) Len() int {
+       m.mutex.Lock()
+       defer m.mutex.Unlock()
+
+       return m.log.Len()
+}
+
+// Message reads the message with the given ID.
+func (m *Memory) Message(id int) (Message, error) {
+       m.mutex.Lock()
+       defer m.mutex.Unlock()
+
+       return m.log.Message(id)
+}
+
+// Node reads the node (l, i) if it is built.
+func (m *Memory) Node(level, index int) (Node, bool, error) {
+       m.mutex.Lock()
+       defer m.mutex.Unlock()
+
+       return m.tree.Node(level, index)
+}
+
 // Context returns the compaction view for the build of node (l, i). It ends
 // before the message of a leaf, or after the last message of a merge, and it
 // stops at the first line that is not built.