1
0
mirror of synced 2024-11-21 20:36:06 +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) {
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) {

View File

@ -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 {

View File

@ -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"`
}