GetChannelDifferenceRequest

Both users and bots can use this request. See code examples.

---functions---
updates.getChannelDifference#03173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference

Returns

updates.ChannelDifference

This type can be an instance of either:

ChannelDifferenceChannelDifferenceEmpty
ChannelDifferenceTooLong

Parameters

channelInputChannelAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
filterChannelMessagesFilter
ptsint
limitint
forceflagThis argument defaults to None and can be omitted.

Known RPC errors

This request can cause 9 known errors:

ChannelInvalidErrorInvalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited.
ChannelPrivateErrorThe channel specified is private and you lack permission to access it. Another reason may be that you were banned from it.
ChannelPublicGroupNaErrorchannel/supergroup not available.
HistoryGetFailedErrorFetching of history failed.
PersistentTimestampEmptyErrorPersistent timestamp empty.
PersistentTimestampInvalidErrorPersistent timestamp invalid.
PersistentTimestampOutdatedErrorPersistent timestamp outdated.
RangesInvalidErrorInvalid range provided.
TimeoutErrorA timeout occurred while fetching data from the worker.

You can import these from telethon.errors.

Example

Please refer to the documentation of client.catch_up() to learn about the parameters and see several code examples on how to use it.

The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.

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

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.updates.GetChannelDifferenceRequest(
        channel='username',
        filter=types.ChannelMessagesFilter(
            ranges=[types.MessageRange(
                min_id=0,
                max_id=0
            )],
            exclude_new_messages=True
        ),
        pts=42,
        limit=100,
        force=True
    ))
    print(result.stringify())