This commit is contained in:
parent
4575c97aae
commit
e36d19e078
|
@ -7,9 +7,6 @@ import (
|
|||
func ExampleChat() *Chats {
|
||||
conversation := NewChats()
|
||||
|
||||
t := conversation.AddTable()
|
||||
t.AddRow([]string{"apple", "pear"})
|
||||
|
||||
conversation.AddGeminiComment("funny")
|
||||
|
||||
/*
|
||||
|
|
28
helpers.go
28
helpers.go
|
@ -3,36 +3,20 @@ package chatpb
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.wit.com/log"
|
||||
"google.golang.org/protobuf/proto"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func (c *Chats) AddGeminiComment(s string) *ChatEntry {
|
||||
chat := new(ChatEntry)
|
||||
|
||||
chat.From = Who_GEMINI
|
||||
chat.Content = s
|
||||
chat.Ctime = timestamppb.New(time.Now())
|
||||
|
||||
c.AppendNew(chat)
|
||||
|
||||
return chat
|
||||
log.Info("FIX")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Chats) AddUserComment(s string) *ChatEntry {
|
||||
chat := new(ChatEntry)
|
||||
|
||||
chat.From = Who_USER
|
||||
chat.Content = s
|
||||
|
||||
c.AppendNew(chat)
|
||||
|
||||
return chat
|
||||
log.Info("FIX")
|
||||
return nil
|
||||
}
|
||||
|
||||
func UnmarshalChats(data []byte) (*Chats, error) {
|
||||
|
@ -100,12 +84,12 @@ func (c *Chat) VerifyUuid() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (x *Chats) AppendNew(y *ChatEntry) {
|
||||
func (x *Chats) AppendNew(y *Chat) {
|
||||
x.Lock()
|
||||
defer x.Unlock()
|
||||
|
||||
var chat *Chat
|
||||
chat = proto.Clone(y).(*ChatEntry)
|
||||
chat = proto.Clone(y).(*Chat)
|
||||
|
||||
x.Chats = append(x.Chats, chat)
|
||||
}
|
||||
|
|
42
make_chat.go
42
make_chat.go
|
@ -1,45 +1,5 @@
|
|||
package chatpb
|
||||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func TestChat() {
|
||||
conversation := NewChats()
|
||||
|
||||
/*
|
||||
chat := new(Chat)
|
||||
chat.Content = "this was fun"
|
||||
|
||||
t := new(Table)
|
||||
t.Columns = 4
|
||||
// t.Rows = append(t.Rows, []string{"a", "b"})
|
||||
chat.Table = t
|
||||
|
||||
r := new(Row)
|
||||
r.Fields = []string{"a", "b"}
|
||||
t.Rows = append(t.Rows, r)
|
||||
|
||||
r = new(Row)
|
||||
r.Fields = []string{"1", "", "2", "3"}
|
||||
t.Rows = append(t.Rows, r)
|
||||
|
||||
conversation.AppendNew(chat)
|
||||
*/
|
||||
|
||||
t := conversation.AddTable()
|
||||
t.AddRow([]string{"apple", "pear"})
|
||||
|
||||
conversation.AddGeminiComment("funny")
|
||||
conversation.AddUserComment("yes")
|
||||
|
||||
conversation.AddGeminiComment("I like astronomy")
|
||||
|
||||
dump := conversation.FormatTEXT()
|
||||
|
||||
log.Println(dump)
|
||||
}
|
||||
|
||||
func (t *Table) AddRow(f []string) {
|
||||
r := new(Row)
|
||||
r.Fields = f
|
||||
|
@ -61,8 +21,6 @@ func (c *Chats) AddTable() *Table {
|
|||
r.Fields = []string{"1", "", "2", "3"}
|
||||
t.Rows = append(t.Rows, r)
|
||||
|
||||
chat.Table = t
|
||||
|
||||
c.AppendNew(chat)
|
||||
|
||||
return t
|
||||
|
|
Loading…
Reference in New Issue