首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在bale bot中获取客户位置

在bale bot中获取客户位置
EN

Stack Overflow用户
提问于 2018-06-10 10:05:45
回答 1查看 79关注 0票数 5

我有个小包机器人。我需要得到客户位置的纬度和经度。我使用了LocationFilter,但是我得到了这个错误。

代码语言:javascript
复制
2018-06-10 14:10:41,980  dispatcher.py:143  ERROR:
"'JsonMessage' object has no attribute 'text'"
Traceback (most recent call last):
  File "/home/ehsan/PycharmProjects/example_bots/balebot/dispatcher.py", line 139, in process_fat_seq_update
    handler.handle_update(self, update)
  File "/home/ehsan/PycharmProjects/example_bots/balebot/handlers/message_handler.py", line 29, in handle_update
    return self.callback(dispatcher.bot, update)
  File "/home/ehsan/PycharmProjects/example_bots/examples/document_conversion.py", line 43, in conversation_starter
    message = update.get_effective_message().text
AttributeError: 'JsonMessage' object has no attribute 'text'

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-10 10:11:32

此错误是由消息类型引起的。这是一个JsonMessage,而不是文本。尝试下面的代码:

代码语言:javascript
复制
def get_store_location(bot, update):
    user_peer = update.get_effective_user()
    user_id = user_peer.peer_id
    latitude = update.get_effective_message().raw_json.latitude
    longitude = update.get_effective_message().raw_json.longitude
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50782577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档