B
B
Bla Bla2020-11-26 17:53:37
Node.js
Bla Bla, 2020-11-26 17:53:37

How to make a telegram bot that sends a picture by url?

I'm using telegraf and when I send a photo to a url it becomes a problem because I get this error: Error: 400: Bad Request: there is no photo in the request, but when I use a local photo (../ img.jpg ), this is normal. And yes, at first I did not connect telegraf and used the standard telegram api and therefore used the following command: bot.sendPhoto (chatId, url_photo, {caption: 'Picture'}), where I can call the image by URL and there was no error, but now I take telegraf, as it is easier to use, but sending by url does not work. The code:

let photo = 'https://img-9gag-fun.9cache.com/photo/azmpDRN_460s.jpg';
  bot.telegram.sendPhoto(chatId,
    {source: photo},
    {caption: "Hello"});
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Israfil22, 2020-11-26
@SubUser

I'm looking at your library's API right now.
It says here that you need to pass a string as the second parameter, in your case a url, not an object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question