Interface UpdatesManagerParams

Parameters for the updates manager

interface UpdatesManagerParams {
    catchUp?: boolean;
    channelPtsLimit?: number | ((channelId: number) => number);
    disableNoDispatch?: boolean;
    onChannelTooLong?: ((channelId: number, update: RawChannelDifferenceTooLong) => void);
    overrideOpenChatTimeout?: ((upd: TypeChannelDifference) => number);
}

Properties

catchUp?: boolean

Whether to catch up with missed updates when starting updates loop.

Note: In case the storage was not properly closed the last time, "catching up" might result in duplicate updates.

channelPtsLimit?: number | ((channelId: number) => number)

ADVANCED

PTS limit for getChannelDifference requests (max. 100000). When there are more updates than this limit, the library will skip some of them. According to the official docs, "Ordinary (non-bot) users are supposed to pass 10-100", so passing >100 for users may lead to issues.

100 for users, 100000 for bots
disableNoDispatch?: boolean

ADVANCED

Whether to globally disable no-dispatch mechanism.

No-dispatch is a mechanism that allows you to call methods that return updates and correctly handle them, without actually dispatching them to the event handlers.

In other words, the following code will work differently:

dp.onNewMessage(console.log)
console.log(await tg.sendText('me', 'hello'))
  • if disableNoDispatch is true, the sent message will be dispatched to the event handler, thus it will be printed twice
  • if disableNoDispatch is false, the sent message will not be dispatched to the event handler, thus it will onlt be printed once

Disabling it may also improve performance, but it's not guaranteed.

Note: you can disable this on per-request basis by passing shouldDispatch: true to the method call that accepts it. For some methods you need to always pass shouldDispatch: true explicitly. This is noted in the corresponding method's documentation by "Doesn't follow disableNoDispatch"

false
onChannelTooLong?: ((channelId: number, update: RawChannelDifferenceTooLong) => void)

ADVANCED

Whenever an updates.channelDifferenceTooLong is received, the library isn't able to efficiently handle it on its own, and will call this function for you to handle it instead.

See docs

overrideOpenChatTimeout?: ((upd: TypeChannelDifference) => number)

ADVANCED

When openChat method is used on a client, the library will set up a timer to periodically fetch the new updates. By default, it will respect the value provided by the server, but it some cases you may want to override it (e.g. decrease it to poll more often and potentially get updates faster).

The returned value is treated as seconds.