Home python pytelegrambotapi | Sending images from user

pytelegrambotapi | Sending images from user

Author

Date

Category

I want to make a simple echo bot, I need that Bot would send the images that the bot was sent.
That’s what I tried:

import telbot
Bot = TELEBOT.TELEBOT (':)')
@ Bot.Message_Handler (CONTENT_TYPES = [Photo '])
DEF Get_Text_Messages (Message):
  Bot.Send_Message (Message.From_user.id, Message.photo)
Bot.Polling (None_stop = True, Interval = 0)

But in response I do not get an image, but information about it.

{'file_size': 4501, 'file_unique_id': 'aqadgzigoi4aa4xvaai', 'height': 150, 'width' : 320, 'File_id': 'agacagiaaxkbaammyg25zzrjbpzcsa1kfpn9aztxveiaapqymrsljmll5cnnbrxfox0boiailgadaqadagadbqadhduaah4e'}

As using Message.Photo Send Image ?


Answer 1, Authority 100%

You need to use the send_photo method and is enough to specify the image file ID:

@ bot.message_handler (content_types = ['photo'])
DEF Get_Text_Messages (Message):
  Bot.Send_Photo (message.from_user.id, Message.photo [0] .file_id)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions