Skip to content

Commit

Permalink
remove keyboards on messages that dont have quick replies
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Dec 7, 2017
1 parent fb7c4c8 commit a04c636
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion handlers/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ func (h *handler) ReceiveMessage(channel courier.Channel, w http.ResponseWriter,
}

func (h *handler) sendMsgPart(msg courier.Msg, token string, path string, form url.Values, replies string) (string, *courier.ChannelLog, error) {
if replies != "" {
// either include or remove our keyboard depending on whether we have quick replies
if replies == "" {
form.Add("reply_markup", `{"remove_keyboard":true}`)
} else {
form.Add("reply_markup", replies)
}

Expand Down
8 changes: 6 additions & 2 deletions handlers/telegram/telegram_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,12 @@ var defaultSendTestCases = []ChannelSendTestCase{
Text: "Simple Message", URN: "telegram:12345",
Status: "W", ExternalID: "133",
ResponseBody: `{ "ok": true, "result": { "message_id": 133 } }`, ResponseStatus: 200,
PostParams: map[string]string{"text": "Simple Message", "chat_id": "12345"},
SendPrep: setSendURL},
PostParams: map[string]string{
"text": "Simple Message",
"chat_id": "12345",
"reply_markup": `{"remove_keyboard":true}`,
},
SendPrep: setSendURL},
{Label: "Quick Reply",
Text: "Are you happy?", URN: "telegram:12345", QuickReplies: []string{"Yes", "No"},
Status: "W", ExternalID: "133",
Expand Down

0 comments on commit a04c636

Please sign in to comment.