/
events.go
60 lines (50 loc) · 1.45 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ADDED BY DROP - https://github.com/matryer/drop (v0.6)
// source: github.com/maciekmm/messenger-platform-go-sdk (ca9227b956ad50bc8b6225a464f6c0146887f7c5)
// update: drop -f github.com/maciekmm/messenger-platform-go-sdk
// license: The MIT License (MIT) (see repo for details)
package main
import "encoding/json"
type upstreamEvent struct {
Object string `json:"object"`
Entries []*MessageEvent `json:"entry"`
}
type Event struct {
ID json.Number `json:"id"`
Time int64 `json:"time"`
}
type MessageOpts struct {
Sender struct {
ID string `json:"id"`
} `json:"sender"`
Recipient struct {
ID string `json:"id"`
} `json:"recipient"`
Timestamp int64 `json:"timestamp"`
}
type MessageEvent struct {
Event
Messaging []struct {
MessageOpts
Message *ReceivedMessage `json:"message,omitempty"`
Delivery *Delivery `json:"delivery,omitempty"`
Postback *Postback `json:"postback,omitempty"`
Optin *Optin `json:"optin,empty"`
} `json:"messaging"`
}
type ReceivedMessage struct {
ID string `json:"mid"`
Text string `json:"text,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
Seq int `json:"seq"`
}
type Delivery struct {
MessageIDS []string `json:"mids"`
Watermark int64 `json:"watermark"`
Seq int `json:"seq"`
}
type Postback struct {
Payload string `json:"payload"`
}
type Optin struct {
Ref string `json:"ref"`
}