elbekD / kt-telegram-bot

Telegram Bot Library for Kotlin language
MIT License
104 stars 19 forks source link

support `sendMessage` with `parseMode = "MarkdownV2"` #37

Closed XDracam closed 2 years ago

XDracam commented 3 years ago

Expected behavior

When calling bot.sendMessage(..., parseMode = "MarkdownV2"), the message should be formatted according to the telegram api documentation: https://core.telegram.org/bots/api#markdownv2-style

Actual behavior

The request probably gets sent, but a reply never arrives and the CompleteableFuture never completes

To Reproduce

Bot.createPolling(
    username,
    token
)
  .sendMessage("~~Markdown doesn't support strikethrough~~", parseMode = "MarkdownV2")
  .thenAccept { println(it ?: "fail" }

The post-request never receives a reply. Nothing is ever printed. Using `parseMode = "Markdown" works just fine. The code above prints the message when using "Markdown" but never prints anything when using "MarkdownV2"

Screenshots/Traceback

Possible solutions

There seems to be no proper error handling for when there's no response from the telegram API. Nothing is printed and nothing ever happens, which makes the problem really hard to debug. Especially when the feature should work, as documented by Telegram.

Additional context

I've tried debugging this myself, but the debugger seems to get confused in multiple places. Or maybe I just can't use the Kotlin debugger, idk.

elbekD commented 3 years ago

According to then docs, strikethrough is realized by single ~ around the text: ~strikethrough~. Try this one, it works for me.