@vanzxy/baileys 2.0.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.
Files changed (281) hide show
  1. package/NOTICE.md +111 -0
  2. package/README.md +830 -0
  3. package/WAProto/index.d.ts +9 -0
  4. package/WAProto/index.js +142036 -0
  5. package/engine-requirements.js +13 -0
  6. package/lib/Defaults/index.d.ts +152 -0
  7. package/lib/Defaults/index.js +179 -0
  8. package/lib/Framework/Bot.js +209 -0
  9. package/lib/Framework/Context.js +90 -0
  10. package/lib/Framework/MediaManager.js +152 -0
  11. package/lib/Framework/SessionManager.js +34 -0
  12. package/lib/Framework/StatsManager.js +120 -0
  13. package/lib/Framework/Store/SQLiteStore.js +74 -0
  14. package/lib/Framework/index.js +11 -0
  15. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  16. package/lib/Signal/Group/ciphertext-message.js +12 -0
  17. package/lib/Signal/Group/group-session-builder.d.ts +7 -0
  18. package/lib/Signal/Group/group-session-builder.js +30 -0
  19. package/lib/Signal/Group/group_cipher.d.ts +10 -0
  20. package/lib/Signal/Group/group_cipher.js +82 -0
  21. package/lib/Signal/Group/index.d.ts +11 -0
  22. package/lib/Signal/Group/index.js +12 -0
  23. package/lib/Signal/Group/keyhelper.d.ts +6 -0
  24. package/lib/Signal/Group/keyhelper.js +18 -0
  25. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  26. package/lib/Signal/Group/sender-chain-key.js +26 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  28. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  29. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  30. package/lib/Signal/Group/sender-key-message.js +66 -0
  31. package/lib/Signal/Group/sender-key-name.d.ts +11 -0
  32. package/lib/Signal/Group/sender-key-name.js +48 -0
  33. package/lib/Signal/Group/sender-key-record.d.ts +12 -0
  34. package/lib/Signal/Group/sender-key-record.js +41 -0
  35. package/lib/Signal/Group/sender-key-state.d.ts +16 -0
  36. package/lib/Signal/Group/sender-key-state.js +84 -0
  37. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  38. package/lib/Signal/Group/sender-message-key.js +26 -0
  39. package/lib/Signal/libsignal.d.ts +54 -0
  40. package/lib/Signal/libsignal.js +431 -0
  41. package/lib/Signal/lid-mapping.d.ts +20 -0
  42. package/lib/Signal/lid-mapping.js +277 -0
  43. package/lib/Socket/Client/index.d.ts +2 -0
  44. package/lib/Socket/Client/index.js +3 -0
  45. package/lib/Socket/Client/types.d.ts +5 -0
  46. package/lib/Socket/Client/types.js +11 -0
  47. package/lib/Socket/Client/websocket.d.ts +12 -0
  48. package/lib/Socket/Client/websocket.js +54 -0
  49. package/lib/Socket/business.d.ts +395 -0
  50. package/lib/Socket/business.js +380 -0
  51. package/lib/Socket/chats.d.ts +136 -0
  52. package/lib/Socket/chats.js +1328 -0
  53. package/lib/Socket/communities.d.ts +561 -0
  54. package/lib/Socket/communities.js +434 -0
  55. package/lib/Socket/dugong.d.ts +117 -0
  56. package/lib/Socket/dugong.js +799 -0
  57. package/lib/Socket/groups.d.ts +285 -0
  58. package/lib/Socket/groups.js +355 -0
  59. package/lib/Socket/index.d.ts +531 -0
  60. package/lib/Socket/index.js +34 -0
  61. package/lib/Socket/messages-recv.d.ts +333 -0
  62. package/lib/Socket/messages-recv.js +1782 -0
  63. package/lib/Socket/messages-send.d.ts +329 -0
  64. package/lib/Socket/messages-send.js +1383 -0
  65. package/lib/Socket/mex.d.ts +1 -0
  66. package/lib/Socket/mex.js +42 -0
  67. package/lib/Socket/newsletter.d.ts +281 -0
  68. package/lib/Socket/newsletter.js +321 -0
  69. package/lib/Socket/socket.d.ts +60 -0
  70. package/lib/Socket/socket.js +1001 -0
  71. package/lib/Socket/username.js +153 -0
  72. package/lib/Store/index.d.ts +3 -0
  73. package/lib/Store/index.js +4 -0
  74. package/lib/Store/make-in-memory-store.d.ts +62 -0
  75. package/lib/Store/make-in-memory-store.js +429 -0
  76. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  77. package/lib/Store/make-ordered-dictionary.js +79 -0
  78. package/lib/Store/object-repository.d.ts +10 -0
  79. package/lib/Store/object-repository.js +24 -0
  80. package/lib/Types/Auth.d.ts +117 -0
  81. package/lib/Types/Auth.js +2 -0
  82. package/lib/Types/Bussines.d.ts +25 -0
  83. package/lib/Types/Bussines.js +2 -0
  84. package/lib/Types/Call.d.ts +15 -0
  85. package/lib/Types/Call.js +2 -0
  86. package/lib/Types/Chat.d.ts +124 -0
  87. package/lib/Types/Chat.js +8 -0
  88. package/lib/Types/Contact.d.ts +26 -0
  89. package/lib/Types/Contact.js +2 -0
  90. package/lib/Types/Events.d.ts +256 -0
  91. package/lib/Types/Events.js +2 -0
  92. package/lib/Types/GroupMetadata.d.ts +71 -0
  93. package/lib/Types/GroupMetadata.js +2 -0
  94. package/lib/Types/Label.d.ts +2 -0
  95. package/lib/Types/Label.js +25 -0
  96. package/lib/Types/LabelAssociation.d.ts +2 -0
  97. package/lib/Types/LabelAssociation.js +7 -0
  98. package/lib/Types/Message.d.ts +11 -0
  99. package/lib/Types/Message.js +18 -0
  100. package/lib/Types/Mex.d.ts +2 -0
  101. package/lib/Types/Mex.js +39 -0
  102. package/lib/Types/Product.d.ts +79 -0
  103. package/lib/Types/Product.js +2 -0
  104. package/lib/Types/RichType.d.ts +2 -0
  105. package/lib/Types/RichType.js +23 -0
  106. package/lib/Types/Signal.d.ts +87 -0
  107. package/lib/Types/Signal.js +2 -0
  108. package/lib/Types/Socket.d.ts +136 -0
  109. package/lib/Types/Socket.js +2 -0
  110. package/lib/Types/State.d.ts +5 -0
  111. package/lib/Types/State.js +56 -0
  112. package/lib/Types/USync.d.ts +26 -0
  113. package/lib/Types/USync.js +2 -0
  114. package/lib/Types/index.d.ts +66 -0
  115. package/lib/Types/index.js +26 -0
  116. package/lib/Utils/A2UI.js +277 -0
  117. package/lib/Utils/MessageBuilder.js +4405 -0
  118. package/lib/Utils/MessageBuilder_d.ts +411 -0
  119. package/lib/Utils/PersistentStore.js +592 -0
  120. package/lib/Utils/PersistentStore_d.ts +60 -0
  121. package/lib/Utils/anti-delete.d.ts +74 -0
  122. package/lib/Utils/anti-delete.js +222 -0
  123. package/lib/Utils/auth-utils.d.ts +57 -0
  124. package/lib/Utils/auth-utils.js +307 -0
  125. package/lib/Utils/auto-reply.d.ts +47 -0
  126. package/lib/Utils/auto-reply.js +158 -0
  127. package/lib/Utils/baileys-event-stream.d.ts +8 -0
  128. package/lib/Utils/baileys-event-stream.js +62 -0
  129. package/lib/Utils/browser-utils.d.ts +8 -0
  130. package/lib/Utils/browser-utils.js +28 -0
  131. package/lib/Utils/business.d.ts +49 -0
  132. package/lib/Utils/business.js +240 -0
  133. package/lib/Utils/button-helper-utils.js +314 -0
  134. package/lib/Utils/button-sender.js +824 -0
  135. package/lib/Utils/chat-control.d.ts +159 -0
  136. package/lib/Utils/chat-control.js +232 -0
  137. package/lib/Utils/chat-history-helpers.d.ts +21 -0
  138. package/lib/Utils/chat-history-helpers.js +71 -0
  139. package/lib/Utils/chat-utils.d.ts +407 -0
  140. package/lib/Utils/chat-utils.js +886 -0
  141. package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
  142. package/lib/Utils/companion-reg-client-utils.js +40 -0
  143. package/lib/Utils/crypto.d.ts +41 -0
  144. package/lib/Utils/crypto.js +148 -0
  145. package/lib/Utils/decode-wa-message.d.ts +83 -0
  146. package/lib/Utils/decode-wa-message.js +317 -0
  147. package/lib/Utils/event-buffer.d.ts +12 -0
  148. package/lib/Utils/event-buffer.js +636 -0
  149. package/lib/Utils/generics.d.ts +69 -0
  150. package/lib/Utils/generics.js +439 -0
  151. package/lib/Utils/history.d.ts +90 -0
  152. package/lib/Utils/history.js +147 -0
  153. package/lib/Utils/identity-change-handler.d.ts +13 -0
  154. package/lib/Utils/identity-change-handler.js +50 -0
  155. package/lib/Utils/index.d.ts +39 -0
  156. package/lib/Utils/index.js +46 -0
  157. package/lib/Utils/link-preview.d.ts +12 -0
  158. package/lib/Utils/link-preview.js +85 -0
  159. package/lib/Utils/logger.d.ts +2 -0
  160. package/lib/Utils/logger.js +3 -0
  161. package/lib/Utils/lt-hash.d.ts +12 -0
  162. package/lib/Utils/lt-hash.js +27 -0
  163. package/lib/Utils/make-mutex.d.ts +6 -0
  164. package/lib/Utils/make-mutex.js +33 -0
  165. package/lib/Utils/media-messages.d.ts +18 -0
  166. package/lib/Utils/media-messages.js +71 -0
  167. package/lib/Utils/media-set.d.ts +13 -0
  168. package/lib/Utils/media-set.js +172 -0
  169. package/lib/Utils/message-kind.js +139 -0
  170. package/lib/Utils/message-retry-manager.d.ts +79 -0
  171. package/lib/Utils/message-retry-manager.js +265 -0
  172. package/lib/Utils/message-search.d.ts +44 -0
  173. package/lib/Utils/message-search.js +189 -0
  174. package/lib/Utils/messages-media.d.ts +135 -0
  175. package/lib/Utils/messages-media.js +869 -0
  176. package/lib/Utils/messages.d.ts +44 -0
  177. package/lib/Utils/messages.js +2155 -0
  178. package/lib/Utils/noise-handler.d.ts +20 -0
  179. package/lib/Utils/noise-handler.js +201 -0
  180. package/lib/Utils/offline-node-processor.d.ts +9 -0
  181. package/lib/Utils/offline-node-processor.js +40 -0
  182. package/lib/Utils/past-participants.d.ts +14 -0
  183. package/lib/Utils/past-participants.js +40 -0
  184. package/lib/Utils/pre-key-manager.d.ts +25 -0
  185. package/lib/Utils/pre-key-manager.js +106 -0
  186. package/lib/Utils/process-message.d.ts +82 -0
  187. package/lib/Utils/process-message.js +809 -0
  188. package/lib/Utils/reporting-utils.d.ts +12 -0
  189. package/lib/Utils/reporting-utils.js +258 -0
  190. package/lib/Utils/rich-message-utils.d.ts +48 -0
  191. package/lib/Utils/rich-message-utils.js +445 -0
  192. package/lib/Utils/scheduling.d.ts +42 -0
  193. package/lib/Utils/scheduling.js +140 -0
  194. package/lib/Utils/signal.d.ts +82 -0
  195. package/lib/Utils/signal.js +201 -0
  196. package/lib/Utils/stanza-ack.d.ts +16 -0
  197. package/lib/Utils/stanza-ack.js +38 -0
  198. package/lib/Utils/status.d.ts +50 -0
  199. package/lib/Utils/status.js +108 -0
  200. package/lib/Utils/stickerpack.d.ts +51 -0
  201. package/lib/Utils/stickerpack.js +275 -0
  202. package/lib/Utils/sync-action-utils.d.ts +2 -0
  203. package/lib/Utils/sync-action-utils.js +49 -0
  204. package/lib/Utils/tc-token-utils.d.ts +29 -0
  205. package/lib/Utils/tc-token-utils.js +163 -0
  206. package/lib/Utils/templates.d.ts +76 -0
  207. package/lib/Utils/templates.js +151 -0
  208. package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
  209. package/lib/Utils/use-cache-manager-auth-state.js +82 -0
  210. package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
  211. package/lib/Utils/use-multi-file-auth-state.js +167 -0
  212. package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
  213. package/lib/Utils/use-single-file-auth-state.js +114 -0
  214. package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
  215. package/lib/Utils/use-sqlite-auth-state.js +170 -0
  216. package/lib/Utils/validate-connection.d.ts +42 -0
  217. package/lib/Utils/validate-connection.js +199 -0
  218. package/lib/Utils/vcard.d.ts +58 -0
  219. package/lib/Utils/vcard.js +105 -0
  220. package/lib/VoIP/audio-feeder.d.ts +15 -0
  221. package/lib/VoIP/audio-feeder.js +132 -0
  222. package/lib/VoIP/index.js +277 -0
  223. package/lib/VoIP/relay-transport.d.ts +43 -0
  224. package/lib/VoIP/relay-transport.js +559 -0
  225. package/lib/VoIP/signaling.js +624 -0
  226. package/lib/VoIP/types.d.ts +69 -0
  227. package/lib/VoIP/types.js +17 -0
  228. package/lib/VoIP/wasm-engine.d.ts +103 -0
  229. package/lib/VoIP/wasm-engine.js +1214 -0
  230. package/lib/VoIP/worker-bootstrap.js +1042 -0
  231. package/lib/WABinary/constants.d.ts +61 -0
  232. package/lib/WABinary/constants.js +1467 -0
  233. package/lib/WABinary/decode.d.ts +9 -0
  234. package/lib/WABinary/decode.js +262 -0
  235. package/lib/WABinary/encode.d.ts +2 -0
  236. package/lib/WABinary/encode.js +220 -0
  237. package/lib/WABinary/generic-utils.d.ts +74 -0
  238. package/lib/WABinary/generic-utils.js +277 -0
  239. package/lib/WABinary/index.d.ts +5 -0
  240. package/lib/WABinary/index.js +6 -0
  241. package/lib/WABinary/jid-utils.d.ts +28 -0
  242. package/lib/WABinary/jid-utils.js +96 -0
  243. package/lib/WABinary/types.d.ts +19 -0
  244. package/lib/WABinary/types.js +2 -0
  245. package/lib/WAM/BinaryInfo.d.ts +7 -0
  246. package/lib/WAM/BinaryInfo.js +10 -0
  247. package/lib/WAM/constants.d.ts +34926 -0
  248. package/lib/WAM/constants.js +22853 -0
  249. package/lib/WAM/encode.d.ts +1 -0
  250. package/lib/WAM/encode.js +150 -0
  251. package/lib/WAM/index.d.ts +3 -0
  252. package/lib/WAM/index.js +4 -0
  253. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
  254. package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
  255. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
  256. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +63 -0
  257. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  258. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  259. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  260. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  261. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
  262. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  263. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
  264. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  265. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
  266. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  267. package/lib/WAUSync/Protocols/index.d.ts +7 -0
  268. package/lib/WAUSync/Protocols/index.js +8 -0
  269. package/lib/WAUSync/USyncQuery.d.ts +20 -0
  270. package/lib/WAUSync/USyncQuery.js +122 -0
  271. package/lib/WAUSync/USyncUser.d.ts +16 -0
  272. package/lib/WAUSync/USyncUser.js +31 -0
  273. package/lib/WAUSync/index.d.ts +3 -0
  274. package/lib/WAUSync/index.js +4 -0
  275. package/lib/assets/wasm/loader.js +5 -0
  276. package/lib/assets/wasm/whatsapp.wasm +0 -0
  277. package/lib/assets/wasm/worker-modules.js +273 -0
  278. package/lib/index.d.ts +12 -0
  279. package/lib/index.js +20 -0
  280. package/package.json +175 -0
  281. package/postinstall-banner.js +56 -0
