Philippe
Philippe

Reputation: 319

pyTelegramBotAPI disable link preview

Currently writing my first bot using pyTelegramBotAPI. I want to disable link previews on certain messages. How do I do this?

Upvotes: 7

Views: 20941

Answers (4)

PN127
PN127

Reputation: 1

If you use the telebot library, you need to add the disable_web_page_preview = True argument when sending a message to the user

bot.send_message(message.chat.id, 'text with url', disable_web_page_preview=True)

Upvotes: 0

Luss Sh
Luss Sh

Reputation: 41

To me this works:

client.send_message(chat_name, msg, link_preview=False)

(Python 3.8, Telethon 1.24)

Upvotes: 3

Denis da Mata
Denis da Mata

Reputation: 510

Try using link_preview/disable_web_page_preview parameter.

client.send_message('chat_name', '[link](example.com)', parse_mode = "Markdown", link_preview=False)

Upvotes: 3

0stone0
0stone0

Reputation: 43904

It looks like there is an disable_web_page_preview parameter on the sendMessage method.

tb = telebot.TeleBot(TOKEN)
tb.send_message(123456, "Hi <link>", disable_web_page_preview=True)

Original code;

def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_message_id=None, reply_markup=None,
                 parse_mode=None, disable_notification=None):

Upvotes: 20

Related Questions