【问题标题】:pyTelegrambotApi how to add photo?pyTelegrambotApi 如何添加照片?
【发布时间】:2020-09-22 23:54:45
【问题描述】:

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

【问题讨论】:

标签: python bots telegram py-telegram-bot-api


【解决方案1】:
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])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-31
    • 2020-03-19
    • 1970-01-01
    • 1970-01-01
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多