How do I get my Telegram bot to write in monospace?
Question:
I am trying to write something in "monospace" with my telegram bot using the following Python function:
@bot.message_handler(commands=['test_monospace'])
def test_monospace(message):
bot.reply_to(message, "```This message should be in monospace```")
Unfortunately, when I test the bot I get the message without the monospace formatting
How can I get it to use monospace?
Answers:
You probably need to set the parse_mode
to MarkdownV2
:
bot.reply_to(message, "```This message should be in monospace```", parse_mode='MarkdownV2')
You could also use the telegram.Message.reply_markdown_v2
shortcut.
I am trying to write something in "monospace" with my telegram bot using the following Python function:
@bot.message_handler(commands=['test_monospace'])
def test_monospace(message):
bot.reply_to(message, "```This message should be in monospace```")
Unfortunately, when I test the bot I get the message without the monospace formatting
How can I get it to use monospace?
You probably need to set the parse_mode
to MarkdownV2
:
bot.reply_to(message, "```This message should be in monospace```", parse_mode='MarkdownV2')
You could also use the telegram.Message.reply_markdown_v2
shortcut.