如何找出它是用户的当前位置还是地图上的选定地点 [英] How to find out whether it's user's current location or a chosen spot on map

查看:26
本文介绍了如何找出它是用户的当前位置还是地图上的选定地点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取用户的当前位置.

I need to get user's current location.

我可以通过位置键盘询问位置,用户点击它会发送他当前的位置.但他也可以回复消息,选择地图上的任何位置并分享.

I can ask for location by location keyboard and user will send his current location clicking on it. But he can also reply to message, choose any location on map and share it.

无论哪种方式,返回给我的机器人的结果都是相同的.(至少在我看来.)

Either way, the returned results to my Bot are identical.(At least as I see.)

有什么方法或技巧可以确保共享位置也是他当前的位置吗?

Is there a way or a trick to make sure that the shared location is also his current?

仅供参考 - 我正在使用 TeleBot 库编写的 Node.js.(尽管我认为它不会影响答案.)

FYI - I'm using TeleBot library written in Node.js.(Even though I don't think it will affect the answer.)

推荐答案

我的解决方法是要求用户发送位置两次.

My workaround is I ask user send the location twice.

如果两个位置不同.我会不断要求他们发送新位置.

If two location are different. I will keep ask them to send new location.

另一个解决方案是我创建了另一个内联机器人,它将创建一个包含安全检查的 Venue 结果.Venue 由内联机器人使用当前用户位置生成.

Another solution is I create another inline bot which will create an Venue result which includes security check. The Venue is generate by the inline bot using current user location.

无论如何,我想使用本机电报机器人 API 来做到这一点.希望 Telegram 团队在未来添加此功能.

Anyway, I would like to use native telegram bot api to do that. Wish Telegram team add this feature in future.

更新:Telegram 4.4 发布了一个新功能 - 很难欺骗的实时位置https://telegram.org/blog/live-locations

Updates: Telegram 4.4 released a new feature - live location which is very difficult to cheat https://telegram.org/blog/live-locations

这篇关于如何找出它是用户的当前位置还是地图上的选定地点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