summaryrefslogtreecommitdiff
path: root/helpers.go
blob: 8f63de0046c5776cd2fba8ba3e3019561dca1bfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
}