1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-10-31 19:44:23 +00:00
cchat-gtk/internal/ui/message/input/send.go

54 lines
946 B
Go
Raw Normal View History

2020-06-04 23:00:41 +00:00
package input
import (
"strconv"
"time"
"github.com/diamondburned/cchat"
"github.com/diamondburned/cchat/text"
)
type SendMessageData struct {
content string
author text.Rich
authorID string
nonce string
}
type PresendMessage interface {
cchat.SendableMessage
cchat.MessageNonce
Author() text.Rich
AuthorID() string
}
var (
_ cchat.SendableMessage = (*SendMessageData)(nil)
_ cchat.MessageNonce = (*SendMessageData)(nil)
)
func NewSendMessageData(content string, author text.Rich, authorID string) SendMessageData {
return SendMessageData{
content: content,
author: author,
nonce: "cchat-gtk_" + strconv.FormatInt(time.Now().UnixNano(), 10),
}
}
func (s SendMessageData) Content() string {
return s.content
}
func (s SendMessageData) Author() text.Rich {
return s.author
}
func (s SendMessageData) AuthorID() string {
return s.authorID
}
func (s SendMessageData) Nonce() string {
return s.nonce
}