Skip to content Skip to sidebar Skip to footer

How To Use Contacts.getLocated() From Telegram API With Telethon?

I want to use the new 'People nearby' feature from Telegram. I want to do it in python so I found Telethon. Then, I looked at the Telegram API and found the contacts.getLocated() m

Solution 1:

The Telethon documentation on full API explains how to use all of the raw Telegram methods have to offer. Searching for "get located" we find GetLocatedRequest. There is a button to copy the import, and also example code at the bottom:

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.contacts.GetLocatedRequest(
        geo_point=types.InputGeoPoint(
            lat=7.13,
            long=7.13
        ),
        self_expires=42
    ))
    print(result.stringify())

Needless to say you need to pass the right values in the geo point.


Post a Comment for "How To Use Contacts.getLocated() From Telegram API With Telethon?"