必须让bot捕获一条消息中发送的多张照片,并通过一条消息将它们发送到频道。我尝试这样做:
@dp.message_handler(content_types=["photo"])
async def get_foto(message: types.Message, state: FSMContext):
async with state.proxy() as data:
if type(data.get('photo')) is list:
data['photo'].append(message.photo[-1].file_id)
data["time"] = time()
return
else:
data['photo'] = [message.photo[-1].file_id]
data["time"] = time()
wait_time = 3
while time() - data["time"] < wait_time:
await sleep(0.1)
print(data['photo'])
#poli = data['photo'][0]
poli = types.MediaGroup()
poli.attach_photo(data['photo'][0])
#print(poli['media'][0])
await bot.send_media_group( chat_id = config.chat_id, media = poli)
async with state.proxy() as data:
del data["time"]
del data["photo"]
但没有用。仅捕获并发送第一张照片