@dp.message_handler(state=UserState.location, content_types=['location'])
async def handle_location(message: types.Message, state: FSMContext):
user_loc1 = message.location.latitude
user_loc2 = message.location.longitude
data = await state.get_data()
org_loc1 = data['id_in_qr'][0]
org_loc2 = data['id_in_qr'][1]
res = geolocation.ras(user_loc1, user_loc2, org_loc1, org_loc2)
if res > 200 or not res:
await message.answer('Вы еще не дошли до работы', reply_markup=types.ReplyKeyboardRemove())
await UserState.location.set()
else:
await message.answer(f'Вы пришли на работу в ', reply_markup=types.ReplyKeyboardRemove())
await state.finish()
for file in glob.glob(f"data/{message.from_user.id}{message.date}.png"):
os.remove(file)