35 lines
540 B
Go
35 lines
540 B
Go
package structs
|
|
|
|
type Message struct {
|
|
Author string
|
|
Content string
|
|
Response string
|
|
}
|
|
|
|
func NewMessage(author, content string) *Message {
|
|
return &Message{
|
|
author,
|
|
content,
|
|
"",
|
|
}
|
|
}
|
|
|
|
func NewMessageWithResponse(author, content, response string) *Message {
|
|
return &Message{
|
|
author,
|
|
content,
|
|
response,
|
|
}
|
|
}
|
|
|
|
func (n *Message) String() string {
|
|
var out string = "### Instruction:\n" +
|
|
n.Author + " wrote " + n.Content + "\n" +
|
|
"### Response:"
|
|
|
|
if n.Response != "" {
|
|
out += "\n" + n.Response + "\n"
|
|
}
|
|
|
|
return out
|
|
}
|