Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send an image link to telegram without display image url

I need send an image url to telegram without display image url and hidden url. I see a telegram bot and it's do it very well and send long message with image I'm attach this bot result image see it. Now how can do it in my custom bot? It's possible hidden url with MARKDOWN style or any way? I want hidden image url in my text but telegram display my image. see my sample attach image. thank you

enter image description here

like image 596
Matin Avatar asked Sep 19 '16 22:09

Matin


People also ask

How do I turn on link preview in Telegram?

Once you paste a URL to the message input field, Telegram will start analyzing the link and getting a preview for it. If you prefer to send a particular message without the preview, just tap the x to remove it. Rich link previews are now shown for most websites.

What is the URL for Telegram API?

The first part of the URL indicates that you want to communicate with the Telegram API ( api.telegram.org ).


4 Answers

Most of them use the dot (or some things like this character) for link description and you thought there is no link.

You can type the following line and select custom markdown:

@bold [.](http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg)

If you want to add text to your link, you need to create a bot and use this approach in the bot.

Edit:

For sending hyperlink with the bot api you can simply send html markup and using parse_mode. See telegram documents:

To use this mode, pass HTML in the parse_mode field when using sendMessage. The following tags are currently supported:

<b>bold</b>, <strong>bold</strong>
<i>italic</i>, <em>italic</em>
<a href="http://www.example.com/">inline URL</a>
<a href="tg://user?id=123456789">inline mention of a user</a>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>

sample:

<a href="http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg"></a>
like image 190
n.y Avatar answered Oct 16 '22 23:10

n.y


According to the Telegram API, it seems if you set disable_web_page_preview to true, you should get the result you want.

The final message should look something like this:

{
    chat_id: 1235,
    message: "http://your/url",
    disable_web_page_preview: true,
}

EDIT: It seems I misunderstood the question, and you actually want the image to appear by itself rather than the url by itself.

Again, as per the Telegram API you can send an image directly. But as far as I can tell, you can't use a URL to do it. You would have to upload the photo from your telegram server directly. You could use the caption property to send text with it.

Here is an example of how you might be able do this in python. You will need to tweak this to whichever language you are using, but the concept is the same.

import requests

response = requests.post(
    "https://your.bot.url.com/sendPhoto",
    data={
        "chat_id": 1234,
        "caption": "Your extra text here"
    }
    files={
        "photo": (
            "image_name.jpg",
            "contents of image",
            "image/jpg",
            {},
        )
    }
)

The caption property has a limit of 200 characters, so if you want to send more characters then that, you'll have to send two messages.

You can always ask Telegram to add this type of functionality in the future

like image 45
Shadow Avatar answered Oct 16 '22 22:10

Shadow


The answer is zero-width non-joiner (ZWNJ) character. ZWNJ is encoded in Unicode as U+200C ZERO WIDTH NON-JOINER (HTML &#8204; , &zwnj;).

HTML mode:

<a href="https://example.com">&#8204;</a>

MARKDOWN mode:

[‌‌](https://example.com)

Update 2021:

The answer is still working but telegram doesn't let you send an empty text message that include only this character anymore, so you have to add at least one character in the whole text message. In addition you can also use the character Unicode Character 'WORD JOINER' (U+2060) instead.

like image 6
Mehdi Rahimi Avatar answered Oct 16 '22 23:10

Mehdi Rahimi


You can use &#160; character as hidden character.

like image 5
علیرضا Avatar answered Oct 17 '22 00:10

علیرضا