I have tried this
elif command == 'bold':
telegram_bot.sendMessage (chat_id, str("*bold*"), reply_markup=markup)
But it is replying *bold*
instead of bold
In the mobile version of Telegram on Android, the monospaced text is done as follows: select the typed text, click on the icon in the form of three horizontal dots and in the displayed list select the type of face "Mono". In iOS, also select the typed text, click "B / U", then select the type of face "Monospace".
You need to provide a parse_mode
Parameter (parse_mode="Markdown").
Or else you will not see any markdown style.
sendMessage(chat_id, "*this text is bold*", parse_mode= 'Markdown')
See
https://telepot.readthedocs.io/en/latest/reference.html#telepot.Bot.sendMessage
I had that same issue with Markdown parse_mode. I've written send_message on my own, without using telepot's sendMessage method. In this case, its much easier to understand how to deal with this problem:
url = 'https://api.telegram.org/bot<token>'
def send_message(chat_id, text='empty line', parse_mode = 'Markdown'):
URL = url + 'sendMessage'
answer = {'chat_id': chat_id, 'text': text, 'parse_mode': 'Markdown'}
r = requests.post(URL, json=answer)
return r.json()
if (text == '/bold'):
send_message(chat_id, 'Here comes the'+'*'+'bold'+'*'+'text!')
On the other hand, you could use curl for sending bold text:
if (text == '/bold'):
URL = url + 'sendMessage?chat_id='+chat_id+'&text=*Here comes the bold text*&parse_mode=Markdown'
answer = {'chat_id': chat_id, 'text': text}
r = requests.post(URL, json=answer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With