pyTelegrambotApi如何添加照片?



我正在使用pyTelegramapiBot(Python(做电报机器人。它的工作原理是一系列问题,并显示一般信息。我想添加上传照片的功能。 逻辑:用户输入姓名,姓氏,他的照片。并向他展示了一张照片的一般信息。 问题:如何在需要时准确获取用户的照片?否则,什么都不会发生。

def addImage(message):
if not message.photo:
msg = bot.send_message(message.chat.id, "Add image")
bot.register_next_step_handler(msg, addImage)
return
item = data[message.from_user.id]
item.photo = message.photo[-1].file_id
bot.send_photo(message.chat.id, photo=item.photo])

最新更新