Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get client location in bale bot

I have a bale bot. I need to get latitude and longitude of client's location. I used LocationFilter but i got this error.

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'

any ideas?

like image 657
Meysam Rahimi Avatar asked Jun 10 '18 10:06

Meysam Rahimi


1 Answers

This error caused by type of message. it’s a JsonMessage not text. try code below:

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
like image 138
Ehsan Barkhordar Avatar answered Oct 31 '22 13:10

Ehsan Barkhordar