From 940d2805be0e64f57244515645b89dc0825f39d1 Mon Sep 17 00:00:00 2001 From: Harrison Shoebridge Date: Wed, 13 Apr 2016 19:46:52 +1000 Subject: [PATCH] Add attachment support to text messages --- cmd/bot/main.go | 1 + message.go | 13 +++++++------ receiving.go | 9 +++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cmd/bot/main.go b/cmd/bot/main.go index 78b4d32..23d4e9d 100644 --- a/cmd/bot/main.go +++ b/cmd/bot/main.go @@ -32,6 +32,7 @@ func main() { m.HandleMessage(func(m messenger.Message, r *messenger.Response) { fmt.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate)) fmt.Println(r.Text("Hello, World!")) + fmt.Println(m.Attachments) }) m.HandleDelivery(func(d messenger.Delivery, r *messenger.Response) { diff --git a/message.go b/message.go index 4115d2f..87b3930 100644 --- a/message.go +++ b/message.go @@ -3,12 +3,13 @@ package messenger import "time" type Message struct { - Sender Sender `json:"-"` - Recipient Recipient `json:"-"` - Time time.Time `json:"-"` - Mid string `json:"mid"` - Text string `json:"text"` - Seq int `json:"seq"` + Sender Sender `json:"-"` + Recipient Recipient `json:"-"` + Time time.Time `json:"-"` + Mid string `json:"mid"` + Text string `json:"text"` + Seq int `json:"seq"` + Attachments []Attachment `json:"attachments"` } type Delivery struct { diff --git a/receiving.go b/receiving.go index c36e772..16df557 100644 --- a/receiving.go +++ b/receiving.go @@ -26,3 +26,12 @@ type Sender struct { type Recipient struct { ID int64 `json:"id"` } + +type Attachment struct { + Type string `json:"type"` + Payload Payload `json:"payload"` +} + +type Payload struct { + URL string `json:"url"` +}