I am scraping telegram and I could get every message instance with client.iter_messages in a chat but I want to get the latitude and longitude of the location if the message instance is a location share message.
for message in client.iter_messages('John'):
print(message.text) #prints message
------------------ #I want the latitude and longitude of the location if the message is a location share message and not a text message
A little help would be appreciated, Thank You.
First act only when the message is a location share message (message.geo
), else no need
location = message.geo #returns a GeoPoint object if the message is a location share message else returns None
if location is not None:
longitude = location.long
latitude = location.lat
print(longitude, latitude)