Add Replies feature (#5)
* add replies payload and method * clean comment * improve TextWithReplies and spelling correction * fix last typo
This commit is contained in:
parent
f5aa0f8e1c
commit
5a7a8679ad
10
receiving.go
10
receiving.go
@ -55,6 +55,16 @@ type Attachment struct {
|
||||
Payload Payload `json:"payload"`
|
||||
}
|
||||
|
||||
// QuickReply is a file which used in a message.
|
||||
type QuickReply struct {
|
||||
// ContentType is the type of reply
|
||||
ContentType string `json:"content_type"`
|
||||
// Title is the reply title
|
||||
Title string `json:"title"`
|
||||
// Payload is the reply information
|
||||
Payload string `json:"payload"`
|
||||
}
|
||||
|
||||
// Payload is the information on where an attachment is.
|
||||
type Payload struct {
|
||||
// URL is where the attachment resides on the internet.
|
||||
|
13
response.go
13
response.go
@ -24,10 +24,16 @@ type Response struct {
|
||||
|
||||
// Text sends a textual message.
|
||||
func (r *Response) Text(message string) error {
|
||||
return r.TextWithReplies(message, nil)
|
||||
}
|
||||
|
||||
// TextWithReplies sends a textual message with some replies
|
||||
func (r *Response) TextWithReplies(message string, replies []QuickReply) error {
|
||||
m := SendMessage{
|
||||
Recipient: r.to,
|
||||
Message: MessageData{
|
||||
Text: message,
|
||||
Text: message,
|
||||
QuickReplies: replies,
|
||||
},
|
||||
}
|
||||
|
||||
@ -178,9 +184,10 @@ type SendMessage struct {
|
||||
Message MessageData `json:"message"`
|
||||
}
|
||||
|
||||
// MessageData is a text message to be sent.
|
||||
// MessageData is a text message with optional replies to be sent.
|
||||
type MessageData struct {
|
||||
Text string `json:"text,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
QuickReplies []QuickReply `json:"quick_replies,omitempty"`
|
||||
}
|
||||
|
||||
// SendStructuredMessage is a structured message template.
|
||||
|
Loading…
Reference in New Issue
Block a user