@@ -0,0 +1,13 @@
1
+ const major = parseInt(
2
+ process.versions.node.split('.')[0],
3
+ 10
4
+ );
5
+
6
+ if (major < 20) {
7
+ console.error(
8
+ `\n❌ This package requires Node.js 20+ to run reliably.\n` +
9
+ ` You are using Node.js ${process.versions.node}.\n` +
10
+ ` Please upgrade to Node.js 20+ to proceed.\n`
11
+ );
12
+ process.exit(1);
13
+ }
@@ -0,0 +1,152 @@
1
+ export const UNAUTHORIZED_CODES: number[];
2
+ export const BIZ_BOT_SUPPORT_PAYLOAD: "{\"version\":1,\"is_ai_message\":true,\"should_upload_client_logs\":false,\"should_show_system_message\":false,\"ticket_id\":\"7004947587700716\",\"citation_items\":[],\"ticket_locale\":\"us\"}";
3
+ export const DEFAULT_ORIGIN: "https://web.whatsapp.com";
4
+ export const CALL_VIDEO_PREFIX: "https://call.whatsapp.com/video/";
5
+ export const CALL_AUDIO_PREFIX: "https://call.whatsapp.com/voice/";
6
+ export const DONATE_URL: "";
7
+ export const LIBRARY_NAME: "vanzxy/baileys";
8
+ export const COMPANION_DEVICE_VERSION: {
9
+ primary: number;
10
+ secondary: number;
11
+ tertiary: number;
12
+ };
13
+ export const DEF_CALLBACK_PREFIX: "CB:";
14
+ export const DEF_TAG_PREFIX: "TAG:";
15
+ export const PHONE_CONNECTION_CB: "CB:Pong";
16
+ export const WA_ADV_ACCOUNT_SIG_PREFIX: any;
17
+ export const WA_ADV_DEVICE_SIG_PREFIX: any;
18
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: any;
19
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: any;
20
+ export const WA_DEFAULT_EPHEMERAL: number;
21
+ /** Status messages older than 24 hours are considered expired */
22
+ export const STATUS_EXPIRY_SECONDS: number;
23
+ /** WA Web enforces a 14-day maximum age for placeholder resend requests */
24
+ export const PLACEHOLDER_MAX_AGE_SECONDS: number;
25
+ export const NOISE_MODE: "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
26
+ export const DICT_VERSION: 3;
27
+ export const KEY_BUNDLE_TYPE: any;
28
+ export const NOISE_WA_HEADER: any;
29
+ export const LEXER_REGEX: RegExp;
30
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
31
+ export const URL_REGEX: RegExp;
32
+ export namespace WA_CERT_DETAILS {
33
+ let SERIAL: number;
34
+ let ISSUER: string;
35
+ let PUBLIC_KEY: any;
36
+ }
37
+ export const PROCESSABLE_HISTORY_TYPES: any[];
38
+ export namespace DEFAULT_CACHE_TTLS {
39
+ let SIGNAL_STORE: number;
40
+ let MSG_RETRY: number;
41
+ let CALL_OFFER: number;
42
+ let USER_DEVICES: number;
43
+ }
44
+ export namespace DEFAULT_CONNECTION_CONFIG {
45
+ export { version };
46
+ export let browser: any[];
47
+ export let waWebSocketUrl: string;
48
+ export let connectTimeoutMs: number;
49
+ export let keepAliveIntervalMs: number;
50
+ export let logger: any;
51
+ export let emitOwnEvents: boolean;
52
+ export let defaultQueryTimeoutMs: number;
53
+ export let customUploadHosts: never[];
54
+ export let retryRequestDelayMs: number;
55
+ export let maxMsgRetryCount: number;
56
+ export let fireInitQueries: boolean;
57
+ export let auth: undefined;
58
+ export let markOnlineOnConnect: boolean;
59
+ export let syncFullHistory: boolean;
60
+ export function patchMessageBeforeSending(msg: any): any;
61
+ export function shouldSyncHistoryMessage({ syncType }: {
62
+ syncType: any;
63
+ }): boolean;
64
+ export function shouldIgnoreJid(): boolean;
65
+ export let linkPreviewImageThumbnailWidth: number;
66
+ export namespace transactionOpts {
67
+ let maxCommitRetries: number;
68
+ let delayBetweenTriesMs: number;
69
+ }
70
+ export let eventBufferTimeoutMs: number;
71
+ export let statusBroadcastDelayMs: number;
72
+ export let albumDelayMs: number;
73
+ export let phashRetryEnabled: boolean;
74
+ export let generateHighQualityLinkPreview: boolean;
75
+ export let enableAutoSessionRecreation: boolean;
76
+ export let enableRecentMessageCache: boolean;
77
+ export let options: {};
78
+ export namespace appStateMacVerification {
79
+ let patch: boolean;
80
+ let snapshot: boolean;
81
+ }
82
+ export let countryCode: string;
83
+ export function getMessage(): Promise<undefined>;
84
+ export function cachedGroupMetadata(): Promise<undefined>;
85
+ export { makeLibSignalRepository as makeSignalRepository };
86
+ }
87
+ export const MEDIA_PATH_MAP: {
88
+ image: string;
89
+ video: string;
90
+ document: string;
91
+ audio: string;
92
+ sticker: string;
93
+ 'sticker-pack': string;
94
+ 'thumbnail-sticker-pack': string;
95
+ 'thumbnail-link': string;
96
+ 'thumbnail-image': string;
97
+ 'thumbnail-video': string;
98
+ 'thumbnail-document': string;
99
+ 'product-catalog-image': string;
100
+ 'md-app-state': string;
101
+ 'md-msg-hist': string;
102
+ 'biz-cover-photo': string;
103
+ };
104
+ export const NEWSLETTER_MEDIA_PATH_MAP: {
105
+ image: string;
106
+ video: string;
107
+ document: string;
108
+ audio: string;
109
+ sticker: string;
110
+ 'thumbnail-link': string;
111
+ };
112
+ export const MEDIA_HKDF_KEY_MAPPING: {
113
+ audio: string;
114
+ document: string;
115
+ gif: string;
116
+ image: string;
117
+ ppic: string;
118
+ product: string;
119
+ ptt: string;
120
+ 'sticker-pack': string;
121
+ 'thumbnail-sticker-pack': string;
122
+ sticker: string;
123
+ video: string;
124
+ 'thumbnail-document': string;
125
+ 'thumbnail-image': string;
126
+ 'thumbnail-video': string;
127
+ 'thumbnail-link': string;
128
+ 'md-msg-hist': string;
129
+ 'md-app-state': string;
130
+ 'product-catalog-image': string;
131
+ 'payment-bg-image': string;
132
+ ptv: string;
133
+ 'biz-cover-photo': string;
134
+ location: string;
135
+ contact: string;
136
+ 'voip-token': string;
137
+ };
138
+ export const MEDIA_KEYS: string[];
139
+ /** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
140
+ export const HISTORY_SYNC_PAUSED_TIMEOUT_MS: 120000;
141
+ export const MIN_PREKEY_COUNT: 5;
142
+ export const INITIAL_PREKEY_COUNT: 812;
143
+ export const UPLOAD_TIMEOUT: 30000;
144
+ export namespace TimeMs {
145
+ let Minute: number;
146
+ let Hour: number;
147
+ let Day: number;
148
+ let Week: number;
149
+ }
150
+ declare const version: number[];
151
+ import { makeLibSignalRepository } from '../Signal/libsignal.js';
152
+ export {};
@@ -0,0 +1,179 @@
1
+ import { proto } from '../../WAProto/index.js';
2
+ import { makeLibSignalRepository } from '../Signal/libsignal.js';
3
+ import { Browsers } from '../Utils/browser-utils.js';
4
+ import logger from '../Utils/logger.js';
5
+ // Vanz@Fix: disamain sama baseline yang dipake pas diff WAProto (lihat
6
+ // WAProto/CHANGELOG-proto-upgrade.md — sempet lebih baru dari fallback
7
+ // lama, jadi socket ngaku versi lebih tua dari field yang udah didukung
8
+ // proto-nya sendiri). Ini cuma fallback kalau fetchLatestBaileysVersion()
9
+ // gagal total (mis. GitHub gak bisa diakses) — tetap worth di-update
10
+ // berkala, dan runtime tetap disaranin pake fetchLatestWaWebVersion()
11
+ // dulu (parse sw.js langsung) baru fallback ke fetchLatestBaileysVersion()
12
+ // / konstanta ini, karena fetchLatestBaileysVersion resmi Baileys ada
13
+ // history bug isLatest:true padahal versinya stale (WhiskeySockets#2679).
14
+ const version = [2, 3000, 1046350168];
15
+ // Vanz@Fix (bug 65): this was an untracked, uncommented magic number inline
16
+ // inside generateRegistrationNode() in validate-connection.js — a *second*,
17
+ // independent hardcoded version (WA's "companion/device-props" version sent
18
+ // during device pairing, distinct from `version` above which is the WA Web
19
+ // client version used for appVersion/buildHash). It can go stale the exact
20
+ // same way `version` can (same failure mode as WhiskeySockets#2370/#2485),
21
+ // but unlike `version`, it isn't covered by fetchLatestWaWebVersion(),
22
+ // fetchLatestBaileysVersion(), or fetchBestWaVersion() — none of those touch
23
+ // it, so it was silently unmaintained. Named + documented here so it's at
24
+ // least visible and update-able; still worth bumping periodically by hand.
25
+ export const COMPANION_DEVICE_VERSION = { primary: 10, secondary: 15, tertiary: 7 };
26
+ export const UNAUTHORIZED_CODES = [401, 403, 419];
27
+ export const BIZ_BOT_SUPPORT_PAYLOAD = '{"version":1,"is_ai_message":true,"should_upload_client_logs":false,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
28
+ export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
29
+ export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
30
+ export const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
31
+ export const DONATE_URL = ''; // Vanz@Fix: cleared itsliaaa's donate URL fallback
32
+ export const LIBRARY_NAME = 'vanzxy/baileys';
33
+ export const DEF_CALLBACK_PREFIX = 'CB:';
34
+ export const DEF_TAG_PREFIX = 'TAG:';
35
+ export const PHONE_CONNECTION_CB = 'CB:Pong';
36
+ export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
37
+ export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
38
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
39
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
40
+ export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
41
+ /** Status messages older than 24 hours are considered expired */
42
+ export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
43
+ /** WA Web enforces a 14-day maximum age for placeholder resend requests */
44
+ export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
45
+ export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
46
+ export const DICT_VERSION = 3;
47
+ export const KEY_BUNDLE_TYPE = Buffer.from([5]);
48
+ export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]); // last is "DICT_VERSION"
49
+ export const LEXER_REGEX = /(\/\/.*|\/\*[\s\S]*?\*\/|#.*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`[\s\S]*?`)|(\b[a-zA-Z_]\w*\b)(?=\s*\()|(\b[a-zA-Z_]\w*\b)|(\b\d+(?:\.\d+)?\b)|(\s+|[^\w\s]+)/g;
50
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
51
+ export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
52
+ export const WA_CERT_DETAILS = {
53
+ SERIAL: 0,
54
+ ISSUER: 'WhatsAppLongTerm1',
55
+ PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
56
+ };
57
+ export const PROCESSABLE_HISTORY_TYPES = [
58
+ proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
59
+ proto.HistorySync.HistorySyncType.PUSH_NAME,
60
+ proto.HistorySync.HistorySyncType.RECENT,
61
+ proto.HistorySync.HistorySyncType.FULL,
62
+ proto.HistorySync.HistorySyncType.ON_DEMAND,
63
+ proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
64
+ proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
65
+ ];
66
+ export const DEFAULT_CACHE_TTLS = {
67
+ SIGNAL_STORE: 5 * 60, // 5 minutes
68
+ MSG_RETRY: 60 * 60, // 1 hour
69
+ CALL_OFFER: 5 * 60, // 5 minutes
70
+ USER_DEVICES: 5 * 60 // 5 minutes
71
+ };
72
+ export const DEFAULT_CONNECTION_CONFIG = {
73
+ version: version,
74
+ browser: Browsers.macOS('Chrome'),
75
+ waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
76
+ connectTimeoutMs: 20000,
77
+ keepAliveIntervalMs: 15000,
78
+ logger: logger.child({ class: 'baileys' }),
79
+ emitOwnEvents: true,
80
+ defaultQueryTimeoutMs: 60000,
81
+ customUploadHosts: [],
82
+ retryRequestDelayMs: 250,
83
+ maxMsgRetryCount: 3,
84
+ fireInitQueries: true,
85
+ auth: undefined,
86
+ markOnlineOnConnect: true,
87
+ syncFullHistory: true,
88
+ patchMessageBeforeSending: msg => msg,
89
+ shouldSyncHistoryMessage: ({ syncType }) => {
90
+ return syncType !== proto.HistorySync.HistorySyncType.FULL;
91
+ },
92
+ shouldIgnoreJid: () => false,
93
+ linkPreviewImageThumbnailWidth: 480, // Vanz@Fix: was 192 — too small, bumped to 480
94
+ transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
95
+ eventBufferTimeoutMs: 30000, // Vanz@Fix (bug 25): configurable — increase if bot is heavy load
96
+ statusBroadcastDelayMs: 1500, // Vanz@Fix (bug 5): configurable delay between status broadcasts — default 1500ms
97
+ albumDelayMs: 1500, // Vanz@Fix (bug 5): configurable delay between album message sends — default 1500ms
98
+ phashRetryEnabled: false, // Vanz@Fix (bug 54/55): enable phash retry on ack (caution: can cause loops if not careful)
99
+ generateHighQualityLinkPreview: true,
100
+ enableAutoSessionRecreation: true,
101
+ enableRecentMessageCache: true,
102
+ options: {},
103
+ appStateMacVerification: {
104
+ patch: false,
105
+ snapshot: false
106
+ },
107
+ countryCode: 'US',
108
+ // Vanz@Fix (bug 15): default returns undefined — every retry request will fail unless overridden.
109
+ // Override this in your makeWASocket config to return messages from your store:
110
+ // getMessage: async (key) => store.loadMessage(key.remoteJid, key.id)?.message
111
+ getMessage: async () => undefined,
112
+ cachedGroupMetadata: async () => undefined,
113
+ makeSignalRepository: makeLibSignalRepository
114
+ };
115
+ export const MEDIA_PATH_MAP = {
116
+ image: '/mms/image',
117
+ video: '/mms/video',
118
+ document: '/mms/document',
119
+ audio: '/mms/audio',
120
+ sticker: '/mms/image',
121
+ 'sticker-pack': '/mms/sticker-pack',
122
+ 'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
123
+ 'thumbnail-link': '/mms/image',
124
+ 'thumbnail-image': '/mms/image',
125
+ 'thumbnail-video': '/mms/video',
126
+ 'thumbnail-document': '/mms/document',
127
+ 'product-catalog-image': '/product/image',
128
+ 'md-app-state': '',
129
+ 'md-msg-hist': '/mms/md-app-state',
130
+ 'biz-cover-photo': '/pps/biz-cover-photo'
131
+ };
132
+ // Lia@Changes 06-02-26 --- Add newsletter media path for "/m1/" instead of "/o1/" (⁠≧⁠▽⁠≦⁠)
133
+ export const NEWSLETTER_MEDIA_PATH_MAP = {
134
+ image: '/newsletter/newsletter-image',
135
+ video: '/newsletter/newsletter-video',
136
+ document: '/newsletter/newsletter-document',
137
+ audio: '/newsletter/newsletter-audio',
138
+ sticker: '/newsletter/newsletter-image',
139
+ 'thumbnail-link': '/newsletter/newsletter-thumbnail-link'
140
+ };
141
+ export const MEDIA_HKDF_KEY_MAPPING = {
142
+ audio: 'Audio',
143
+ document: 'Document',
144
+ gif: 'Video',
145
+ image: 'Image',
146
+ ppic: '',
147
+ product: 'Image',
148
+ ptt: 'Audio',
149
+ 'sticker-pack': 'Sticker Pack',
150
+ 'thumbnail-sticker-pack': 'Sticker Pack Thumbnail',
151
+ sticker: 'Image',
152
+ video: 'Video',
153
+ 'thumbnail-document': 'Document Thumbnail',
154
+ 'thumbnail-image': 'Image Thumbnail',
155
+ 'thumbnail-video': 'Video Thumbnail',
156
+ 'thumbnail-link': 'Link Thumbnail',
157
+ 'md-msg-hist': 'History',
158
+ 'md-app-state': 'App State',
159
+ 'product-catalog-image': 'Product Catalog Image',
160
+ 'payment-bg-image': 'Payment Background',
161
+ ptv: 'Video',
162
+ 'biz-cover-photo': 'Image',
163
+ location: 'Location',
164
+ contact: 'Contact',
165
+ 'voip-token': 'Voip Token'
166
+ };
167
+ export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
168
+ /** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
169
+ export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
170
+ export const MIN_PREKEY_COUNT = 5;
171
+ export const INITIAL_PREKEY_COUNT = 812;
172
+ export const UPLOAD_TIMEOUT = 30000; // 30 seconds
173
+ export const TimeMs = {
174
+ Minute: 60 * 1000,
175
+ Hour: 60 * 60 * 1000,
176
+ Day: 24 * 60 * 60 * 1000,
177
+ Week: 7 * 24 * 60 * 60 * 1000
178
+ };
179
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,209 @@
1
+ import { Boom } from '@hapi/boom';
2
+ import makeWASocket from '../Socket/index.js';
3
+ import { DisconnectReason } from '../Types/index.js';
4
+ import { isJidGroup } from '../WABinary/index.js';
5
+ import defaultLogger from '../Utils/logger.js';
6
+ import { SQLiteStore } from './Store/SQLiteStore.js';
7
+ import { Context } from './Context.js';
8
+ import { SessionManager } from './SessionManager.js';
9
+ import { StatsManager } from './StatsManager.js';
10
+
11
+ // Vanz@Port (from @queenanya/baileys Framework, originally Baileys PR #2710
12
+ // by LuferOS) --- high-level Bot class: middleware routing (Express/Koa-style
13
+ // `use()`/`next()`), a `!command` dispatcher, an outgoing message queue that
14
+ // survives disconnects, and exponential-backoff auto-reconnect.
15
+ //
16
+ // Kept from upstream's fix pass:
17
+ // - command boundary check: `!sticker` no longer matches `!stickerSpam`
18
+ // - queue is rejected (not left hanging) on DisconnectReason.loggedOut
19
+ // - stats.observeMessage runs inside the per-message try block, so a
20
+ // SQLite error can't silently skip middleware for that message
21
+ // - reconnect timer handle is stored so stop()/restart() can cancel it
22
+ //
23
+ // Vanz@Fix vs upstream: SQLiteStore/StatsManager are now created through an
24
+ // async factory (see Store/SQLiteStore.js) instead of a synchronous
25
+ // constructor, since better-sqlite3 is lazy-loaded as an optional peer dep
26
+ // in this fork. That means store/session/stats setup moved out of the Bot
27
+ // constructor and into start() — the socket is only created *after* the
28
+ // store is ready, so no message can arrive before sessions/stats exist.
29
+ export class Bot {
30
+ constructor(config) {
31
+ this.middlewares = [];
32
+ this.messageQueue = [];
33
+ this.isConnected = false;
34
+ this.reconnectAttempts = 0;
35
+ this.reconnectTimer = null;
36
+ this.BASE_RECONNECT_DELAY = 1000;
37
+ this.MAX_RECONNECT_DELAY = 30000;
38
+ this.socket = null;
39
+ this.sessions = null;
40
+ this.stats = null;
41
+ this.store = null;
42
+ this.config = config;
43
+ this.logger = config.logger ?? defaultLogger.child({ module: 'Framework.Bot' });
44
+ }
45
+
46
+ /** Register a middleware function */
47
+ use(middleware) {
48
+ this.middlewares.push(middleware);
49
+ return this;
50
+ }
51
+
52
+ /**
53
+ * Register a command handler.
54
+ * Uses exact match OR prefix + whitespace so '!sticker' does NOT
55
+ * match '!stickerSpam' or '!stickerset'.
56
+ */
57
+ command(cmd, handler) {
58
+ this.use(async (ctx, next) => {
59
+ const text = ctx.text;
60
+ if (text === cmd || text?.startsWith(cmd + ' ')) {
61
+ await handler(ctx);
62
+ }
63
+ await next();
64
+ });
65
+ return this;
66
+ }
67
+
68
+ /** Register a handler that fires on any non-empty text */
69
+ onText(handler) {
70
+ this.use(async (ctx, next) => {
71
+ if (ctx.text) {
72
+ await handler(ctx);
73
+ }
74
+ await next();
75
+ });
76
+ return this;
77
+ }
78
+
79
+ /** Send a message — queues automatically when socket is disconnected */
80
+ async sendMessage(jid, content, options = {}) {
81
+ if (this.isConnected && this.socket) {
82
+ return this.socket.sendMessage(jid, content, options);
83
+ }
84
+ return new Promise((resolve, reject) => {
85
+ this.messageQueue.push({ jid, content, options, resolve, reject });
86
+ this.logger.info({ queueLength: this.messageQueue.length }, 'socket not connected — message queued');
87
+ });
88
+ }
89
+
90
+ /** Drain queued messages after reconnect. */
91
+ drainQueue() {
92
+ if (!this.isConnected || !this.socket || this.messageQueue.length === 0)
93
+ return;
94
+ this.logger.info({ pending: this.messageQueue.length }, 'draining message queue');
95
+ const queue = [...this.messageQueue];
96
+ this.messageQueue = [];
97
+ for (const msg of queue) {
98
+ this.socket.sendMessage(msg.jid, msg.content, msg.options).then(msg.resolve).catch(msg.reject);
99
+ }
100
+ }
101
+
102
+ /** Reject and clear the message queue. Called on loggedOut so callers don't hang forever. */
103
+ rejectQueue(reason) {
104
+ const queue = [...this.messageQueue];
105
+ this.messageQueue = [];
106
+ for (const msg of queue) {
107
+ msg.reject(new Boom(reason, { statusCode: 401 }));
108
+ }
109
+ if (queue.length > 0) {
110
+ this.logger.warn({ rejected: queue.length }, 'message queue rejected — session terminated');
111
+ }
112
+ }
113
+
114
+ /** Start the socket and wire all event handlers */
115
+ async start() {
116
+ if (this.reconnectTimer) {
117
+ clearTimeout(this.reconnectTimer);
118
+ this.reconnectTimer = null;
119
+ }
120
+ // Vanz@Fix: store/sessions must exist before the socket can receive
121
+ // any message, so this now awaits creation instead of doing it
122
+ // synchronously in the constructor.
123
+ if (!this.store) {
124
+ const dbPath = this.config.dbPath ?? 'baileys_store.db';
125
+ this.store = await SQLiteStore.create(dbPath);
126
+ this.sessions = new SessionManager(this.store);
127
+ }
128
+ this.socket = makeWASocket(this.config.socketConfig);
129
+ if (this.config.enableStats && !this.stats) {
130
+ this.stats = await StatsManager.create(this.config.dbPath ?? 'baileys_store.db', jid => this.socket.groupMetadata(jid));
131
+ }
132
+ this.socket.ev.on('messages.upsert', async ({ messages, type }) => {
133
+ if (type !== 'notify')
134
+ return;
135
+ for (const msg of messages) {
136
+ const ctx = new Context(this, msg);
137
+ try {
138
+ if (this.stats && ctx.remoteJid && isJidGroup(ctx.remoteJid)) {
139
+ const participant = msg.key.participant || msg.participant;
140
+ if (participant) {
141
+ const isSticker = !!msg.message?.stickerMessage;
142
+ this.stats.observeMessage(ctx.remoteJid, participant, isSticker);
143
+ }
144
+ }
145
+ await this.executeMiddlewares(ctx);
146
+ }
147
+ catch (err) {
148
+ this.logger.error({ err }, 'error executing middleware');
149
+ }
150
+ }
151
+ });
152
+ this.socket.ev.on('connection.update', update => {
153
+ const { connection, lastDisconnect } = update;
154
+ if (connection === 'open') {
155
+ this.logger.info('bot connected');
156
+ this.isConnected = true;
157
+ this.reconnectAttempts = 0;
158
+ this.drainQueue();
159
+ }
160
+ if (connection === 'close') {
161
+ this.isConnected = false;
162
+ const error = lastDisconnect?.error;
163
+ const statusCode = error?.output?.statusCode;
164
+ const isLoggedOut = statusCode === DisconnectReason.loggedOut;
165
+ this.logger.warn({ statusCode }, 'connection closed');
166
+ if (isLoggedOut) {
167
+ this.rejectQueue('session terminated (logged out)');
168
+ this.logger.info('session logged out — not reconnecting');
169
+ }
170
+ else {
171
+ this.reconnectAttempts++;
172
+ const delay = Math.min(this.MAX_RECONNECT_DELAY, this.BASE_RECONNECT_DELAY * Math.pow(2, this.reconnectAttempts - 1));
173
+ this.logger.info({ delay, attempt: this.reconnectAttempts }, 'scheduling reconnect');
174
+ this.reconnectTimer = setTimeout(() => {
175
+ this.reconnectTimer = null;
176
+ this.start().catch(err => {
177
+ this.logger.error({ err }, 'reconnect failed');
178
+ });
179
+ }, delay);
180
+ }
181
+ }
182
+ });
183
+ }
184
+
185
+ async executeMiddlewares(ctx) {
186
+ let index = -1;
187
+ const dispatch = async (i) => {
188
+ if (i <= index)
189
+ throw new Error('next() called multiple times');
190
+ index = i;
191
+ const middleware = this.middlewares[i];
192
+ if (middleware) {
193
+ await middleware(ctx, () => dispatch(i + 1));
194
+ }
195
+ };
196
+ await dispatch(0);
197
+ }
198
+
199
+ /** Gracefully stop the bot */
200
+ stop() {
201
+ if (this.reconnectTimer) {
202
+ clearTimeout(this.reconnectTimer);
203
+ this.reconnectTimer = null;
204
+ }
205
+ this.rejectQueue('bot stopped');
206
+ this.store?.close();
207
+ this.stats?.close();
208
+ }
209
+ }
@@ -0,0 +1,90 @@
1
+ import { MediaManager } from './MediaManager.js';
2
+
3
+ // Vanz@Port (from @queenanya/baileys Framework, originally Baileys PR #2710
4
+ // by LuferOS) --- message context helper: wraps a WAMessage with reply,
5
+ // react, session, and media helpers so command handlers don't have to touch
6
+ // the raw socket API.
7
+ //
8
+ // Kept from upstream's fix pass:
9
+ // - text getter also reads imageMessage/videoMessage/documentMessage
10
+ // captions, so a command sent as an image caption still matches
11
+ // - reply()/react()/replySticker()/replyVoiceNote() throw when remoteJid is
12
+ // missing instead of silently no-op'ing, so a handler can't believe a
13
+ // reply went out when it never did
14
+ export class Context {
15
+ constructor(bot, message) {
16
+ this.bot = bot;
17
+ this.message = message;
18
+ }
19
+
20
+ get remoteJid() {
21
+ return this.message.key.remoteJid;
22
+ }
23
+
24
+ /** Text content, including image/video/document captions so caption-only commands still match. */
25
+ get text() {
26
+ return (this.message.message?.conversation ||
27
+ this.message.message?.extendedTextMessage?.text ||
28
+ this.message.message?.imageMessage?.caption ||
29
+ this.message.message?.videoMessage?.caption ||
30
+ this.message.message?.documentMessage?.caption ||
31
+ undefined);
32
+ }
33
+
34
+ get quoted() {
35
+ return this.message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
36
+ }
37
+
38
+ session() {
39
+ return this.bot.sessions?.get(this.remoteJid || '');
40
+ }
41
+
42
+ setSession(data) {
43
+ this.bot.sessions?.set(this.remoteJid || '', data);
44
+ }
45
+
46
+ updateSession(updater) {
47
+ this.bot.sessions?.update(this.remoteJid || '', updater);
48
+ }
49
+
50
+ clearSession() {
51
+ this.bot.sessions?.delete(this.remoteJid || '');
52
+ }
53
+
54
+ async reply(content, options) {
55
+ if (!this.remoteJid)
56
+ throw new Error('Cannot reply: remoteJid is undefined');
57
+ await this.bot.sendMessage(this.remoteJid, {
58
+ ...content
59
+ }, {
60
+ quoted: this.message,
61
+ ...options
62
+ });
63
+ }
64
+
65
+ async react(emoji) {
66
+ if (!this.remoteJid)
67
+ throw new Error('Cannot react: remoteJid is undefined');
68
+ await this.bot.sendMessage(this.remoteJid, {
69
+ react: { text: emoji, key: this.message.key }
70
+ });
71
+ }
72
+
73
+ async replySticker(inputPathOrBuffer, metadata) {
74
+ if (!this.remoteJid)
75
+ throw new Error('Cannot reply: remoteJid is undefined');
76
+ const buffer = await MediaManager.convertToSticker(inputPathOrBuffer, metadata);
77
+ await this.reply({ sticker: buffer });
78
+ }
79
+
80
+ async replyVoiceNote(inputPathOrBuffer) {
81
+ if (!this.remoteJid)
82
+ throw new Error('Cannot reply: remoteJid is undefined');
83
+ const buffer = await MediaManager.convertToVoiceNote(inputPathOrBuffer);
84
+ await this.reply({
85
+ audio: buffer,
86
+ mimetype: 'audio/ogg; codecs=opus',
87
+ ptt: true
88
+ });
89
+ }
90
+ }