Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

telegram bot - unable to send high resolution photo via send_photo method of Telgram bot API

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.

question from:https://stackoverflow.com/questions/65848376/unable-to-send-high-resolution-photo-via-send-photo-method-of-telgram-bot-api

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...