telegramtelegram-bot

Telegram API, how to add newlines?


Tried many way with parse_mode: Markdown or HTML:

curl -s "https://api.telegram.org/bot$botToken/sendMessage" \
-H 'Content-Type: application/json' \
-d '{ "parse_mode": "Markdown", "chat_id": "234567", "text": "xxx", "description": "xxxxxxx" }

But nothing works.

Searched many web sites. API doc https://core.telegram.org/bots/api#formatting-options don't say anything about newlines.

How can I do to preserve \n from my input text?


Solution

  • Its supported by default. I need to double my newlines:

    message="$(perl -pe 's/\n/\\n/g' <<< "$message")"