M
M
Matvey2022-01-06 21:25:17
Python
Matvey, 2022-01-06 21:25:17

How to make bold text and a picture under a link in a Telegram bot?

How to make such an attached picture in a telegram bot as in the screenshot I am making a
bot in python
The pyTelegrambotapi library
61d733b8eb52b372735604.png And another question. How to make text bold?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
asinco, 2022-01-06
@mlt_melt

The text preview image is a link to the article. It appears automatically
To make the text different styles, you need to register a special attribute parse_mode=HTML

def jordan(bot, update):
    chat_id = update.message.chat.id
    with open('JordanPeterson.jpg', 'rb') as jordan_picture:
        caption = "<a href='https://twitter.com/jordanbpeterson'>Jordan B. Peterson</a>"
        bot.send_photo(
            chat_id, 
            photo=jordan_picture, 
            caption=caption,
            parse_mode=ParseMode.HTML
        )

Also, this parse_mode can be specified when importing the bot token. To make the text bold, you need to write like this:
msg = <b>Jordan B. Peterson</b>

Z
Zettabyte, 2022-01-06
@Zettabyte

I will supplement the next answer:
The picture is indeed taken from the site you are referring to. Default source - Open Graph protocol, property og:image: https://ogp.me/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question