InitHistoryImportRequest

Only users can use this request. See code examples.

---functions---
messages.initHistoryImport#34090c3b peer:InputPeer file:InputFile media_count:int = messages.HistoryImport

Returns

messages.HistoryImport

This type can only be an instance of:

HistoryImport

Parameters

peerInputPeerAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
fileInputFile
media_countint

Known RPC errors

This request can cause 4 known errors:

ImportFileInvalidErrorThe file is too large to be imported.
ImportFormatUnrecognizedErrorUnknown import format.
PreviousChatImportActiveWaitMinErrorSimilar to a flood wait, must wait {minutes} minutes.
TimeoutErrorA timeout occurred while fetching data from the worker.

You can import these from telethon.errors.

Example

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

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.messages.InitHistoryImportRequest(
        peer='username',
        file=client.upload_file('/path/to/file.jpg'),
        media_count=42
    ))
    print(result.stringify())