de3a5d0949
* Added Read message support Delivered message suppport already existed but was commented as indicating that a message was read by a user. As of the 1 July 2016 API release this isn't true, there is another event. This commit adds read event support and corrects the description of delivered events. Also added to the example bot. * go fmt * Added new profile fields from July 1st API update * gofmt
66 lines
2.0 KiB
Go
66 lines
2.0 KiB
Go
package messenger
|
|
|
|
import "time"
|
|
|
|
// Message represents a Facebook messenge message.
|
|
type Message struct {
|
|
// Sender is who the message was sent from.
|
|
Sender Sender `json:"-"`
|
|
// Recipient is who the message was sent to.
|
|
Recipient Recipient `json:"-"`
|
|
// Time is when the message was sent.
|
|
Time time.Time `json:"-"`
|
|
// Mid is the ID of the message.
|
|
Mid string `json:"mid"`
|
|
// Seq is order the message was sent in relation to other messages.
|
|
Seq int `json:"seq"`
|
|
// Text is the textual contents of the message.
|
|
Text string `json:"text"`
|
|
// Attachments is the information about the attachments which were sent
|
|
// with the message.
|
|
Attachments []Attachment `json:"attachments"`
|
|
}
|
|
|
|
// Delivery represents a the event fired when Facebook delivers a message to the
|
|
// recipient.
|
|
type Delivery struct {
|
|
// Mids are the IDs of the messages which were read.
|
|
Mids []string `json:"mids"`
|
|
// RawWatermark is the timestamp of when the delivery was.
|
|
RawWatermark int64 `json:"watermark"`
|
|
// Seq is the sequence the message was sent in.
|
|
Seq int `json:"seq"`
|
|
}
|
|
|
|
// Delivery represents a the event fired when a message is read by the
|
|
// recipient.
|
|
type Read struct {
|
|
// RawWatermark is the timestamp before which all messages have been read
|
|
// by the user
|
|
RawWatermark int64 `json:"watermark"`
|
|
// Seq is the sequence the message was sent in.
|
|
Seq int `json:"seq"`
|
|
}
|
|
|
|
// PostBack represents postback callback
|
|
type PostBack struct {
|
|
// Sender is who the message was sent from.
|
|
Sender Sender `json:"-"`
|
|
// Recipient is who the message was sent to.
|
|
Recipient Recipient `json:"-"`
|
|
// Time is when the message was sent.
|
|
Time time.Time `json:"-"`
|
|
// PostBack ID
|
|
Payload string `json:"payload"`
|
|
}
|
|
|
|
// Watermark is the RawWatermark timestamp rendered as a time.Time.
|
|
func (d Delivery) Watermark() time.Time {
|
|
return time.Unix(d.RawWatermark, 0)
|
|
}
|
|
|
|
// Watermark is the RawWatermark timestamp rendered as a time.Time.
|
|
func (r Read) Watermark() time.Time {
|
|
return time.Unix(r.RawWatermark, 0)
|
|
}
|