zaileys 4.8.5 → 4.8.7
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.
- package/dist/builder/builder.d.ts +12 -1
- package/dist/builder/content/buttons.d.ts +10 -0
- package/dist/builder/content/group-status.d.ts +15 -0
- package/dist/builder/status-wrap.d.ts +11 -0
- package/dist/builder/types.d.ts +26 -1
- package/dist/client/client.d.ts +2 -0
- package/dist/client/types.d.ts +3 -0
- package/dist/events/context.d.ts +1 -0
- package/dist/events/decoders/_shared.d.ts +7 -0
- package/dist/index.cjs +17 -17
- package/dist/index.mjs +17 -17
- package/dist/media/ffmpeg/sticker.d.ts +7 -0
- package/package.json +8 -5
|
@@ -3,7 +3,7 @@ import { type ButtonsContentOptions } from './content/buttons.js';
|
|
|
3
3
|
import { type CarouselCard } from './content/carousel.js';
|
|
4
4
|
import { type AIRichOptions } from './content/airich.js';
|
|
5
5
|
import { type BuilderInternalState } from './state.js';
|
|
6
|
-
import type { AlbumItem, AudioOptions, BuilderState, ButtonDef, DocumentOptions, EventOptions, GroupInviteOptions, ImageOptions, InteractiveButton, ListOptions, LocationOptions, MediaSource, PollOptions, ProductOptions, StickerOptions, TemplateOptions, VideoNoteOptions, VideoOptions } from './types.js';
|
|
6
|
+
import type { AlbumItem, AudioOptions, BuilderState, ButtonDef, DocumentOptions, EventOptions, GroupInviteOptions, GroupStatusOptions, GroupStatusRepostOptions, GroupStatusSource, ImageOptions, InteractiveButton, ListOptions, LocationOptions, MediaSource, PollOptions, ProductOptions, StickerOptions, TemplateOptions, VideoNoteOptions, VideoOptions } from './types.js';
|
|
7
7
|
export interface BuilderSocketLike {
|
|
8
8
|
sendMessage(jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions): Promise<WAMessage | undefined>;
|
|
9
9
|
relayMessage?(jid: string, message: unknown, options: {
|
|
@@ -44,6 +44,9 @@ export declare class MessageBuilder<State extends BuilderState> {
|
|
|
44
44
|
template(this: MessageBuilder<'init'>, opts: TemplateOptions): MessageBuilder<'content-set'>;
|
|
45
45
|
event(this: MessageBuilder<'init'>, opts: EventOptions): MessageBuilder<'content-set'>;
|
|
46
46
|
groupInvite(this: MessageBuilder<'init'>, opts: GroupInviteOptions): MessageBuilder<'content-set'>;
|
|
47
|
+
/** Post a group status. Pass text, or an existing message to repost it without re-uploading its media. */
|
|
48
|
+
groupStatus(this: MessageBuilder<'init'>, text: string, opts?: GroupStatusOptions): MessageBuilder<'content-set'>;
|
|
49
|
+
groupStatus(this: MessageBuilder<'init'>, source: GroupStatusSource, opts?: GroupStatusRepostOptions): MessageBuilder<'content-set'>;
|
|
47
50
|
product(this: MessageBuilder<'init'>, opts: ProductOptions): MessageBuilder<'content-set'>;
|
|
48
51
|
requestPhoneNumber(this: MessageBuilder<'init'>): MessageBuilder<'content-set'>;
|
|
49
52
|
sharePhoneNumber(this: MessageBuilder<'init'>): MessageBuilder<'content-set'>;
|
|
@@ -55,5 +58,13 @@ export declare class MessageBuilder<State extends BuilderState> {
|
|
|
55
58
|
disappearing(seconds: number): MessageBuilder<State>;
|
|
56
59
|
then<T = WAMessageKey>(this: MessageBuilder<'content-set'>, onResolved: (key: WAMessageKey) => T, onRejected?: (err: unknown) => T | PromiseLike<T>): Promise<T>;
|
|
57
60
|
private uploadHeaderMedia;
|
|
61
|
+
/**
|
|
62
|
+
* Uploads the status media and returns it at the TOP level, not inside the envelope. baileys derives
|
|
63
|
+
* the stanza's `mediatype` attribute from the raw message before `patchMessageBeforeSending` runs, and
|
|
64
|
+
* the server drops a media status that lacks it — so the wrapping happens later, in that hook.
|
|
65
|
+
*/
|
|
66
|
+
private buildStatusMedia;
|
|
67
|
+
/** Relay skips baileys' contextInfo pass, so mentions and mentionAll are applied to the unwrapped node here. */
|
|
68
|
+
private applyRelayMentions;
|
|
58
69
|
private sendRelay;
|
|
59
70
|
}
|
|
@@ -2,6 +2,16 @@ import { proto, type AnyMessageContent } from 'baileys';
|
|
|
2
2
|
import type { BottomSheetOptions, ButtonDef, InteractiveButton, LimitedTimeOfferOptions, MediaSource } from '../types.js';
|
|
3
3
|
export declare const RELAY_CONTENT_KEY = "__zaileysRelayMessage";
|
|
4
4
|
export declare const RELAY_MEDIA_KEY = "__zaileysHeaderMedia";
|
|
5
|
+
/** Marks relay content that may only target a group jid; the value is the method label used in the error. */
|
|
6
|
+
export declare const RELAY_REQUIRE_GROUP_KEY = "__zaileysRequireGroupJid";
|
|
7
|
+
/** Carries a downloaded media buffer that `sendRelay` re-uploads and injects into the status envelope. */
|
|
8
|
+
export declare const RELAY_STATUS_MEDIA_KEY = "__zaileysStatusMedia";
|
|
9
|
+
export type StatusMedia = {
|
|
10
|
+
kind: 'image' | 'video' | 'audio';
|
|
11
|
+
buffer: Buffer;
|
|
12
|
+
caption?: string;
|
|
13
|
+
ptt?: boolean;
|
|
14
|
+
};
|
|
5
15
|
export type HeaderMedia = {
|
|
6
16
|
kind: 'image' | 'video';
|
|
7
17
|
src: MediaSource;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AnyMessageContent } from 'baileys';
|
|
2
|
+
import type { GroupStatusFont, GroupStatusOptions, GroupStatusRepostOptions, GroupStatusSource } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parses a group status background into an ARGB integer. Unlike baileys' `assertColor` this keeps
|
|
5
|
+
* numeric input (which that helper silently turns into `undefined`) and reads `#RGB` as CSS shorthand.
|
|
6
|
+
*/
|
|
7
|
+
export declare const parseStatusArgb: (value: string | number) => number;
|
|
8
|
+
/** Resolves a named font to its WhatsApp `FontType`; raw integers pass through for forward compatibility. */
|
|
9
|
+
export declare const resolveStatusFont: (value: GroupStatusFont | number) => number;
|
|
10
|
+
export declare const buildGroupStatusContent: (text: string, opts?: GroupStatusOptions) => AnyMessageContent;
|
|
11
|
+
/**
|
|
12
|
+
* Reposts an existing message as a group status. Media cannot be carried by copying pointers — the
|
|
13
|
+
* bytes are downloaded here and re-uploaded at dispatch, because a status needs its own upload.
|
|
14
|
+
*/
|
|
15
|
+
export declare const buildGroupStatusRepost: (source: GroupStatusSource, opts?: GroupStatusRepostOptions) => Promise<AnyMessageContent>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks a media message to be wrapped into a group status envelope at send time.
|
|
3
|
+
*
|
|
4
|
+
* baileys reads `getMediaType()` from the raw message to set the stanza's `mediatype` attribute, and
|
|
5
|
+
* only calls `patchMessageBeforeSending` afterwards. A media message nested inside
|
|
6
|
+
* `groupStatusMessageV2` is therefore invisible to that check and the server drops it. Relaying the
|
|
7
|
+
* media at the top level and wrapping it in the patch hook gets both the attribute and the envelope.
|
|
8
|
+
*/
|
|
9
|
+
export declare const markAsGroupStatus: (message: object) => void;
|
|
10
|
+
/** Wraps a marked message into the group status envelope; returns it untouched otherwise. */
|
|
11
|
+
export declare const applyGroupStatusWrap: <T extends object>(message: T) => T;
|
package/dist/builder/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WAMessage, WAMessageKey } from 'baileys';
|
|
2
|
+
import type { StickerMetadataType } from '../media/ffmpeg/sticker.js';
|
|
2
3
|
export type BuilderState = 'init' | 'content-set';
|
|
3
4
|
export type MediaSource = string | Buffer | URL;
|
|
4
5
|
export type ImageOptions = {
|
|
@@ -24,7 +25,7 @@ export type DocumentOptions = {
|
|
|
24
25
|
mimetype?: string;
|
|
25
26
|
caption?: string;
|
|
26
27
|
};
|
|
27
|
-
export type StickerOptions = {
|
|
28
|
+
export type StickerOptions = StickerMetadataType & {
|
|
28
29
|
animated?: boolean;
|
|
29
30
|
};
|
|
30
31
|
export type AlbumItem = {
|
|
@@ -155,6 +156,30 @@ export type GroupInviteOptions = {
|
|
|
155
156
|
/** Optional JPEG thumbnail (group avatar) — improves how the card renders. */
|
|
156
157
|
thumbnail?: Buffer;
|
|
157
158
|
};
|
|
159
|
+
export type GroupStatusFont = 'system' | 'system-text' | 'fb-script' | 'system-bold' | 'morningbreeze' | 'calistoga' | 'exo2' | 'courierprime';
|
|
160
|
+
export type GroupStatusOptions = {
|
|
161
|
+
/** Background as `#RGB`, `#RRGGBB`, `#AARRGGBB` (with or without `#`), or a raw ARGB integer. */
|
|
162
|
+
backgroundColor?: string | number;
|
|
163
|
+
/** Font face. Accepts a named font or a raw FontType integer for forward compatibility. */
|
|
164
|
+
font?: GroupStatusFont | number;
|
|
165
|
+
};
|
|
166
|
+
/** Media posted directly as a group status, without an existing message to repost. */
|
|
167
|
+
export type GroupStatusMedia = {
|
|
168
|
+
image?: MediaSource;
|
|
169
|
+
video?: MediaSource;
|
|
170
|
+
audio?: MediaSource;
|
|
171
|
+
caption?: string;
|
|
172
|
+
/** Send an audio status as a voice note. */
|
|
173
|
+
ptt?: boolean;
|
|
174
|
+
};
|
|
175
|
+
/** What a group status can be built from: a `MessageContext`, a raw `WAMessage`, or fresh media. */
|
|
176
|
+
export type GroupStatusSource = WAMessage | {
|
|
177
|
+
message: () => WAMessage;
|
|
178
|
+
} | GroupStatusMedia;
|
|
179
|
+
export type GroupStatusRepostOptions = {
|
|
180
|
+
/** Replaces the original caption. Ignored for voice notes, which have none. */
|
|
181
|
+
caption?: string;
|
|
182
|
+
};
|
|
158
183
|
export type BuilderContext = {
|
|
159
184
|
recipient: string;
|
|
160
185
|
quoted?: WAMessage | WAMessageKey;
|
package/dist/client/client.d.ts
CHANGED
|
@@ -142,6 +142,8 @@ export declare class Client extends TypedEventEmitter<ClientEventMap> {
|
|
|
142
142
|
pin(key: WAMessageKey, opts?: PinOptions): Promise<WAMessageKey>;
|
|
143
143
|
unpin(key: WAMessageKey): Promise<WAMessageKey>;
|
|
144
144
|
setDisappearing(to: string, seconds: number): Promise<void>;
|
|
145
|
+
/** Group status media must be wrapped after baileys computes the stanza's mediatype; see status-wrap. */
|
|
146
|
+
private readonly patchOutgoing;
|
|
145
147
|
private resolveRecipient;
|
|
146
148
|
private requireSocket;
|
|
147
149
|
/** Messaging seam: baileys socket or the cloud transport, whichever the provider dictates. */
|
package/dist/client/types.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { InboundEventMap } from '../events/types.js';
|
|
|
11
11
|
import type { MessageStore } from '../store/types.js';
|
|
12
12
|
import type { PluginsOptions } from '../plugin/types.js';
|
|
13
13
|
import type { CloudOptions } from '../cloud/types.js';
|
|
14
|
+
import type { StickerMetadataType } from '../media/ffmpeg/sticker.js';
|
|
14
15
|
import type { CloudFlowResponseEvent, CloudOrderEvent, CloudStatusEvent, CloudTemplateStatusEvent } from '../cloud/translate/inbound.js';
|
|
15
16
|
export type ProviderKind = 'baileys' | 'cloud';
|
|
16
17
|
export type ConnectionState = 'idle' | 'connecting' | 'qr-pending' | 'pairing-pending' | 'connected' | 'reconnecting' | 'disconnecting' | 'disconnected';
|
|
@@ -65,6 +66,8 @@ export interface ClientOptions {
|
|
|
65
66
|
autoDelete?: AutoDeleteOptions | false;
|
|
66
67
|
/** Load and manage plugins from a directory. */
|
|
67
68
|
plugins?: PluginsOptions;
|
|
69
|
+
/** Global default sticker metadata configuration (pack name, author, etc). */
|
|
70
|
+
sticker?: StickerMetadataType;
|
|
68
71
|
}
|
|
69
72
|
export type ConnectionEventMap = {
|
|
70
73
|
connect: {
|
package/dist/events/context.d.ts
CHANGED
|
@@ -182,6 +182,7 @@ export interface MessageContext {
|
|
|
182
182
|
isHideTags: boolean;
|
|
183
183
|
isStatusMention: boolean;
|
|
184
184
|
isGroupStatusMention: boolean;
|
|
185
|
+
isGroupStatus: boolean;
|
|
185
186
|
isStory: boolean;
|
|
186
187
|
roomName(): Promise<string | null>;
|
|
187
188
|
receiverName(): Promise<string | null>;
|
|
@@ -24,3 +24,10 @@ export declare const extractMentions: (contextInfo: WAContextInfo | null | undef
|
|
|
24
24
|
export declare const mapAddressing: (key: WAMessageKey) => AddressingAliases;
|
|
25
25
|
export declare const isGroupJid: (jid: string) => boolean;
|
|
26
26
|
export declare const safeNumber: (n: number | LongLike | null | undefined) => number | null;
|
|
27
|
+
export declare const asRecord: (value: unknown) => Record<string, unknown> | null;
|
|
28
|
+
/** Order matters: unwrap() breaks on the first match, so new entries go at the end. */
|
|
29
|
+
export declare const WRAPPER_FIELDS: readonly ['ephemeralMessage', 'viewOnceMessage', 'viewOnceMessageV2', 'viewOnceMessageV2Extension', 'documentWithCaptionMessage', 'editedMessage', 'lottieStickerMessage', 'groupStatusMessage', 'groupStatusMessageV2'];
|
|
30
|
+
export declare const GROUP_STATUS_FIELDS: readonly ['groupStatusMessage', 'groupStatusMessageV2'];
|
|
31
|
+
/** True when any level of the bounded wrapper chain carries one of the given fields. */
|
|
32
|
+
export declare const wrapperChainHas: (content: Record<string, unknown>, fields: readonly string[]) => boolean;
|
|
33
|
+
export declare const unwrap: (content: Record<string, unknown>) => Record<string, unknown>;
|