1
0
mirror of synced 2024-11-25 14:26:09 +03:00

Add attachment support to text messages

This commit is contained in:
Harrison Shoebridge 2016-04-13 19:46:52 +10:00
parent ed71354256
commit 940d2805be
3 changed files with 17 additions and 6 deletions

View File

@ -32,6 +32,7 @@ func main() {
m.HandleMessage(func(m messenger.Message, r *messenger.Response) { m.HandleMessage(func(m messenger.Message, r *messenger.Response) {
fmt.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate)) fmt.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate))
fmt.Println(r.Text("Hello, World!")) fmt.Println(r.Text("Hello, World!"))
fmt.Println(m.Attachments)
}) })
m.HandleDelivery(func(d messenger.Delivery, r *messenger.Response) { m.HandleDelivery(func(d messenger.Delivery, r *messenger.Response) {

View File

@ -9,6 +9,7 @@ type Message struct {
Mid string `json:"mid"` Mid string `json:"mid"`
Text string `json:"text"` Text string `json:"text"`
Seq int `json:"seq"` Seq int `json:"seq"`
Attachments []Attachment `json:"attachments"`
} }
type Delivery struct { type Delivery struct {

View File

@ -26,3 +26,12 @@ type Sender struct {
type Recipient struct { type Recipient struct {
ID int64 `json:"id"` ID int64 `json:"id"`
} }
type Attachment struct {
Type string `json:"type"`
Payload Payload `json:"payload"`
}
type Payload struct {
URL string `json:"url"`
}