0

我制作了一个机器人来收集包括照片在内的一些信息,我需要保存照片。我只能从相册中保存 1 张照片,如何保存所有内容?

我将 python3 与 pyTelegramBotAPI 一起使用

@bot.message_handler(func=lambda message: True, commands=['test'])
def test(message):
   text_message = 'some question' 
   bot.send_message(message.chat.id,text_message) 
   bot.register_next_step_handler(message, test2) 

def test2(message):
   file_info = bot.get_file(message.photo[-1].file_id)
   print(file_info) 

我需要获取一组数据或下载所有照片。

4

1 回答 1

0

您可以创建一个列表并在用户发送和图像时附加它。

@bot.message_handler(commands=['sendimage'])
def sendimage(m):
  cid = call.message.chat.id
  mid = call.message.message_id
  info = call.data

  msg= bot.send_message(cid, 'Send Image')
  bot.register_next_step_handler(msg, step_add_image)

def step_add_image(m): 
  cid = m.chat.id
  photo_id= m.photo[-1].file_id
  addImg(cid,photo_id)
  bot.send_message(cid,'Next photo is added')
  bot.send_photo( cid, photo_id,reply_markup=aceptarPinKeyboard)

def addImg(cid, photo_id):
    # Here you can add image id in JSON, DATABASE,...
于 2019-08-07T09:22:44.740 回答