Skip to content

Commit b0ab00b

Browse files
committed
fix: parse_mode in lower case and empty for plain text
1 parent 62e3040 commit b0ab00b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

webhook_responder.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ func newTgWebhookResponder(w http.ResponseWriter, whc *tgWebhookContext) tgWebho
3030

3131
func (r tgWebhookResponder) SendMessage(c context.Context, m botsfw.MessageFromBot, channel botsfw.BotAPISendMessageChannel) (resp botsfw.OnMessageSentResponse, err error) {
3232
logus.Debugf(c, "tgWebhookResponder.SendMessage(channel=%v, isEdit=%v)\nm: %+v", channel, m.IsEdit, m)
33-
if channel != botsfw.BotAPISendMessageOverHTTPS && channel != botsfw.BotAPISendMessageOverResponse {
33+
switch channel {
34+
case botsfw.BotAPISendMessageOverHTTPS, botsfw.BotAPISendMessageOverResponse:
35+
// Known channels
36+
default:
3437
panic(fmt.Sprintf("Unknown channel: [%v]. Expected either 'https' or 'response'.", channel))
3538
}
3639
//ctx := tc.Context()
@@ -44,13 +47,13 @@ func (r tgWebhookResponder) SendMessage(c context.Context, m botsfw.MessageFromB
4447
parseMode := func() string {
4548
switch m.Format {
4649
case botsfw.MessageFormatHTML:
47-
return "HTML"
50+
return "html"
4851
case botsfw.MessageFormatMarkdown:
49-
return "Markdown"
52+
return "markdown"
5053
case botsfw.MessageFormatText:
51-
return "Text"
54+
return ""
5255
default:
53-
return fmt.Sprintf("%d", m.Format)
56+
panic(fmt.Sprintf("Unknown message parse_mode value: %d", m.Format))
5457
}
5558
}
5659

0 commit comments

Comments
 (0)