C
C
Cyril2020-04-26 20:28:14
Python
Cyril, 2020-04-26 20:28:14

How to send a picture sent by a user to python-telegram-bot?

How to make a bot send a picture sent to it by a user like an echo bot with text?
I made this handler:

updater.dispatcher.add_handler(MessageHandler(Filters.photo, get_pic))

And the function looks like this:
def get_pic(update, context):
    photo = update.message.file_id
    update.send_photo(chat_id=update.message.chat_id, photo=photo, reply_markup=full_keyboard())

But when sending, nothing happens. What to fix?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cyril, 2020-04-26
@Pus1st

Searching in other people's codes led to this:

def get_pic(update, context):
    photo = update.message.photo[-1]
    update.message.reply_photo(photo=photo, reply_markup=full_keyboard())

V
Vladislav the Wise, 2020-04-26
@yungtitanium

context.bot.send_photo(chat_id=chat_id, photo=photo, reply_markup=full_kb)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question