skip to Main Content

When the GPS on the phone is disabled, the user can manually select any point on the map. How can I remove this option to send location?
The variable res handles the distance between two points.
I will be very grateful.

Current code:

@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)

2

Answers


  1. keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
    button_geo = types.KeyboardButton(text="Send location", request_location=True)
    button_back = types.KeyboardButton(text="Back")
    keyboard.add(button_geo, button_back)
    bot.send_message(message.chat.id, "Send your location...", reply_markup=keyboard)
    

    You can to try print on user screen the special button, which make request by user location. It is won’t decide your problem fully, but I think it`s some better. This variant also can be go around. As I know user in any case can send fake location.

    Login or Signup to reply.
  2. Ah yes, the Big Brother daddy issues.

    In a general case, you can’t prevent employees from faking their location without being far, far more intrusive. If they are circumventing your restrictions now, you will achieve precisely nothing by blocking this specific route.

    If I control a device, I may not only select the location manually, I could also spoof it – sprawling communities were created for Pokemon Go, for example. This knowledge is pretty much widely available. You are dealing with a people problem here, not a tech problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search