Jacopo Taramasso
Jacopo Taramasso

Reputation: 11

disable link preview using python-telegram-bot

i'm trying to create my first bot... I incurred in this... i do not know how to disable link preview in a telegram message. I cannot find how to do that. I'm using https://github.com/python-telegram-bot/python-telegram-bot

for example, I have tried this:

import logging
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
.
.
.
def link(update, context):
     update.message.reply_html(
     text=f"<a href='{link_to_send}'>This is an example</a>",    
    )
.
.
.

but the link is previewed. I tried to add the parameter disable_web_page_preview=None as I seen on https://docs.python-telegram-bot.org/en/v20.0a4/telegram.message.html, but in my case it is not recognized as a parameters. Where am I wrong?

Upvotes: 1

Views: 1749

Answers (1)

grebulon
grebulon

Reputation: 7982

Newer bot api changed sendMessage parameter to link_preview_options passing it a stringified json of type LinkPreviewOptions.

Upvotes: 1

Related Questions