Send an image link to telegram without display image url - image

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

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>
inline URL
inline mention of a user
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
sample:

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

The answer is zero-width non-joiner (ZWNJ) character. ZWNJ is encoded in Unicode as U+200C ZERO WIDTH NON-JOINER (HTML ‌ , ‌).
HTML mode:
‌
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.

You can use   character as hidden character.

This might help:
It works for both:
web links
telegram links

import requests
def telegram(channel,bot,text,img):
if(text==""):text="Refer - "
r = requests.get('https://api.telegram.org/bot'+bot+'/sendMessage?chat_id=#'+channel+'&parse_mode=markdown&text='+"[​​​​​​​​​​​]("+img+")"+text)
Use the above function. It will work perfectly. In case, there is no text and only image, it should break. So it will show a "." (dot) in those cases.
Now use the function -
telegram(your_channel_name,your_token_here,description,image_url)

To correctly send an image hosted on a website without showing any reference link, you must use the "html" parsing mode.
And in the content to send, for example, something like this (Python mode):
# We take the html address of the image.
image_address = 'https://picsum.photos/100.jpg'
# The unicode character to prevent the words from
# being separated, in this case, we take advantage
# of it so that the Telegram API accepts it and
# incidentally so that it does not take up space
# when including text in the message.
word_joiner = '&#8288'
# This would be the final pattern.
html_pattern = f'{word_joiner}'

With HTML parse mode. Keep empty space between the opening and closing tag.

Related

Displaying vCard photos in Windows Contacts

