Search code examples
pythonpython-3.xtelegramtelegram-botpy-telegram-bot-api

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?


Solution

  • 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):