1

Using telegram bot api in python, I am sending photo using a file.

  1. First I get the photo from a url.
  2. Save the photo to disk. (Full Resolution)
  3. Read the file and pass it to bot.send_photo
  4. Get the file_id contained in returned Message object and save it.
  5. Next time I send via file_id upon new /command.

First request:

file = open(get_filename(), 'rb')  
msg = context.bot.send_photo(chat_id, file, caption=None)  
fileid = msg.photo[len(msg.photo)-1].file_id

Second and onwards ...

context.bot.send_photo(chat_id, photo=get_fileid(), caption=None)
context.bot.send_message(chat_id, text=EXPLANATION)

Here file ID represent the highest resolution file id available in PhotoSize array.

enter image description here

Here is the file id: AgACAgQAAxkDAAIBMmAK636SiNEGCA8UILZ55gVppXfqAAIytjEbqp1RUJwNFOjmz7N6ZoHuJ10AAwEAAwIAA3cAAwRjBAABHgQ

Problem: I am receiving 1k resolution photo in bot chat. Please advise what I am missing here.

omer
  • 522
  • 1
  • 8
  • 26

0 Answers0