1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-mock.git synced 2024-12-28 06:06:45 +00:00
cchat-mock/internal/message/header.go

43 lines
573 B
Go

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
}