zaileys 2.0.16 → 2.1.1

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/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import * as baileys from 'baileys';
2
2
  import baileys__default, { AuthenticationState, WAMessage, proto, ParticipantAction, WAPrivacyValue, WAPrivacyOnlineValue, WAReadReceiptsValue, WAPrivacyGroupAddValue } from 'baileys';
3
3
  import * as Stream from 'stream';
4
4
  import Stream__default from 'stream';
5
+ import { JetDB } from 'jetdb';
6
+ export { JetDB, JetDBOptions, createJetDB } from 'jetdb';
5
7
  import z, { z as z$1 } from 'zod';
6
8
  import _ from 'lodash';
7
9
 
@@ -31,6 +33,12 @@ declare const SignalOptionsType: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.Zo
31
33
  ptv: z.ZodOptional<z.ZodBoolean>;
32
34
  }, z.core.$loose>, z.ZodObject<{
33
35
  sticker: z.ZodUnion<[z.ZodUnion<[z.ZodURL, z.ZodBase64]>, z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>]>;
36
+ shape: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
37
+ default: "default";
38
+ rounded: "rounded";
39
+ circle: "circle";
40
+ oval: "oval";
41
+ }>>>;
34
42
  caption: z.ZodOptional<z.ZodString>;
35
43
  }, z.core.$loose>, z.ZodObject<{
36
44
  document: z.ZodUnion<[z.ZodUnion<[z.ZodURL, z.ZodBase64]>, z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>]>;
@@ -295,6 +303,7 @@ declare const DEVICE_ENUM_TYPES: z.ZodEnum<{
295
303
  }>;
296
304
  declare const MESSAGE_ENUM_TYPES: z.ZodEnum<{
297
305
  text: "text";
306
+ album: "album";
298
307
  image: "image";
299
308
  contact: "contact";
300
309
  location: "location";
@@ -306,6 +315,8 @@ declare const MESSAGE_ENUM_TYPES: z.ZodEnum<{
306
315
  highlyStructured: "highlyStructured";
307
316
  sendPayment: "sendPayment";
308
317
  requestPayment: "requestPayment";
318
+ groupStatusMention: "groupStatusMention";
319
+ statusMention: "statusMention";
309
320
  declinePaymentRequest: "declinePaymentRequest";
310
321
  cancelPaymentRequest: "cancelPaymentRequest";
311
322
  template: "template";
@@ -348,6 +359,7 @@ declare const BaseMessagesType: z.ZodObject<{
348
359
  chatId: z.ZodString;
349
360
  chatType: z.ZodEnum<{
350
361
  text: "text";
362
+ album: "album";
351
363
  image: "image";
352
364
  contact: "contact";
353
365
  location: "location";
@@ -359,6 +371,8 @@ declare const BaseMessagesType: z.ZodObject<{
359
371
  highlyStructured: "highlyStructured";
360
372
  sendPayment: "sendPayment";
361
373
  requestPayment: "requestPayment";
374
+ groupStatusMention: "groupStatusMention";
375
+ statusMention: "statusMention";
362
376
  declinePaymentRequest: "declinePaymentRequest";
363
377
  cancelPaymentRequest: "cancelPaymentRequest";
364
378
  template: "template";
@@ -418,6 +432,9 @@ declare const BaseMessagesType: z.ZodObject<{
418
432
  isPrefix: z.ZodBoolean;
419
433
  isSpam: z.ZodBoolean;
420
434
  isTagMe: z.ZodBoolean;
435
+ isStatusMention: z.ZodBoolean;
436
+ isGroupStatusMention: z.ZodBoolean;
437
+ isHideTags: z.ZodBoolean;
421
438
  isGroup: z.ZodBoolean;
422
439
  isNewsletter: z.ZodBoolean;
423
440
  isQuestion: z.ZodBoolean;
@@ -443,6 +460,7 @@ declare const ListenerMessagesType: z.ZodObject<{
443
460
  chatId: z.ZodString;
444
461
  chatType: z.ZodEnum<{
445
462
  text: "text";
463
+ album: "album";
446
464
  image: "image";
447
465
  contact: "contact";
448
466
  location: "location";
@@ -454,6 +472,8 @@ declare const ListenerMessagesType: z.ZodObject<{
454
472
  highlyStructured: "highlyStructured";
455
473
  sendPayment: "sendPayment";
456
474
  requestPayment: "requestPayment";
475
+ groupStatusMention: "groupStatusMention";
476
+ statusMention: "statusMention";
457
477
  declinePaymentRequest: "declinePaymentRequest";
458
478
  cancelPaymentRequest: "cancelPaymentRequest";
459
479
  template: "template";
@@ -513,6 +533,9 @@ declare const ListenerMessagesType: z.ZodObject<{
513
533
  isPrefix: z.ZodBoolean;
514
534
  isSpam: z.ZodBoolean;
515
535
  isTagMe: z.ZodBoolean;
536
+ isStatusMention: z.ZodBoolean;
537
+ isGroupStatusMention: z.ZodBoolean;
538
+ isHideTags: z.ZodBoolean;
516
539
  isGroup: z.ZodBoolean;
517
540
  isNewsletter: z.ZodBoolean;
518
541
  isQuestion: z.ZodBoolean;
@@ -537,6 +560,7 @@ declare const ListenerMessagesType: z.ZodObject<{
537
560
  chatId: z.ZodString;
538
561
  chatType: z.ZodEnum<{
539
562
  text: "text";
563
+ album: "album";
540
564
  image: "image";
541
565
  contact: "contact";
542
566
  location: "location";
@@ -548,6 +572,8 @@ declare const ListenerMessagesType: z.ZodObject<{
548
572
  highlyStructured: "highlyStructured";
549
573
  sendPayment: "sendPayment";
550
574
  requestPayment: "requestPayment";
575
+ groupStatusMention: "groupStatusMention";
576
+ statusMention: "statusMention";
551
577
  declinePaymentRequest: "declinePaymentRequest";
552
578
  cancelPaymentRequest: "cancelPaymentRequest";
553
579
  template: "template";
@@ -607,6 +633,9 @@ declare const ListenerMessagesType: z.ZodObject<{
607
633
  isPrefix: z.ZodBoolean;
608
634
  isSpam: z.ZodBoolean;
609
635
  isTagMe: z.ZodBoolean;
636
+ isStatusMention: z.ZodBoolean;
637
+ isGroupStatusMention: z.ZodBoolean;
638
+ isHideTags: z.ZodBoolean;
610
639
  isGroup: z.ZodBoolean;
611
640
  isNewsletter: z.ZodBoolean;
612
641
  isQuestion: z.ZodBoolean;
@@ -644,10 +673,22 @@ declare const FakeReplyType: z$1.ZodOptional<z$1.ZodObject<{
644
673
  tiktok: "tiktok";
645
674
  }>, z$1.ZodNumber]>;
646
675
  }, z$1.core.$strip>>;
676
+ declare const StickerShapeType: z$1.ZodDefault<z$1.ZodEnum<{
677
+ default: "default";
678
+ rounded: "rounded";
679
+ circle: "circle";
680
+ oval: "oval";
681
+ }>>;
647
682
  declare const StickerMetadataType: z$1.ZodOptional<z$1.ZodObject<{
648
683
  packageName: z$1.ZodString;
649
684
  authorName: z$1.ZodString;
650
685
  quality: z$1.ZodNumber;
686
+ shape: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodEnum<{
687
+ default: "default";
688
+ rounded: "rounded";
689
+ circle: "circle";
690
+ oval: "oval";
691
+ }>>>;
651
692
  }, z$1.core.$strip>>;
652
693
  declare const ClientBaseType: z$1.ZodObject<{
653
694
  session: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodString>>;
@@ -681,6 +722,12 @@ declare const ClientBaseType: z$1.ZodObject<{
681
722
  packageName: z$1.ZodString;
682
723
  authorName: z$1.ZodString;
683
724
  quality: z$1.ZodNumber;
725
+ shape: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodEnum<{
726
+ default: "default";
727
+ rounded: "rounded";
728
+ circle: "circle";
729
+ oval: "oval";
730
+ }>>>;
684
731
  }, z$1.core.$strip>>;
685
732
  }, z$1.core.$strip>;
686
733
  declare const ClientAuthPairingType: z$1.ZodObject<{
@@ -724,6 +771,12 @@ declare const ClientOptionsType: z$1.ZodUnion<readonly [z$1.ZodObject<{
724
771
  packageName: z$1.ZodString;
725
772
  authorName: z$1.ZodString;
726
773
  quality: z$1.ZodNumber;
774
+ shape: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodEnum<{
775
+ default: "default";
776
+ rounded: "rounded";
777
+ circle: "circle";
778
+ oval: "oval";
779
+ }>>>;
727
780
  }, z$1.core.$strip>>;
728
781
  }, z$1.core.$strip>, z$1.ZodObject<{
729
782
  authType: z$1.ZodLiteral<"qr">;
@@ -758,6 +811,12 @@ declare const ClientOptionsType: z$1.ZodUnion<readonly [z$1.ZodObject<{
758
811
  packageName: z$1.ZodString;
759
812
  authorName: z$1.ZodString;
760
813
  quality: z$1.ZodNumber;
814
+ shape: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodEnum<{
815
+ default: "default";
816
+ rounded: "rounded";
817
+ circle: "circle";
818
+ oval: "oval";
819
+ }>>>;
761
820
  }, z$1.core.$strip>>;
762
821
  }, z$1.core.$strip>]>;
763
822
  declare const EventEnumType: z$1.ZodEnum<{
@@ -901,6 +960,30 @@ declare class MessageCollector {
901
960
  cancel(channelId: string): ParsedMessage[];
902
961
  }
903
962
 
963
+ interface HealthOptions {
964
+ checkIntervalMs?: number;
965
+ staleThresholdMs?: number;
966
+ cooldownMs?: number;
967
+ maxRetries?: number;
968
+ }
969
+ declare class HealthManager {
970
+ private client;
971
+ private lastActivityTime;
972
+ private lastRecoveryTime;
973
+ private checkInterval;
974
+ private isRecovering;
975
+ private retryCount;
976
+ private options;
977
+ constructor(client: Client, options?: HealthOptions);
978
+ start(): void;
979
+ stop(): void;
980
+ touch(): void;
981
+ private setupActivityListeners;
982
+ private check;
983
+ private isInCooldown;
984
+ recover(): Promise<void>;
985
+ }
986
+
904
987
  declare class Logs {
905
988
  private client;
906
989
  private logsInitialized;
@@ -961,25 +1044,23 @@ declare class Client {
961
1044
  options: z.infer<typeof ClientOptionsType>;
962
1045
  private listener;
963
1046
  private _ready;
964
- private watchdog;
1047
+ health: HealthManager;
965
1048
  logs: Logs;
966
1049
  collector: MessageCollector;
967
1050
  middleware: Middleware<any>;
968
1051
  plugins: Plugins;
969
1052
  constructor(options: z.infer<typeof ClientOptionsType>);
970
1053
  initialize(client?: Client): Promise<void>;
971
- private prekeyDetected;
972
- private setupPrekeyErrorDetection;
973
1054
  ready(): Promise<void>;
974
- db(path: string): Lowdb;
1055
+ db(path: string): JetDB;
975
1056
  on<T extends z.infer<typeof EventEnumType>>(event: T, handler: EventCallbackType[T]): void;
976
1057
  use<T>(handler: MiddlewareHandler<T>): this;
977
1058
  get socket(): ReturnType<typeof baileys__default>;
978
- getMessageByChatId(chatId: string): Promise<Partial<{
1059
+ getMessageByChatId(chatId: string, media?: proto.IMessage): Promise<Partial<{
979
1060
  channelId: string;
980
1061
  uniqueId: string;
981
1062
  chatId: string;
982
- chatType: "text" | "image" | "contact" | "location" | "document" | "audio" | "video" | "protocol" | "contacts" | "highlyStructured" | "sendPayment" | "requestPayment" | "declinePaymentRequest" | "cancelPaymentRequest" | "template" | "sticker" | "groupInvite" | "product" | "deviceSent" | "lists" | "viewOnce" | "order" | "ephemeral" | "invoice" | "buttons" | "paymentInvite" | "interactive" | "reaction" | "interactiveResponse" | "pollCreation" | "pollUpdate" | "keepInChat" | "requestPhoneNumber" | "scheduledCallCreation" | "groupMentioned" | "pinInChat" | "scheduledCallEdit" | "ptv" | "botInvoke" | "callLog" | "encComment" | "bcall" | "lottieSticker" | "event" | "comment" | "placeholder" | "encEventUpdate";
1063
+ chatType: "text" | "album" | "image" | "contact" | "location" | "document" | "audio" | "video" | "protocol" | "contacts" | "highlyStructured" | "sendPayment" | "requestPayment" | "groupStatusMention" | "statusMention" | "declinePaymentRequest" | "cancelPaymentRequest" | "template" | "sticker" | "groupInvite" | "product" | "deviceSent" | "lists" | "viewOnce" | "order" | "ephemeral" | "invoice" | "buttons" | "paymentInvite" | "interactive" | "reaction" | "interactiveResponse" | "pollCreation" | "pollUpdate" | "keepInChat" | "requestPhoneNumber" | "scheduledCallCreation" | "groupMentioned" | "pinInChat" | "scheduledCallEdit" | "ptv" | "botInvoke" | "callLog" | "encComment" | "bcall" | "lottieSticker" | "event" | "comment" | "placeholder" | "encEventUpdate";
983
1064
  receiverId: string;
984
1065
  receiverName: string;
985
1066
  roomId: string;
@@ -996,6 +1077,9 @@ declare class Client {
996
1077
  isPrefix: boolean;
997
1078
  isSpam: boolean;
998
1079
  isTagMe: boolean;
1080
+ isStatusMention: boolean;
1081
+ isGroupStatusMention: boolean;
1082
+ isHideTags: boolean;
999
1083
  isGroup: boolean;
1000
1084
  isNewsletter: boolean;
1001
1085
  isQuestion: boolean;
@@ -1020,7 +1104,7 @@ declare class Client {
1020
1104
  channelId: string;
1021
1105
  uniqueId: string;
1022
1106
  chatId: string;
1023
- chatType: "text" | "image" | "contact" | "location" | "document" | "audio" | "video" | "protocol" | "contacts" | "highlyStructured" | "sendPayment" | "requestPayment" | "declinePaymentRequest" | "cancelPaymentRequest" | "template" | "sticker" | "groupInvite" | "product" | "deviceSent" | "lists" | "viewOnce" | "order" | "ephemeral" | "invoice" | "buttons" | "paymentInvite" | "interactive" | "reaction" | "interactiveResponse" | "pollCreation" | "pollUpdate" | "keepInChat" | "requestPhoneNumber" | "scheduledCallCreation" | "groupMentioned" | "pinInChat" | "scheduledCallEdit" | "ptv" | "botInvoke" | "callLog" | "encComment" | "bcall" | "lottieSticker" | "event" | "comment" | "placeholder" | "encEventUpdate";
1107
+ chatType: "text" | "album" | "image" | "contact" | "location" | "document" | "audio" | "video" | "protocol" | "contacts" | "highlyStructured" | "sendPayment" | "requestPayment" | "groupStatusMention" | "statusMention" | "declinePaymentRequest" | "cancelPaymentRequest" | "template" | "sticker" | "groupInvite" | "product" | "deviceSent" | "lists" | "viewOnce" | "order" | "ephemeral" | "invoice" | "buttons" | "paymentInvite" | "interactive" | "reaction" | "interactiveResponse" | "pollCreation" | "pollUpdate" | "keepInChat" | "requestPhoneNumber" | "scheduledCallCreation" | "groupMentioned" | "pinInChat" | "scheduledCallEdit" | "ptv" | "botInvoke" | "callLog" | "encComment" | "bcall" | "lottieSticker" | "event" | "comment" | "placeholder" | "encEventUpdate";
1024
1108
  receiverId: string;
1025
1109
  receiverName: string;
1026
1110
  roomId: string;
@@ -1037,6 +1121,9 @@ declare class Client {
1037
1121
  isPrefix: boolean;
1038
1122
  isSpam: boolean;
1039
1123
  isTagMe: boolean;
1124
+ isStatusMention: boolean;
1125
+ isGroupStatusMention: boolean;
1126
+ isHideTags: boolean;
1040
1127
  isGroup: boolean;
1041
1128
  isNewsletter: boolean;
1042
1129
  isQuestion: boolean;
@@ -1065,48 +1152,6 @@ declare class Client {
1065
1152
 
1066
1153
  declare const registerAuthCreds: (client: Client) => Promise<void>;
1067
1154
 
1068
- type FlushMode = 'manual' | 'sync' | 'debounce';
1069
- declare class Lowdb {
1070
- private data;
1071
- private path;
1072
- private pool;
1073
- private size;
1074
- private chunkDir;
1075
- private replacer;
1076
- private reviver;
1077
- private loaded;
1078
- private flushMode;
1079
- private debounceMs;
1080
- private flushTimer;
1081
- private dirty;
1082
- constructor(path: string, bufferJSON?: any, size?: number, flushMode?: FlushMode, debounceMs?: number);
1083
- private ensureLoaded;
1084
- private scheduleFlush;
1085
- read(): Promise<Map<string, any>>;
1086
- write(): Promise<void>;
1087
- set<T>(key: string, value: T): Promise<void>;
1088
- push<T>(key: string, value: T): Promise<void>;
1089
- upsert<T extends {
1090
- key?: {
1091
- id?: string;
1092
- };
1093
- id?: string;
1094
- }>(key: string, value: T, idKey?: string): Promise<void>;
1095
- get(key?: string | object): Promise<any>;
1096
- all(): Promise<any>;
1097
- delete(key: string): Promise<boolean>;
1098
- private saveChunk;
1099
- private loadChunk;
1100
- private delChunk;
1101
- private isMeta;
1102
- }
1103
- declare const createLowdb: (path: string, options?: {
1104
- BufferJSON?: any;
1105
- size?: number;
1106
- flushMode?: FlushMode;
1107
- debounceMs?: number;
1108
- }) => Lowdb;
1109
-
1110
1155
  declare const ignoreLint: (data: any) => any;
1111
1156
  declare const getLatestLibVersion: () => Promise<any>;
1112
1157
  declare const removeAuthCreds: (session: string) => Promise<void>;
@@ -1146,7 +1191,7 @@ declare class VideoProcessor {
1146
1191
  }
1147
1192
  declare class ImageProcessor {
1148
1193
  static getThumbnail(buffer: Buffer): Promise<string>;
1149
- static resizeForSticker(buffer: Buffer, quality: number): Promise<Buffer>;
1194
+ static resizeForSticker(buffer: Buffer, quality: number, shape?: string): Promise<Buffer>;
1150
1195
  }
1151
1196
  declare class MediaProcessor {
1152
1197
  static getThumbnail(input: MediaInput): Promise<string>;
@@ -1183,32 +1228,4 @@ declare const cleanupSocket: (socket: WASocket) => void;
1183
1228
  declare const repairSessionKeys: (session: string) => Promise<void>;
1184
1229
  declare const getExistingSocket: () => WASocket | null;
1185
1230
 
1186
- type WatchdogOptions = {
1187
- session: string;
1188
- checkIntervalMs?: number;
1189
- staleThresholdMs?: number;
1190
- cooldownMs?: number;
1191
- maxRetries?: number;
1192
- onRecovery?: () => Promise<void>;
1193
- };
1194
- declare class SessionWatchdog {
1195
- private lastActivityTime;
1196
- private lastRecoveryTime;
1197
- private checkInterval;
1198
- private isRecovering;
1199
- private retryCount;
1200
- private options;
1201
- constructor(options: WatchdogOptions);
1202
- start(): void;
1203
- stop(): void;
1204
- touch(): void;
1205
- private setupActivityListeners;
1206
- private check;
1207
- private isInCooldown;
1208
- private recover;
1209
- forceRecovery(): Promise<void>;
1210
- }
1211
- declare const createWatchdog: (options: WatchdogOptions) => SessionWatchdog;
1212
- declare const getWatchdog: () => SessionWatchdog | null;
1213
-
1214
- export { AudioProcessor, type AudioType, BaseMessagesType, ButtonInteractiveCallType, ButtonInteractiveCopyType, ButtonInteractiveReplyType, ButtonInteractiveSingleSelectType, ButtonInteractiveType, ButtonInteractiveUrlType, ButtonSimpleType, ButtonType, type CallsContext, CitationType, Client, ClientAuthPairingType, ClientAuthQRType, ClientBaseType, ClientOptionsType, type ConnectionContext, DEVICE_ENUM_TYPES, DocumentProcessor, type EventCallbackType, EventEnumType, FakeReplyType, ImageProcessor, LimiterType, ListenerCallsType, ListenerConnectionType, ListenerMessagesType, Lowdb, MESSAGE_ENUM_TYPES, MediaProcessor, type MessagesContext, type PluginDefinition, Plugins, type PluginsConfigType, type PluginsHandlerType, SessionWatchdog, StickerMetadataType, StickerProcessor, VideoProcessor, cleanJid, cleanMediaObject, cleanupSocket, configureFFmpeg, createLowdb, createWatchdog, definePlugins, extractJids, extractUrls, findGlobalWord, findNestedByKeys, generateId, getDeepContent, getExistingSocket, getLatestLibVersion, getMediaThumbnail, getUsersMentions, getVideoDuration, getVideoThumbnail, getWaAudio, getWaDocument, getWaSticker, getWatchdog, ignoreLint, logColor, modifyFn, normalizeText, numbersToJids, pickKeysFromArray, randomize, registerAuthCreds, removeAuthCreds, repairSessionKeys, shuffleString, toBuffer, toJson, toString, useAuthState };
1231
+ export { AudioProcessor, type AudioType, BaseMessagesType, ButtonInteractiveCallType, ButtonInteractiveCopyType, ButtonInteractiveReplyType, ButtonInteractiveSingleSelectType, ButtonInteractiveType, ButtonInteractiveUrlType, ButtonSimpleType, ButtonType, type CallsContext, CitationType, Client, ClientAuthPairingType, ClientAuthQRType, ClientBaseType, ClientOptionsType, type ConnectionContext, DEVICE_ENUM_TYPES, DocumentProcessor, type EventCallbackType, EventEnumType, FakeReplyType, ImageProcessor, LimiterType, ListenerCallsType, ListenerConnectionType, ListenerMessagesType, MESSAGE_ENUM_TYPES, MediaProcessor, type MessagesContext, type PluginDefinition, Plugins, type PluginsConfigType, type PluginsHandlerType, StickerMetadataType, StickerProcessor, StickerShapeType, VideoProcessor, cleanJid, cleanMediaObject, cleanupSocket, configureFFmpeg, definePlugins, extractJids, extractUrls, findGlobalWord, findNestedByKeys, generateId, getDeepContent, getExistingSocket, getLatestLibVersion, getMediaThumbnail, getUsersMentions, getVideoDuration, getVideoThumbnail, getWaAudio, getWaDocument, getWaSticker, ignoreLint, logColor, modifyFn, normalizeText, numbersToJids, pickKeysFromArray, randomize, registerAuthCreds, removeAuthCreds, repairSessionKeys, shuffleString, toBuffer, toJson, toString, useAuthState };