Skip to content

Chats (API Reference)

Complete reference for the Chats<TContext> class. See Chats guide for narrative documentation.

Constructor (internal)

Chats is never instantiated directly. It is created and returned by the prepare functions.

Type parameter

ts
class Chats<TContext extends Context = Context>

Actor factories

MethodSignatureReturns
newUser(profile?: UserProfile) => User<TContext>New User actor
newAdmin(profile?: UserProfile) => User<TContext>User promoted to admin in defaultGroup
newOwner(profile?: UserProfile) => User<TContext>User set as creator in defaultGroup
newGroup(profile?: string | ChatProfile) => Group<TContext>New Group actor
newSupergroup(profile?: string | ChatProfile) => Supergroup<TContext>New Supergroup actor
newChannel(profile?: string | ChatProfile) => Channel<TContext>New Channel actor
newPrivateChat(user: User<TContext>) => PrivateChat<TContext>New PrivateChat for user
newBusinessAccount() => BusinessAccount<TContext>New BusinessAccount actor

Log accessors

MethodSignatureReturns
repliesFor(user: User<TContext>) => RepliesInbox<TContext>Bot replies to that user
actionsFor(user: User<TContext>) => ActionsLogsendChatAction calls to that user
editsFor(user: User<TContext>) => EditsLogeditMessage* calls to that user
deletionsFor(chat: AnyChat<TContext>) => DeletionsLog<TContext>deleteMessage calls in that chat

Properties

PropertyTypeDescription
outgoingOutgoingRequestsAll captured API calls
defaultGroupSupergroup<TContext>Auto-created group used by newAdmin/newOwner
allUsersUser<TContext>[]All created user actors
allChatsAnyChat<TContext>[]All created chat actors

Methods

idle(): Promise<void>

Resolves when all in-flight transformer promises have settled.

clear(): void

Resets all logs. Does not remove actors or membership state.

attachBot(bot): void (internal)

Called by prepareBot to wire the bot reference into all chat actors.

deriveFromCapture(request): void (internal)

Called by the transformer's onCapture hook to route a captured API call to the right logs.

buildDefaultResponses(): Responses (internal)

Constructs the default canned response map used when no override is provided.

Released under the MIT License.