account.InitTakeoutSession
Initialize account takeout session
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.account.InitTakeoutSession({
contacts: true,
messageUsers: true,
messageChats: true,
messageMegagroups: true,
messageChannels: true,
files: true,
fileMaxSize: BigInt("-4156887774564"),
})
);
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.account.Takeout = await client.invoke(
new Api.account.InitTakeoutSession({
contacts: true,
messageUsers: true,
messageChats: true,
messageMegagroups: true,
messageChannels: true,
files: true,
fileMaxSize: BigInt("-4156887774564"),
})
);
console.log(result); // prints the result
})();
Parameters
Name | Type | Description |
---|---|---|
flags | # | Flags, see TL conditional fields |
contacts | flags.0?true | Whether to export contacts |
messageUsers | flags.1?true | Whether to export messages in private chats |
messageChats | flags.2?true | Whether to export messages in basic groups |
messageMegagroups | flags.3?true | Whether to export messages in supergroups |
messageChannels | flags.4?true | Whether to export messages in channels |
files | flags.5?true | Whether to export files |
fileMaxSize | flags.5?int | Maximum size of files to export |
Result
Possible errors
Code | Type | Description |
---|---|---|
420 | TAKEOUT_INIT_DELAY_%d | Wait %d seconds before initializing takeout. |
Can bots use this method?
No
Related pages
Channels, supergroups, gigagroups and basic groups
How to handle channels, supergroups, gigagroups, basic groups, and what's the difference between them.