Skip to content

Logs (API Reference)

MessagesLog<TContext>

Per-chat log of all bot sends.

ts
class MessagesLog<TContext extends Context = Context>
Property/MethodTypeDescription
allReply<TContext>[]All captured messages
lastReply<TContext> | undefinedLast captured message
lengthnumberCount
byText(matcher)Reply<TContext> | undefinedFind first by exact string or regex
clear()voidReset

RepliesInbox<TContext>

Per-user log of bot replies to that user.

ts
class RepliesInbox<TContext extends Context = Context>
Property/MethodTypeDescription
allReply<TContext>[]All replies
lastReply<TContext> | undefinedLast reply
lengthnumberCount
lastOrThrow()Reply<TContext>Last reply or throws Error
clear()voidReset

ActionsLog

Per-user log of sendChatAction calls.

ts
class ActionsLog
Property/MethodTypeDescription
all{ action: string }[]All captured actions
last{ action: string } | undefinedLast action
lengthnumberCount
clear()voidReset

EditsLog

Per-user log of editMessageText, editMessageCaption, and editMessageMedia calls.

ts
class EditsLog

Edit interface

ts
interface Edit {
  text?: string;
  caption?: string;
  messageId: number;
}
Property/MethodTypeDescription
allEdit[]All edits
lastEdit | undefinedLast edit
lengthnumberCount
lastOrThrow()EditLast edit or throws
clear()voidReset

DeletionsLog<TContext>

Per-chat log of deleteMessage calls.

ts
class DeletionsLog<TContext extends Context = Context>

Deletion interface

ts
interface Deletion<TContext extends Context = Context> {
  chatId: number;
  messageId: number;
  reply?: Reply<TContext>; // captured Reply if sent during the test
}
Property/MethodTypeDescription
allDeletion<TContext>[]All deletions
lastDeletion<TContext> | undefinedLast deletion
lengthnumberCount
lastOrThrow()Deletion<TContext>Last deletion or throws
clear()voidReset

See also

Released under the MIT License.