I have developed a chatbot in Telegram to get user's photo sent using the following API:
https://core.telegram.org/bots/api#sendmessage
And able to get the file use the following API:
https://core.telegram.org/bots/api#getfile
However, the file downloaded lost the EXIF attributes. Is telegram strip all the data? Or is there any way to get the original file?
No there is no way to get original image. Telegram optimize photo for user display.
but if user send the photo as file (document) then you can get the image without any change/optimize from Telegram.
Related
I have a bot which creates messages including some urls provided by users.
Telegram creates link previews for those urls. The previews are cached.
Sometimes the content of the url changes, then the preview provided by Telegram is outdated. So I need to update the link preview provided by Telegram.
Telegram link previews can be updated using https://telegram.me/webpagebot. But according to Telegram Bot API, a bot can't talk to another bot to avoid infinite loops. So opening a chat between my bot and webpagebot to request the update is not an option.
How could I force the update of a link preview from my bot? Is there some http request, API, or whatever to do it programmatically?
You may add a randomly generated variable to the end of the link, so Telegram looks a link as a new link, like this:
Suppose a old link is like:
https://example.com/offers/106-tatasky-recharge
If you change og_image, title, meta description of this page, then use the above link as:
https://example.com/offers/106-tatasky-recharge?t=18121980
I think, it solves the problem.
There is an applet which allows to send text messages from telegram to some email. Unfortunately there is a limitation: it only works with text.
I would like to have the same functionality, but for images, video and may be audio. I suppose media content should be attached to the email.
Is there a tool for this task? If no, what is the easiest way to implement it?
You need split this idea to a few and search for each of following topics:
echo bot using python-telegram-bot
python-telegram-bot and Telegram object types (photo, video, etc.)
how to send email using python and SMTP
how to add attachments email using python
After that you'll be able to understand what else is missing.
Is there any way to send a voice command to Telegram bot?
I want to send voices to my bot and use google API to convert them to text and then translate and send back.
In order to do this, I need to get the voice first. Is there any way to send the voice to the bot?
You can find file_id from Voice update, and then obtain download path via the getFile method.
This object represents a file ready to be downloaded.
The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>.
In above instance, you can download from https://api.telegram.org/file/bot485609210:mySecret/voice/file_178.
You can send a voice message to the bot, which would be stored on your server. Than convert it to text using Google API, translate and send back. Do you want to send it back as text?
I'm working on a telegram bot and I need to download photo, audio, video sent by user to the bot. Using the only path returned by the get file method I only get a thumbnail. In fact the only result of the get file method contains a really tiny value for the file size. I can't figure out where the problem is. The photos are normally sent by message as photo (not as file).
first you should download the photo with this api to your bot
https://api.telegram.org/bot<token>/getfile?file_id={the file_id of the photo you want to download}
then it returns you a response of a File which has an attribute named file_path
then using the file_path you can download the photo full size using this
https://api.telegram.org/file/bot<token>/<file_path>
all of this is based on official documentation found here .
Telegram API Doc
According to Telegram docs:
Link Preview is generated server-side
I'm trying to make a bot to process the info in the link preview for links sent by users, but I couln't find a way to get that information from the Bot API.
Is there any way to ask the API for the information the link preview shows?
Although there is no API method to get this information, Telegram uses the Open Graph Protocol to generate its Link Previews.
Any open graph client will provide the same information that Telegram shows in their Link Previews.
Is there any way to ask the API for the information the link preview shows?
The answer would be no. The Bot API cannot process the information in the link preview.
I'm trying to make a bot to process the info in the link preview for links sent by users
However if you want the bot to know what is on the other side of the link, It is possible. You can use a HTML content scrapping library and a Summarizing library to get a link preview. I have attached below the libraries you can use and a Reddit bot which is somehow close to what you need. The example libraries are in python but you can essentially get or make for the language you use.
python-goose is a HTML content scrapping library
python summarizing library
another python summarizing library
sample reddit bot
Telegram MessageEntity object