1

In my project, I need to use two telegram bots, which are linked by one database. I faced the following difficulty: having received a photo_id from one bot, I can only use it in this bot, the other bot does not have access to the files.

ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: wrong file identifier/HTTP URL specified

At the same time, exactly the same line of code in the first bot successfully sends a photo

If I try to make an URL with this file, then it is downloaded, therefore, you will not be able to send a photo via the link.

Is it possible to use documents received from another bot without saving them to the database?

  • No, BOT-A will never be able to send data to BOT-B. – 0stone0 Apr 19 '21 at 15:24
  • 4
    Does this answer your question? [Telegram Bot - Bad Request: wrong file identifier/HTTP URL specified](https://stackoverflow.com/questions/47005393/telegram-bot-bad-request-wrong-file-identifier-http-url-specified) – hc_dev Apr 19 '21 at 16:19

1 Answers1

-1

Yes... well maybe. Are you trying to avoid writing to the database to avoid writing to the database specifically or are you trying to avoid any further file handling?

If you are trying to avoid the database because its a database - my proposal would need you to create a shared memory space to do so. Maybe others know of easier ways.

Try memcache or redis. Both have python libraries, I'd personally go with redis due to my own experiences.

I don't know what your architecture is like for checking for updates - I assume you have some kind of scheduler ongoing? In which case you check redis/memcache for updates periodically, download/retransmit the data if it exists, then clear it.

Amiga500
  • 1,258
  • 1
  • 6
  • 11
  • If OP doesn't want to use a database, I don't think Redis would be a great alternative. – 0stone0 Apr 19 '21 at 16:24
  • Depends on their reason for not wanting to commit information to the database. Hence me starting off with that question. – Amiga500 Apr 19 '21 at 16:29
  • Of course, I don't avoid using databases. I am using sqlite3 to store user information. I just don't want to allocate 99% of the used memory for photos, when they can be stored directly on telegram servers. If I had used one bot, this problem would not have arisen. – Alexander Zoly Apr 19 '21 at 17:12
  • The only solution I can imagine so far is the automatic creation of a link that, when opened, will show the photo in the browser, rather than download it, as suggested in posts on a similar topic. – Alexander Zoly Apr 19 '21 at 17:14