chatpb/helpers.go

43 lines
666 B
Go

package chatpb
import (
"time"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
func (c *Chats) AddGeminiComment(s string) *Chat {
chat := new(Chat)
chat.From = Who_GEMINI
chat.Content = s
chat.Ctime = timestamppb.New(time.Now())
c.Append(chat)
return chat
}
func (c *Chats) AddUserComment(s string) *Chat {
chat := new(Chat)
chat.From = Who_USER
chat.Content = s
c.Append(chat)
return chat
}
func UnmarshalChats(data []byte) (*Chats, error) {
c := new(Chats)
err := c.Unmarshal(data)
return c, err
}
func UnmarshalChatsTEXT(data []byte) (*Chats, error) {
c := new(Chats)
err := c.UnmarshalTEXT(data)
return c, err
}