17

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?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Ramon de Llano
  • 365
  • 1
  • 2
  • 11

2 Answers2

32

You should use:

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

Or:

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

More info

Bulent Vural
  • 2,630
  • 1
  • 13
  • 18
2

This is a little bit late. But i hope to be helpful for others:

import telepot
token = 'xxxxxxxxxxxxxxx' # Your telegram token .
receiver_id = yyyyyyyy # Bot id, you can get this by using the next link :  
https://api.telegram.org/bot<TOKEN>/getUpdates. Note that you should 
replace <TOKEN> with your token. 

bot = telepot.Bot(token) 
message = "*YOUR MESSAGE YOU WENT TO SEND.*" #Any characters between ** will be 
send in bold format. 

bot.sendMessage(receiver_id, message , parse_mode= 'Markdown' )  
A. chahid
  • 184
  • 2
  • 5