telegram-bot-ruby icon indicating copy to clipboard operation
telegram-bot-ruby copied to clipboard

Send file through url instead of upload

Open JorgeDDW opened this issue 8 years ago • 6 comments

Hi there,

In my part of learn Ruby, JSON, and Telegram Bots I want to make a Pokedext, and here is what i need to send file through the url i get from the API instead of upload from the server: bot.api.send_photo(chat_id: message.chat.id, photo: Faraday::UploadIO.new('~/Desktop/jennifer.jpg', 'image/jpeg'))

What do I need to change in order to use a url ?

JorgeDDW avatar Jul 13 '16 04:07 JorgeDDW

Can you send url as plain text, i.e. using send_message method?

ivanovaleksey avatar Jul 13 '16 05:07 ivanovaleksey

I could do that, but how ever its more cool if just send the image :(

JorgeDDW avatar Jul 13 '16 12:07 JorgeDDW

I am not sure but try to do this

require 'open-uri'
bot.api.send_photo(chat_id: message.chat.id, photo: open(image_url))

ivanovaleksey avatar Jul 13 '16 12:07 ivanovaleksey

not working :( But thanks for trying.

JorgeDDW avatar Jul 13 '16 22:07 JorgeDDW

@JorgeDDW try bot.api.send_message(chat_id: message.from.id, text: "<a href=\"http://fonday.ru/images/tmp/16/7/original/16710fBjLzqnJlMXhoFHAG.jpg\">Cats</a>", parse_mode: "HTML" ) , telegram client`d render image by itself

d4rk5eed avatar Feb 11 '17 19:02 d4rk5eed

If your url is http you can post an image just like this: telegram.api.send_photo(chat_id: <chat_id>, caption: <text>, photo: <http url>)

M1chael avatar Aug 18 '19 13:08 M1chael

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 19 '23 15:02 github-actions[bot]