Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send bold text using Telegram Python bot

I am writing a telegram bot in Python. I want to send messages with bold letters. I tried to inclose message inside both * and **, but it does not solve the problem.

Is there a function for mark up or HTML formatting or a way to do it?

like image 861
Ramon de Llano Avatar asked Mar 16 '18 18:03

Ramon de Llano


1 Answers

You should use:

bot.send_message(chat_id=chat_id, text="*bold* Example message", 
                parse_mode=telegram.ParseMode.MARKDOWN)

Or:

bot.send_message(chat_id=chat_id, text='<b>Example message</b>', 
                  parse_mode=telegram.ParseMode.HTML)

More info at: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets#message-formatting-bold-italic-code-

like image 200
Gabriel Ben Compte Avatar answered Sep 28 '22 06:09

Gabriel Ben Compte