From 2db24269ecc01c4a0509a6e6fd30c1103e0fa22c Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 23 Sep 2016 05:49:05 +0800 Subject: [PATCH] Add Send func for sending a message to a user (#10) Fixes #6. --- messenger.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/messenger.go b/messenger.go index dafc118..3cc71ed 100644 --- a/messenger.go +++ b/messenger.go @@ -264,6 +264,21 @@ func (m *Messenger) Response(to int64) *Response { } } +// Send will send a textual message to a user. This user must have previously initiated a conversation with the bot. +func (m *Messenger) Send(to Recipient, message string) error { + return m.SendWithReplies(to, message, nil) +} + +// SendWithReplies sends a textual message to a user, but gives them the option of numerous quick response options. +func (m *Messenger) SendWithReplies(to Recipient, message string, replies []QuickReply) error { + response := &Response{ + token: m.token, + to: to, + } + + return response.TextWithReplies(message, replies) +} + // classify determines what type of message a webhook event is. func (m *Messenger) classify(info MessageInfo, e Entry) Action { if info.Message != nil {