Everything currently registered, in call order.
A copy of the local update state: pts, qts, date and seq.
Ids of the channels currently kept alive by watch.
Installs the handler for anything thrown inside the chain.
Fetches everything missed since the last known state.
Removes a middleware or handler from the chain.
Handles updates of the given raw names, or the events of a builder.
A raw name gives the untouched update typed as its schema class; a
builder gives that builder's event object, as addEventHandler does. An
array of handlers runs in order, each deciding with next() whether the
rest of them run.
Raw update names, or an event builder.
One handler or an ordered array of them.
Optionaloptions: OnOptions
Chat and predicate filters, see OnOptions.
A function that removes the handler.
client.updates.on("newChannelMessage", (update) => console.log(update.message.id));
client.updates.on(["newMessage", "newChannelMessage"], handler);
client.updates.on("botCallbackQuery", [checkAuth, handleClick]);
client.updates.on("newChannelMessage", handler, { chats: ["durov"] });
client.updates.on(new NewMessage({}), (event) => event.message.reply({ message: "hi" }));
Handles updates of the given raw names, or the events of a builder.
A raw name gives the untouched update typed as its schema class; a
builder gives that builder's event object, as addEventHandler does. An
array of handlers runs in order, each deciding with next() whether the
rest of them run.
One handler or an ordered array of them.
A function that removes the handler.
client.updates.on("newChannelMessage", (update) => console.log(update.message.id));
client.updates.on(["newMessage", "newChannelMessage"], handler);
client.updates.on("botCallbackQuery", [checkAuth, handleClick]);
client.updates.on("newChannelMessage", handler, { chats: ["durov"] });
client.updates.on(new NewMessage({}), (event) => event.message.reply({ message: "hi" }));
Adds a middleware to the end of the chain. It sees every update, so this is the place for logging, timing or authentication.
see UpdateMiddleware.
A function that removes it.
Handles updates from the given chats only, and keeps them coming.
Telegram streams channel updates to a session only while it keeps the channel open, so for channels the account is not a member of this is the difference between receiving their messages and receiving nothing. Chats that need no such subscription are simply filtered.
Synchronous like on: resolving the chats and subscribing happen in
the background, waiting for the client to connect, so it can be called
before start(). A reconnect re-subscribes on its own. The poll runs at
the interval Telegram names in the difference, falling back to the
client's channelPollInterval.
Chats to listen to: usernames, ids or entities.
Optionalhandler: UpdateMiddleware<any> | UpdateMiddleware<any>[]
Optional handler; without it only the subscription is kept.
Which updates to handle, see WatchOptions.
A function that stops watching and removes the handler.
The update pipeline of a client, reachable as
client.updates.Handlers form one chain:
next()passes the update on, returning without it consumes the update. on matches first, by raw schema name or by an event builder; watch also keeps Telegram sending updates for the chats it is given.A raw name gives the untouched
Api.TypeUpdate, a builder gives its event object. Direct and small-group messages arrive as theupdateShortMessagecontainers, which are not part of theUpdateunion; the chain expands them, so"newMessage"sees them too.Each update carries a
stateobject for middleware to leave things in. Throws go to catch, or to the client's error handler.client.addEventHandlerkeeps working and runs before this chain; aStopPropagationthere ends that loop only.Example