mirror of
https://github.com/diamondburned/cchat-mock.git
synced 2024-11-08 07:14:21 +00:00
43 lines
573 B
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
|
||
|
}
|