zaileys 4.12.0 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ export declare class MessageBuilder<State extends BuilderState> {
26
26
  protected readonly socket: BuilderSocketLike;
27
27
  protected readonly internal: BuilderInternalState;
28
28
  constructor(socket: BuilderSocketLike, internal: BuilderInternalState);
29
- static create(socket: BuilderSocketLike, recipient: string, resolveRecipient?: (raw: string) => Promise<string>, recordSent?: (message: WAMessage) => void): MessageBuilder<'init'>;
29
+ static create(socket: BuilderSocketLike, recipient: string, resolveRecipient?: (raw: string) => Promise<string>, recordSent?: (message: WAMessage) => void, inheritDisappearing?: (jid: string) => number | undefined): MessageBuilder<'init'>;
30
30
  to(this: MessageBuilder<'init'>, recipient: string): MessageBuilder<'init'>;
31
31
  text(this: MessageBuilder<'init'>, content: string, opts?: TextOptions): MessageBuilder<'content-set'>;
32
32
  image(this: MessageBuilder<'init'>, src: MediaSource, opts?: ImageOptions): MessageBuilder<'content-set'>;
@@ -12,5 +12,7 @@ export type BuilderInternalState = {
12
12
  disappearingSeconds?: number;
13
13
  resolveRecipient?: (raw: string) => Promise<string>;
14
14
  recordSent?: (message: WAMessage) => void;
15
+ /** The chat's own disappearing timer, applied when the caller did not set one. */
16
+ inheritDisappearing?: (jid: string) => number | undefined;
15
17
  };
16
- export declare const createInternalState: (recipient: string, resolveRecipient?: (raw: string) => Promise<string>, recordSent?: (message: WAMessage) => void) => BuilderInternalState;
18
+ export declare const createInternalState: (recipient: string, resolveRecipient?: (raw: string) => Promise<string>, recordSent?: (message: WAMessage) => void, inheritDisappearing?: (jid: string) => number | undefined) => BuilderInternalState;
@@ -37,6 +37,8 @@ export declare class Client extends TypedEventEmitter<ClientEventMap> {
37
37
  private readonly presenceThrottle;
38
38
  private readonly scheduleLimiter;
39
39
  private authExhausted;
40
+ /** Each chat's disappearing timer, learned from inbound messages so outbound sends can inherit it. */
41
+ private readonly chatExpiration;
40
42
  private _socket;
41
43
  private reconnectTimer;
42
44
  private listenerCleanup;
@@ -133,6 +135,7 @@ export declare class Client extends TypedEventEmitter<ClientEventMap> {
133
135
  private buildCommandContext;
134
136
  private detachCommands;
135
137
  send(to: string): MessageBuilder<'init'>;
138
+ private rememberChatExpiration;
136
139
  edit(key: WAMessageKey): EditBuilder;
137
140
  delete(key: WAMessageKey, opts?: DeleteOptions): Promise<void>;
138
141
  react(key: WAMessageKey, emoji: string): Promise<WAMessageKey>;
@@ -1,6 +1,6 @@
1
1
  import type { WAMessageKey } from 'baileys';
2
2
  import type { MessageContext } from '../events/context.js';
3
- import type { TextOptions } from '../builder/builder.js';
3
+ import type { MessageBuilder, TextOptions } from '../builder/builder.js';
4
4
  import type { Client as ZaileysClient } from '../client/client.js';
5
5
  export type CommandPrefix = string | string[];
6
6
  export interface ParsedArgs {
@@ -12,13 +12,13 @@ export interface ParsedArgs {
12
12
  raw: string;
13
13
  }
14
14
  export interface CommandContext extends MessageContext {
15
- /** The client that received this command, so a handler needs nothing else in scope. */
16
- client: ZaileysClient;
17
15
  raw: string;
18
16
  command: string;
19
17
  args: string[];
20
18
  flags: Record<string, string | boolean>;
21
19
  json: unknown;
20
+ client: ZaileysClient;
21
+ send(to?: string): MessageBuilder<'init'>;
22
22
  reply(content: string, opts?: TextOptions): Promise<WAMessageKey>;
23
23
  react(emoji: string): Promise<WAMessageKey>;
24
24
  edit(content: string): Promise<void>;
@@ -217,12 +217,12 @@ export interface MessageContext {
217
217
  mentionedGroups: string[];
218
218
  ad?: AdAttribution;
219
219
  business?: BusinessInfo;
220
+ media?: ContextMedia;
221
+ citation: CitationPredicates;
220
222
  roomName(): Promise<string | null>;
221
223
  receiverName(): Promise<string | null>;
222
- media?: ContextMedia;
223
224
  replied(): Promise<MessageContext | null>;
224
225
  message(): WAMessage;
225
- citation: CitationPredicates;
226
226
  reply(content: string, opts?: TextOptions): Promise<WAMessageKey>;
227
227
  react(emoji: string): Promise<WAMessageKey>;
228
228
  }
@@ -56,10 +56,10 @@ export interface PollVotePayload {
56
56
  pollKey: WAMessageKey;
57
57
  /** Raw SHA-256 hashes WhatsApp sends. Use {@link PollVotePayload.options} for readable text. */
58
58
  selectedOptions: string[];
59
- /** The option text the voter picked. Needs the original poll in the store; empty when unavailable. */
60
- options(): Promise<string[]>;
61
59
  voter: SenderInfo;
62
60
  timestamp: number;
61
+ /** The option text the voter picked. Needs the original poll in the store; empty when unavailable. */
62
+ options(): Promise<string[]>;
63
63
  }
64
64
  export interface ButtonClickPayload {
65
65
  key: WAMessageKey;