Following vCard 2.1, I'm adding photos to vCards. I'm encoding the image fetched from a URL, then adding the encoded value to the proper place within the vCard. This seemingly displays the photo correctly for all programs that can open vCards except the Windows Contacts program on Windows 7 (probably doesn't work for newer versions of Windows either).
As far as I can tell, the below snippet should display the vcard photo when opened in Windows Contacts:
BEGIN:VCARD
VERSION:2.1
N;CHARSET=ISO-8859-1:Lastname;Firstname;
FN;CHARSET=ISO-8859-1:Firstname Lastname
ORG;CHARSET=ISO-8859-1: Organization LLP
PHOTO;ENCODING=b;TYPE=jpg: <base64 encoded image as one line>
TITLE;CHARSET=ISO-8859-1:Position
TEL;WORK;VOICE:+1 999 999 9999
END:VCARD
All the other information displays in Windows Contacts, but not the photo. The standard blank image placeholder displays.
I have tried
ENCODING=BASE64
ommitting the ENCODING keyword altogether
removing the TYPE keyword altogether
using specifically a 240px by 240px image
adding the image URL value in the file instead of the encoded value
Anyone have any ideas?
Version 2.1 uses ENCODING=BASE64.
Put an empty line after the PHOTO property. Outlook requires this, so Contacts might too.
Put all parameter names/values in upper case. I know of one compatibility problem with Windows Contacts where it doesn't recognize a parameter value if it's in lower case.
Remove the space character before the base64 data.
Try setting the TYPE parameter to JPEG.
You've correctly encoded the image data, right? Try using an online decoder to make sure.
Corrected property:
PHOTO;ENCODING=BASE64;TYPE=JPEG:<base64 encoded image as one line>
[empty line]
According to the specs, if you have a URL, you should set the VALUE parameter to URL.
PHOTO;TYPE=JPEG;VALUE=URL:<url goes here>
I've run into your post while researching this question and I was able to successfully find the correct way to achieve this.
Bellow is a self-containing example of a v-card containing an 96x96 embedded red.gif image as the PHOTO.
https://www.rfc-editor.org/rfc/rfc2426#section-3.1.4
Be sure to note the VERSION line and the PHOTO line. This is currently working in Outlook365.
BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest;;Mr.;
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;ENCODING=BASE64;TYPE=GIF:R0lGODdhYABgAPAAALccHMlFJiH5BAEAAAEALAAAAABgAGAAAAJuhI+py+0Po5y02ouz3rz7D4biSJbmiabqyrbuC8fyTNf2jef6zvf+DwwKh8Si8YhMKpfMpvMJjUqn1Kr1is1qt9yu9wsOi8fksvmMTqvX7Lb7DY/L5/S6/Y7P6/f8vv8PGCg4SFhoeIiYqLiIUgAAOw==
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
ADR;TYPE=WORK;PREF=1;LABEL="100 Waters Edge\nBaytown\, LA 30314\nUnited States of America":;;100 Waters Edge;Baytown;LA;30314;United States of America
ADR;TYPE=HOME;LABEL="42 Plantation St.\nBaytown\, LA 30314\nUnited States of America":;;42 Plantation St.;Baytown;LA;30314;United States of America
EMAIL:forrestgump#example.com
REV:20080424T195243Z
x-qq:21588891
END:VCARD

Pinterest removing the media parameter

I'm having a bad time trying to implement a simple PinIt button.
I followed all the process and it works fine, with an exception: it is removing the Media parameter from the anchor tag.
This means that the PinIt button will open a window showing all the images from that page and the user needs to select one.
The source is ok:
<img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_white_20.png" />
But, when the page is loaded, the pinit.js is replacing the parameters.
I have tried to find a solution on the web and read something about the URL Enconde, I have tried with UTF-8 and ISO-8859-1 but without success.
The rendered html is:
<span class="PIN_1395089773564_hidden" id="PIN_1395089773564_pin_count_0"><i></i></span>
The media parameter is there, empty.
Thanks for your time,
William Borgo.
I believe the problem is actually in your url parameter. It cannot contain hashtags or other types of parameters. If you delete ?idItem=6920 from the url it will probably work.
I think your URL encoding is incorrect and is confusing Pinterest as to what is part of the Pinterest URL and what is part of one of the parameters - essentially where each parameter begins and ends, and what's a separate parameter for Pinterest vs a continuation of a previous parameter. (This is really the purpose of URL encoding for parameters.)
That is, the overall Pinterest URL should be like:
www.pinterest.com/pin/create/button/?url=[url]&media=[media]&description=[description]
The "&" separating the url, media, and description parameters should NOT be encoded. But each of the parameters themselves (the parts in [brackets]) SHOULD be encoded.
So for instance:
https://www.pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.tokstok.com.br%2Fvitrine%2Fproduto.jsf%3FidItem%3D121826&media=http%3A%2F%2Fwww.tokstok.com.br%2Fpnv%2F570%2Fc%2Fconnmlt_czbr1.jpg&description=CONNECTION%20MESA%20PARA%20LAPTOP
...which you could look at like this (with line breaks between parameters and some spacing):
https://www.pinterest.com/pin/create/button/
?url = http%3A%2F%2Fwww.tokstok.com.br%2Fvitrine%2Fproduto.jsf%3FidItem%3D121826
&media = http%3A%2F%2Fwww.tokstok.com.br%2Fpnv%2F570%2Fc%2Fconnmlt_czbr1.jpg
&description = CONNECTION%20MESA%20PARA%20LAPTOP
(Note: the URL you gave seems not to be active any more, so I grabbed another product from the site.)

Send an image in an email with Grails

I am using the Grails mail plugin to send emails and I want to send images in the body of the email, not as attachment. What I want is for images to be shown in the email body itself, as in newsletters. I tried:
img style="display:block; height:100px; width:100; " alt="candle"
src="http://www.xyz.com//Candle_4.jpg">
but it is being displayed as-is.
I also tried using the wikimedia format:
[[:File:Example.jpg]]<br/>
[[Special:FilePath/Example.jpg]]
but again, both seem to link to external.
What am I doing wrong?
This is the email template I am using:
<img src="cid:springsourceInlineImage" /> Dear [username],<br/>
Thank you for shopping with us.<br/>
You have placed a new order with following details.<br/>
[details]<br/>
Happy shopping!
But, if I want to put 10 images in my template, how would I do that?
You have to do three things
Declare mail as multipart
Attach your image as inline image
Reference you inline image from your mail template
According to this mailing list thread it should work like this:
sendMail{
multipart true
to "[hidden email]"
subject "Subject goes here"
html g.render( template: '/emails/mailTemplate')
inline 'springsourceInlineImage', 'image/jpg', new File('./web-app/images/springsource.png')
}
In your template you could refer the image like this
<img src="cid:springsourceInlineImage" />
Hope that helps.
In general, most "newsletter" type emails are just HTML emails and don't in-line the images within the body of the emails. In fact, many email servers will outright reject emails that are too big, and putting the image data inside the body of the email can easily run this risk.
Instead, the way to do with this is to just have HTML emails with the images you wish to include as normal HTML image links.
Please refer to the Mail plugin documentation for more info on how to send HTML emails.
Sorry I don't have enough Stackoverflow points to leave comment on others' answers.
In #aiolos 's answer, it contains:
inline 'springsourceInlineImage', 'image/jpg', new File('./web-app/images/springsource.png')
This specifies 'image/jpg' as the output, but the file is in png format. Is this intentional?
Wikipedia provides a list of mime types: http://en.wikipedia.org/wiki/Internet_media_type#Type_image
I tried 'image/png' and it worked, so I'm not sure if setting it to 'image/jpg' makes any difference.

CodeIgniter santizing POST values

I have a text area in which I am trying to add youtube embed code and other HTML tags. $this->input->post is converting the <iframe> tags to < and > respectively but not the <h1> and <h2> tags.
Any idea how I can store these values?
If you only have a small number of forms that you need to allow iframes in, I would just write a function to restore the iframe (while validating that it's a valid YouTube embed code).
You can also turn off global_xss_filtering in your config (or not implement it if you're using it), but that's not the ideal solution (turning off all of your security to get one thing to work is generally a horrible idea).
$config['global_xss_filtering'] = FALSE;
To see all of the tags that get filtered out, look in the CI_Input class and search for the '$naughty' variable. You'll see a pipe-delimited list (don't change anything in this class).
Why don't you avoid CIs auto sanitizing and use something like htmlspecialchars($_POST['var']); ? Or make a helper function for sanitizing youtube urls...
Or you could either just ask for the video ID code or parse the code from what you are getting.
This would let you use both the URL or the embed code.
Also storing just the ID takes less space in you database, and you could write a helper function to output the embed code/url.
In this case, use $_POST instead of $this->input->post to get the original text area value, and then use HTML Purifier to clean the contents without losing the <iframe> tag you want.
You will need to check HTML Purifier documentation for details. Please, check this specific documentation page about "Embedding YouTube Videos".

How to identify or read nsf mails containing inline image

I am trying to read mails programmatically in VB6. but i am unable to read mails containing inline images or HTML code like hyper link. Can anyone suggest me the way to read this type of mails.
EDIT:
I am not getting any error message but
nsfDocument.GETITEMVALUE("Body")(0) returns only text.
images are not shown.
You may want to try a third party API to help, such as the Midas Rich Text C++ API from Genii Software. http://www.geniisoft.com/showcase.nsf/MidasCPP
Or try the code examples shown on this site to gain access to the Notes Document in HTML form: http://searchdomino.techtarget.com/tip/0,289483,sid4_gci1284906,00.html
The GetItemValue method of the Document class returns rich-text item values as an array of strings, with all rich text styling removed. The "body" field in a Notes email is generally rich text. So, you should look into using the GetFirstItem method, instead. That will return a NotesRichTextItem object (for the body field). From that object, you can access the styling of the text, hyperlinks and file attachments, etc. (I do not believe that you can access in-line images at all via the "back-end" COM classes - I think for that, you will need to drop down to use the C API classes).
Here's a quick sample of how to get a NotesRichTextItem handle:
Dim doc As NotesDocument
Dim rtitem As Variant
... get the document
Set rtitem = doc.GetFirstItem( "Body" )
If rtitem.Type = RICHTEXT Then
.. work with rtItem
End If
Here is the doc page for the NotesRichTextItemClass:
http://publib-b.boulder.ibm.com/lotus/c2359850.nsf/2e73cbb2141acefa85256b8700688cea/dc72d312572a75818525731b004a5294?OpenDocument
And here is a starting point for the C API docs:
http://www14.software.ibm.com/webapp/download/nochargesearch.jsp?k=ALL&S_TACT=104CBW71&status=Active&q=Lotus+%22C+API%22

Resources