Guest User

Photo Album Handler

a guest
Aug 17th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. @dp.message_handler(state=Area.photo, content_types=types.ContentType.PHOTO)
  2. async def sale_photo_added_handler(message: types.Message, state: FSMContext):
  3.     user = message.from_user.id
  4.     recieved_text = message.text
  5.  
  6.     try:
  7.         count = len(os.listdir(os.getcwd()+"\\Users\\" + str(user)))
  8.     except Exception as e:
  9.         count = 0
  10.  
  11.     photo = await bot.get_file(message.photo[-1].file_id)
  12.     await photo.download(os.getcwd()+"\\Users\\" + str(user)+"\\{}.jpg".format(count+1))
Add Comment
Please, Sign In to add comment