contacts.GetLocated
Get contacts near you
Example
const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result = await client.invoke(
new Api.contacts.GetLocated({
geoPoint: new Api.InputGeoPoint({
lat: 8.24,
long: 8.24,
accuracyRadius: 43,
}),
selfExpires: 43,
})
);
console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result: Api.Updates = await client.invoke(
new Api.contacts.GetLocated({
geoPoint: new Api.InputGeoPoint({
lat: 8.24,
long: 8.24,
accuracyRadius: 43,
}),
selfExpires: 43,
})
);
console.log(result); // prints the result
})();
Parameters
Name | Type | Description |
---|---|---|
flags | # | Flags, see TL conditional fields |
background | flags.1?true | While the geolocation of the current user is public, clients should update it in the background every half-an-hour or so, while setting this flag. Do this only if the new location is more than 1 KM away from the previous one, or if the previous location is unknown. |
geoPoint | InputGeoPoint | Geolocation |
selfExpires | flags.0?int | If set, the geolocation of the current user will be public for the specified number of seconds; pass 0x7fffffff to disable expiry, 0 to make the current geolocation private; if the flag isn't set, no changes will be applied. |
Result
Possible errors
Code | Type | Description |
---|---|---|
400 | GEO_POINT_INVALID | Invalid geoposition provided. |
406 | USERPIC_PRIVACY_REQUIRED | You need to disable privacy settings for your profile picture in order to make your geolocation public. |
406 | USERPIC_UPLOAD_REQUIRED | You must have a profile picture to publish your geolocation. |
Can bots use this method?
No