1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-mock.git synced 2024-11-08 07:14:21 +00:00
cchat-mock/internal/message/header.go

43 lines
573 B
Go
Raw Permalink Normal View History

2020-10-04 20:47:41 +00:00
package message
import (
"strconv"
"time"
"github.com/diamondburned/cchat"
)
type Header struct {
id uint32
time time.Time
}
var _ cchat.MessageHeader = (*Message)(nil)
func ParseID(id string) (uint32, error) {
i, err := strconv.Atoi(id)
if err != nil {
return 0, err
}
return uint32(i), nil
}
func NewHeader(id uint32, t time.Time) Header {
return Header{
id: id,
time: t,
}
}
func (m Header) ID() string {
return strconv.Itoa(int(m.id))
}
func (m Header) RealID() uint32 {
return m.id
}
func (m Header) Time() time.Time {
return m.time
}