pyTelegramBotAPI disable link preview
Asked Answered
A

3

7

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

Anion answered 30/12, 2019 at 19:25 Comment(1)
Ostone0's answer is fine, just wanted to mention you can also use the disable_web_page_preview=True on the reply_text method.Elsa
T
20

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):
Tribunal answered 30/12, 2019 at 19:40 Comment(0)
G
3

Try using link_preview/disable_web_page_preview parameter.

client.send_message('chat_name', '[link](example.com)', parse_mode = "Markdown", link_preview=False)
Geanticlinal answered 14/8, 2020 at 19:42 Comment(0)
B
3

To me this works:

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

(Python 3.8, Telethon 1.24)

Bullhead answered 19/7, 2022 at 0:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.