GramJS

langpack.GetDifference

Get new updates.

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.langpack.GetDifference({
      langPack: "some string here",
      langCode: "some string here",
      fromVersion: 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.LangPackDifference = await client.invoke(
    new Api.langpack.GetDifference({
      langPack: "some string here",
      langCode: "some string here",
      fromVersion: 43,
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
ptsintPTS, see updates.
ptsTotalLimitflags.0?intFor fast updating: if provided and pts + pts_total_limit < remote pts, updates.differenceTooLong will be returned.Simply tells the server to not return the difference if it is bigger than pts_total_limitIf the remote pts is too big (> ~4000000), this field will default to 1000000
dateintdate, see updates.
qtsintQTS, see updates.

Result

updates.Difference

Possible errors

CodeTypeDescription
400CDN_METHOD_INVALIDYou can't call this method in a CDN DC.
400CHANNEL_INVALIDThe provided channel is invalid.
403CHAT_WRITE_FORBIDDENYou can't write in this chat.
400DATE_EMPTYDate empty.
400MSG_ID_INVALIDInvalid message ID provided.
400PERSISTENT_TIMESTAMP_EMPTYPersistent timestamp empty.
400PERSISTENT_TIMESTAMP_INVALIDPersistent timestamp invalid.

Can bots use this method?

Yes

Working with Updates

How to subscribe to updates and handle them properly.

updates.differenceTooLong

The difference is too long, and the specified state must be used to refetch updates.