@dp.message_handler(content_types=['photo'])
async def checker(message: types.Message):
number = random.randint(1,999999)
text = message.caption
await message.photo[-1].download(f'{number}.jpg')
photo = open(f'{number}.jpg','rb')
users = cursor.execute("SELECT user FROM users").fetchall()
otpr = 0
nootpr = 0
print(users)
for user in users:
try:
await bot.send_photo(user[0],photo = photo,caption = text)
otpr = otpr + 1
time.sleep(0.3)
except Exception:
nootpr = nootpr + 1
traceback.print_exc()
await bot.send_message(message.chat.id,text = f"<b>Рассылка завершена</b>\n\n<b>Отправлено: {otpr}\nНе отправлено: {nootpr}</b>",parse_mode = 'HTML')
node js