@vsxid/alya-baileys 0.0.0-stage → 1.0.3

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 (432) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1642 -2
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +5479 -0
  5. package/WAProto/fix-imports.js +85 -0
  6. package/WAProto/index.d.ts +14017 -0
  7. package/WAProto/index.js +97691 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/index.d.ts +75 -0
  10. package/lib/Defaults/index.d.ts.map +1 -0
  11. package/lib/Defaults/index.js +129 -0
  12. package/lib/Defaults/index.js.map +1 -0
  13. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  14. package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
  15. package/lib/Signal/Group/ciphertext-message.js +12 -0
  16. package/lib/Signal/Group/ciphertext-message.js.map +1 -0
  17. package/lib/Signal/Group/group-session-builder.d.ts +15 -0
  18. package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
  19. package/lib/Signal/Group/group-session-builder.js +30 -0
  20. package/lib/Signal/Group/group-session-builder.js.map +1 -0
  21. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  22. package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
  23. package/lib/Signal/Group/group_cipher.js +82 -0
  24. package/lib/Signal/Group/group_cipher.js.map +1 -0
  25. package/lib/Signal/Group/index.d.ts +12 -0
  26. package/lib/Signal/Group/index.d.ts.map +1 -0
  27. package/lib/Signal/Group/index.js +12 -0
  28. package/lib/Signal/Group/index.js.map +1 -0
  29. package/lib/Signal/Group/keyhelper.d.ts +11 -0
  30. package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
  31. package/lib/Signal/Group/keyhelper.js +18 -0
  32. package/lib/Signal/Group/keyhelper.js.map +1 -0
  33. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  34. package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
  35. package/lib/Signal/Group/sender-chain-key.js +26 -0
  36. package/lib/Signal/Group/sender-chain-key.js.map +1 -0
  37. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  38. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
  39. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  40. package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
  41. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  42. package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
  43. package/lib/Signal/Group/sender-key-message.js +66 -0
  44. package/lib/Signal/Group/sender-key-message.js.map +1 -0
  45. package/lib/Signal/Group/sender-key-name.d.ts +18 -0
  46. package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
  47. package/lib/Signal/Group/sender-key-name.js +48 -0
  48. package/lib/Signal/Group/sender-key-name.js.map +1 -0
  49. package/lib/Signal/Group/sender-key-record.d.ts +31 -0
  50. package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
  51. package/lib/Signal/Group/sender-key-record.js +41 -0
  52. package/lib/Signal/Group/sender-key-record.js.map +1 -0
  53. package/lib/Signal/Group/sender-key-state.d.ts +39 -0
  54. package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
  55. package/lib/Signal/Group/sender-key-state.js +84 -0
  56. package/lib/Signal/Group/sender-key-state.js.map +1 -0
  57. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  58. package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
  59. package/lib/Signal/Group/sender-message-key.js +26 -0
  60. package/lib/Signal/Group/sender-message-key.js.map +1 -0
  61. package/lib/Signal/libsignal.d.ts +5 -0
  62. package/lib/Signal/libsignal.d.ts.map +1 -0
  63. package/lib/Signal/libsignal.js +431 -0
  64. package/lib/Signal/libsignal.js.map +1 -0
  65. package/lib/Signal/lid-mapping.d.ts +23 -0
  66. package/lib/Signal/lid-mapping.d.ts.map +1 -0
  67. package/lib/Signal/lid-mapping.js +277 -0
  68. package/lib/Signal/lid-mapping.js.map +1 -0
  69. package/lib/Socket/Client/index.d.ts +3 -0
  70. package/lib/Socket/Client/index.d.ts.map +1 -0
  71. package/lib/Socket/Client/index.js +3 -0
  72. package/lib/Socket/Client/index.js.map +1 -0
  73. package/lib/Socket/Client/types.d.ts +16 -0
  74. package/lib/Socket/Client/types.d.ts.map +1 -0
  75. package/lib/Socket/Client/types.js +11 -0
  76. package/lib/Socket/Client/types.js.map +1 -0
  77. package/lib/Socket/Client/websocket.d.ts +13 -0
  78. package/lib/Socket/Client/websocket.d.ts.map +1 -0
  79. package/lib/Socket/Client/websocket.js +54 -0
  80. package/lib/Socket/Client/websocket.js.map +1 -0
  81. package/lib/Socket/business.d.ts +217 -0
  82. package/lib/Socket/business.d.ts.map +1 -0
  83. package/lib/Socket/business.js +379 -0
  84. package/lib/Socket/business.js.map +1 -0
  85. package/lib/Socket/chats.d.ts +125 -0
  86. package/lib/Socket/chats.d.ts.map +1 -0
  87. package/lib/Socket/chats.js +1198 -0
  88. package/lib/Socket/chats.js.map +1 -0
  89. package/lib/Socket/communities.d.ts +273 -0
  90. package/lib/Socket/communities.d.ts.map +1 -0
  91. package/lib/Socket/communities.js +431 -0
  92. package/lib/Socket/communities.js.map +1 -0
  93. package/lib/Socket/groups.d.ts +161 -0
  94. package/lib/Socket/groups.d.ts.map +1 -0
  95. package/lib/Socket/groups.js +347 -0
  96. package/lib/Socket/groups.js.map +1 -0
  97. package/lib/Socket/index.d.ts +260 -0
  98. package/lib/Socket/index.d.ts.map +1 -0
  99. package/lib/Socket/index.js +12 -0
  100. package/lib/Socket/index.js.map +1 -0
  101. package/lib/Socket/messages-recv.d.ts +203 -0
  102. package/lib/Socket/messages-recv.d.ts.map +1 -0
  103. package/lib/Socket/messages-recv.js +1772 -0
  104. package/lib/Socket/messages-recv.js.map +1 -0
  105. package/lib/Socket/messages-send.d.ts +199 -0
  106. package/lib/Socket/messages-send.d.ts.map +1 -0
  107. package/lib/Socket/messages-send.js +1169 -0
  108. package/lib/Socket/messages-send.js.map +1 -0
  109. package/lib/Socket/mex.d.ts +3 -0
  110. package/lib/Socket/mex.d.ts.map +1 -0
  111. package/lib/Socket/mex.js +42 -0
  112. package/lib/Socket/mex.js.map +1 -0
  113. package/lib/Socket/newsletter.d.ts +170 -0
  114. package/lib/Socket/newsletter.d.ts.map +1 -0
  115. package/lib/Socket/newsletter.js +181 -0
  116. package/lib/Socket/newsletter.js.map +1 -0
  117. package/lib/Socket/socket.d.ts +59 -0
  118. package/lib/Socket/socket.d.ts.map +1 -0
  119. package/lib/Socket/socket.js +970 -0
  120. package/lib/Socket/socket.js.map +1 -0
  121. package/lib/Types/Auth.d.ts +117 -0
  122. package/lib/Types/Auth.d.ts.map +1 -0
  123. package/lib/Types/Auth.js +2 -0
  124. package/lib/Types/Auth.js.map +1 -0
  125. package/lib/Types/Bussines.d.ts +25 -0
  126. package/lib/Types/Bussines.d.ts.map +1 -0
  127. package/lib/Types/Bussines.js +2 -0
  128. package/lib/Types/Bussines.js.map +1 -0
  129. package/lib/Types/Call.d.ts +15 -0
  130. package/lib/Types/Call.d.ts.map +1 -0
  131. package/lib/Types/Call.js +2 -0
  132. package/lib/Types/Call.js.map +1 -0
  133. package/lib/Types/Chat.d.ts +124 -0
  134. package/lib/Types/Chat.d.ts.map +1 -0
  135. package/lib/Types/Chat.js +8 -0
  136. package/lib/Types/Chat.js.map +1 -0
  137. package/lib/Types/Contact.d.ts +26 -0
  138. package/lib/Types/Contact.d.ts.map +1 -0
  139. package/lib/Types/Contact.js +2 -0
  140. package/lib/Types/Contact.js.map +1 -0
  141. package/lib/Types/Events.d.ts +256 -0
  142. package/lib/Types/Events.d.ts.map +1 -0
  143. package/lib/Types/Events.js +2 -0
  144. package/lib/Types/Events.js.map +1 -0
  145. package/lib/Types/GroupMetadata.d.ts +71 -0
  146. package/lib/Types/GroupMetadata.d.ts.map +1 -0
  147. package/lib/Types/GroupMetadata.js +2 -0
  148. package/lib/Types/GroupMetadata.js.map +1 -0
  149. package/lib/Types/Label.d.ts +47 -0
  150. package/lib/Types/Label.d.ts.map +1 -0
  151. package/lib/Types/Label.js +25 -0
  152. package/lib/Types/Label.js.map +1 -0
  153. package/lib/Types/LabelAssociation.d.ts +30 -0
  154. package/lib/Types/LabelAssociation.d.ts.map +1 -0
  155. package/lib/Types/LabelAssociation.js +7 -0
  156. package/lib/Types/LabelAssociation.js.map +1 -0
  157. package/lib/Types/Message.d.ts +320 -0
  158. package/lib/Types/Message.d.ts.map +1 -0
  159. package/lib/Types/Message.js +11 -0
  160. package/lib/Types/Message.js.map +1 -0
  161. package/lib/Types/Mex.d.ts +141 -0
  162. package/lib/Types/Mex.d.ts.map +1 -0
  163. package/lib/Types/Mex.js +37 -0
  164. package/lib/Types/Mex.js.map +1 -0
  165. package/lib/Types/Product.d.ts +79 -0
  166. package/lib/Types/Product.d.ts.map +1 -0
  167. package/lib/Types/Product.js +2 -0
  168. package/lib/Types/Product.js.map +1 -0
  169. package/lib/Types/Signal.d.ts +87 -0
  170. package/lib/Types/Signal.d.ts.map +1 -0
  171. package/lib/Types/Signal.js +2 -0
  172. package/lib/Types/Signal.js.map +1 -0
  173. package/lib/Types/Socket.d.ts +136 -0
  174. package/lib/Types/Socket.d.ts.map +1 -0
  175. package/lib/Types/Socket.js +3 -0
  176. package/lib/Types/Socket.js.map +1 -0
  177. package/lib/Types/State.d.ts +97 -0
  178. package/lib/Types/State.d.ts.map +1 -0
  179. package/lib/Types/State.js +56 -0
  180. package/lib/Types/State.js.map +1 -0
  181. package/lib/Types/USync.d.ts +26 -0
  182. package/lib/Types/USync.d.ts.map +1 -0
  183. package/lib/Types/USync.js +2 -0
  184. package/lib/Types/USync.js.map +1 -0
  185. package/lib/Types/index.d.ts +66 -0
  186. package/lib/Types/index.d.ts.map +1 -0
  187. package/lib/Types/index.js +26 -0
  188. package/lib/Types/index.js.map +1 -0
  189. package/lib/Utils/auth-utils.d.ts +24 -0
  190. package/lib/Utils/auth-utils.d.ts.map +1 -0
  191. package/lib/Utils/auth-utils.js +302 -0
  192. package/lib/Utils/auth-utils.js.map +1 -0
  193. package/lib/Utils/browser-utils.d.ts +4 -0
  194. package/lib/Utils/browser-utils.d.ts.map +1 -0
  195. package/lib/Utils/browser-utils.js +29 -0
  196. package/lib/Utils/browser-utils.js.map +1 -0
  197. package/lib/Utils/business.d.ts +23 -0
  198. package/lib/Utils/business.d.ts.map +1 -0
  199. package/lib/Utils/business.js +231 -0
  200. package/lib/Utils/business.js.map +1 -0
  201. package/lib/Utils/chat-utils.d.ts +100 -0
  202. package/lib/Utils/chat-utils.d.ts.map +1 -0
  203. package/lib/Utils/chat-utils.js +872 -0
  204. package/lib/Utils/chat-utils.js.map +1 -0
  205. package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
  206. package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
  207. package/lib/Utils/companion-reg-client-utils.js +35 -0
  208. package/lib/Utils/companion-reg-client-utils.js.map +1 -0
  209. package/lib/Utils/crypto.d.ts +37 -0
  210. package/lib/Utils/crypto.d.ts.map +1 -0
  211. package/lib/Utils/crypto.js +118 -0
  212. package/lib/Utils/crypto.js.map +1 -0
  213. package/lib/Utils/decode-wa-message.d.ts +66 -0
  214. package/lib/Utils/decode-wa-message.d.ts.map +1 -0
  215. package/lib/Utils/decode-wa-message.js +317 -0
  216. package/lib/Utils/decode-wa-message.js.map +1 -0
  217. package/lib/Utils/event-buffer.d.ts +36 -0
  218. package/lib/Utils/event-buffer.d.ts.map +1 -0
  219. package/lib/Utils/event-buffer.js +622 -0
  220. package/lib/Utils/event-buffer.js.map +1 -0
  221. package/lib/Utils/generics.d.ts +92 -0
  222. package/lib/Utils/generics.d.ts.map +1 -0
  223. package/lib/Utils/generics.js +393 -0
  224. package/lib/Utils/generics.js.map +1 -0
  225. package/lib/Utils/history.d.ts +24 -0
  226. package/lib/Utils/history.d.ts.map +1 -0
  227. package/lib/Utils/history.js +134 -0
  228. package/lib/Utils/history.js.map +1 -0
  229. package/lib/Utils/identity-change-handler.d.ts +44 -0
  230. package/lib/Utils/identity-change-handler.d.ts.map +1 -0
  231. package/lib/Utils/identity-change-handler.js +50 -0
  232. package/lib/Utils/identity-change-handler.js.map +1 -0
  233. package/lib/Utils/index.d.ts +22 -0
  234. package/lib/Utils/index.d.ts.map +1 -0
  235. package/lib/Utils/index.js +22 -0
  236. package/lib/Utils/index.js.map +1 -0
  237. package/lib/Utils/link-preview.d.ts +21 -0
  238. package/lib/Utils/link-preview.d.ts.map +1 -0
  239. package/lib/Utils/link-preview.js +85 -0
  240. package/lib/Utils/link-preview.js.map +1 -0
  241. package/lib/Utils/logger.d.ts +12 -0
  242. package/lib/Utils/logger.d.ts.map +1 -0
  243. package/lib/Utils/logger.js +3 -0
  244. package/lib/Utils/logger.js.map +1 -0
  245. package/lib/Utils/lt-hash.d.ts +8 -0
  246. package/lib/Utils/lt-hash.d.ts.map +1 -0
  247. package/lib/Utils/lt-hash.js +8 -0
  248. package/lib/Utils/lt-hash.js.map +1 -0
  249. package/lib/Utils/make-mutex.d.ts +9 -0
  250. package/lib/Utils/make-mutex.d.ts.map +1 -0
  251. package/lib/Utils/make-mutex.js +33 -0
  252. package/lib/Utils/make-mutex.js.map +1 -0
  253. package/lib/Utils/message-retry-manager.d.ts +115 -0
  254. package/lib/Utils/message-retry-manager.d.ts.map +1 -0
  255. package/lib/Utils/message-retry-manager.js +265 -0
  256. package/lib/Utils/message-retry-manager.js.map +1 -0
  257. package/lib/Utils/messages-media.d.ts +133 -0
  258. package/lib/Utils/messages-media.d.ts.map +1 -0
  259. package/lib/Utils/messages-media.js +788 -0
  260. package/lib/Utils/messages-media.js.map +1 -0
  261. package/lib/Utils/messages.d.ts +91 -0
  262. package/lib/Utils/messages.d.ts.map +1 -0
  263. package/lib/Utils/messages.js +893 -0
  264. package/lib/Utils/messages.js.map +1 -0
  265. package/lib/Utils/noise-handler.d.ts +20 -0
  266. package/lib/Utils/noise-handler.d.ts.map +1 -0
  267. package/lib/Utils/noise-handler.js +201 -0
  268. package/lib/Utils/noise-handler.js.map +1 -0
  269. package/lib/Utils/offline-node-processor.d.ts +17 -0
  270. package/lib/Utils/offline-node-processor.d.ts.map +1 -0
  271. package/lib/Utils/offline-node-processor.js +40 -0
  272. package/lib/Utils/offline-node-processor.js.map +1 -0
  273. package/lib/Utils/pre-key-manager.d.ts +28 -0
  274. package/lib/Utils/pre-key-manager.d.ts.map +1 -0
  275. package/lib/Utils/pre-key-manager.js +106 -0
  276. package/lib/Utils/pre-key-manager.js.map +1 -0
  277. package/lib/Utils/process-message.d.ts +60 -0
  278. package/lib/Utils/process-message.d.ts.map +1 -0
  279. package/lib/Utils/process-message.js +630 -0
  280. package/lib/Utils/process-message.js.map +1 -0
  281. package/lib/Utils/reporting-utils.d.ts +11 -0
  282. package/lib/Utils/reporting-utils.d.ts.map +1 -0
  283. package/lib/Utils/reporting-utils.js +258 -0
  284. package/lib/Utils/reporting-utils.js.map +1 -0
  285. package/lib/Utils/signal.d.ts +47 -0
  286. package/lib/Utils/signal.d.ts.map +1 -0
  287. package/lib/Utils/signal.js +201 -0
  288. package/lib/Utils/signal.js.map +1 -0
  289. package/lib/Utils/stanza-ack.d.ts +11 -0
  290. package/lib/Utils/stanza-ack.d.ts.map +1 -0
  291. package/lib/Utils/stanza-ack.js +38 -0
  292. package/lib/Utils/stanza-ack.js.map +1 -0
  293. package/lib/Utils/sync-action-utils.d.ts +19 -0
  294. package/lib/Utils/sync-action-utils.d.ts.map +1 -0
  295. package/lib/Utils/sync-action-utils.js +49 -0
  296. package/lib/Utils/sync-action-utils.js.map +1 -0
  297. package/lib/Utils/tc-token-utils.d.ts +37 -0
  298. package/lib/Utils/tc-token-utils.d.ts.map +1 -0
  299. package/lib/Utils/tc-token-utils.js +164 -0
  300. package/lib/Utils/tc-token-utils.js.map +1 -0
  301. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  302. package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
  303. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  304. package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
  305. package/lib/Utils/validate-connection.d.ts +11 -0
  306. package/lib/Utils/validate-connection.d.ts.map +1 -0
  307. package/lib/Utils/validate-connection.js +210 -0
  308. package/lib/Utils/validate-connection.js.map +1 -0
  309. package/lib/WABinary/constants.d.ts +28 -0
  310. package/lib/WABinary/constants.d.ts.map +1 -0
  311. package/lib/WABinary/constants.js +1301 -0
  312. package/lib/WABinary/constants.js.map +1 -0
  313. package/lib/WABinary/decode.d.ts +7 -0
  314. package/lib/WABinary/decode.d.ts.map +1 -0
  315. package/lib/WABinary/decode.js +262 -0
  316. package/lib/WABinary/decode.js.map +1 -0
  317. package/lib/WABinary/encode.d.ts +3 -0
  318. package/lib/WABinary/encode.d.ts.map +1 -0
  319. package/lib/WABinary/encode.js +220 -0
  320. package/lib/WABinary/encode.js.map +1 -0
  321. package/lib/WABinary/generic-utils.d.ts +15 -0
  322. package/lib/WABinary/generic-utils.d.ts.map +1 -0
  323. package/lib/WABinary/generic-utils.js +113 -0
  324. package/lib/WABinary/generic-utils.js.map +1 -0
  325. package/lib/WABinary/index.d.ts +6 -0
  326. package/lib/WABinary/index.d.ts.map +1 -0
  327. package/lib/WABinary/index.js +6 -0
  328. package/lib/WABinary/index.js.map +1 -0
  329. package/lib/WABinary/jid-utils.d.ts +48 -0
  330. package/lib/WABinary/jid-utils.d.ts.map +1 -0
  331. package/lib/WABinary/jid-utils.js +96 -0
  332. package/lib/WABinary/jid-utils.js.map +1 -0
  333. package/lib/WABinary/types.d.ts +19 -0
  334. package/lib/WABinary/types.d.ts.map +1 -0
  335. package/lib/WABinary/types.js +2 -0
  336. package/lib/WABinary/types.js.map +1 -0
  337. package/lib/WAM/BinaryInfo.d.ts +9 -0
  338. package/lib/WAM/BinaryInfo.d.ts.map +1 -0
  339. package/lib/WAM/BinaryInfo.js +10 -0
  340. package/lib/WAM/BinaryInfo.js.map +1 -0
  341. package/lib/WAM/constants.d.ts +40 -0
  342. package/lib/WAM/constants.d.ts.map +1 -0
  343. package/lib/WAM/constants.js +22853 -0
  344. package/lib/WAM/constants.js.map +1 -0
  345. package/lib/WAM/encode.d.ts +3 -0
  346. package/lib/WAM/encode.d.ts.map +1 -0
  347. package/lib/WAM/encode.js +150 -0
  348. package/lib/WAM/encode.js.map +1 -0
  349. package/lib/WAM/index.d.ts +4 -0
  350. package/lib/WAM/index.d.ts.map +1 -0
  351. package/lib/WAM/index.js +4 -0
  352. package/lib/WAM/index.js.map +1 -0
  353. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  354. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
  355. package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
  356. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
  357. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  358. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
  359. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  360. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
  361. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  362. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
  363. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  364. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
  365. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  366. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
  367. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  368. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
  369. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  370. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
  371. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  372. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
  373. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  374. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
  375. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  376. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
  377. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  378. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
  379. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  380. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
  381. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  382. package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
  383. package/lib/WAUSync/Protocols/index.js +6 -0
  384. package/lib/WAUSync/Protocols/index.js.map +1 -0
  385. package/lib/WAUSync/USyncQuery.d.ts +30 -0
  386. package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
  387. package/lib/WAUSync/USyncQuery.js +98 -0
  388. package/lib/WAUSync/USyncQuery.js.map +1 -0
  389. package/lib/WAUSync/USyncUser.d.ts +17 -0
  390. package/lib/WAUSync/USyncUser.d.ts.map +1 -0
  391. package/lib/WAUSync/USyncUser.js +31 -0
  392. package/lib/WAUSync/USyncUser.js.map +1 -0
  393. package/lib/WAUSync/index.d.ts +4 -0
  394. package/lib/WAUSync/index.d.ts.map +1 -0
  395. package/lib/WAUSync/index.js +4 -0
  396. package/lib/WAUSync/index.js.map +1 -0
  397. package/lib/index.d.ts +12 -0
  398. package/lib/index.d.ts.map +1 -0
  399. package/lib/index.js +12 -0
  400. package/lib/index.js.map +1 -0
  401. package/media/example.mp4 +0 -0
  402. package/media/thumb-alya.jpg +0 -0
  403. package/media/thumb-alya2.jpg +0 -0
  404. package/package.json +162 -4
  405. package/src/airich.js +93 -0
  406. package/src/anti-call.js +20 -0
  407. package/src/anti-delete.js +37 -0
  408. package/src/auto-reply.js +68 -0
  409. package/src/biz.js +80 -0
  410. package/src/broadcast.js +17 -0
  411. package/src/buttons_sheet.js +20 -0
  412. package/src/carousel.js +54 -0
  413. package/src/code-snippet.js +64 -0
  414. package/src/cta_copy.js +12 -0
  415. package/src/cta_url.js +12 -0
  416. package/src/custom-pairing.js +24 -0
  417. package/src/fake-quoted.js +166 -0
  418. package/src/fixxed-pairing.js +24 -0
  419. package/src/g.us.js +41 -0
  420. package/src/index.js +27 -0
  421. package/src/komunitas.js +35 -0
  422. package/src/lid-jid.js +45 -0
  423. package/src/limited_time_offer.js +40 -0
  424. package/src/location.js +20 -0
  425. package/src/newletter.js +35 -0
  426. package/src/poll.js +24 -0
  427. package/src/presence.js +47 -0
  428. package/src/status-story.js +31 -0
  429. package/src/sticker.js +4 -0
  430. package/src/storeJSON.js +33 -0
  431. package/src/url.js +25 -0
  432. package/src/voip.js +166 -0
package/README.md CHANGED
@@ -1,3 +1,1643 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <img src="https://raw.github.usercontent.com/Plenger-final/alya-baileys/main/media/thumb-alya2.jpg" alt="Alya Thumbnail" alt="Alya Baileys Banner" src="https://raw.github.usercontent.com/Plenger-final/alya-baileys/main/media/thumb-alya2.jpg" alt="Alya Thumbnail" alt="Alya Baileys Banner" src="https://raw.github.usercontent.com/Plenger-final/alya-baileys/main/media/thumb-alya2.jpg" alt="Alya Thumbnail" controls="controls" style="max-width: 100%;"></video>
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ <h1 align='center'><img alt="Baileys logo" src="https://raw.githubusercontent.com/vsxid/alya-baileys/refs/heads/master/Media/logo.png" height="75"/></h1>
5
+
6
+ <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
7
+
8
+
9
+ > [!CAUTION]
10
+ > NOTICE OF BREAKING CHANGE.
11
+ >
12
+ > As of 1.0.2, multiple breaking changes were introduced into the library.
13
+ >
14
+ > Please check out https://whiskey.so/migrate-latest for more information.
15
+
16
+ # Important Note
17
+ This is a temporary README.md, the new guide is in development and will this file will be replaced with .github/README.md (already a default on GitHub).
18
+
19
+ New guide link: https://baileys.wiki
20
+
21
+ # Get Support
22
+
23
+ If you'd like business to enterprise-level support from Rajeh, the current maintainer of Baileys, you can book a video chat. Book a 1 hour time slot by contacting him on Discord or pre-ordering [here](https://purpshell.dev/book). The earlier you pre-order the better, as his time slots usually fill up very quickly. He offers immense value per hour and will answer all your questions before the time runs out.
24
+
25
+ If you are a business, we encourage you to contribute back to the high development costs of the project and to feed the maintainers who dump tens of hours a week on this. You can do so by booking meetings or sponsoring below. All support, even in bona fide / contribution hours, is welcome by businesses of all sizes. This is not condoning or endorsing businesses to use the library. See the Disclaimer below.
26
+
27
+ # Sponsor
28
+ If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
29
+
30
+ # Disclaimer
31
+ This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates.
32
+ The official WhatsApp website can be found at whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
33
+
34
+ The maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp. The maintainers of this application call upon the personal responsibility of its users to use this application in a fair way, as it is intended to be used.
35
+ Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
36
+
37
+ ##
38
+
39
+ - Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
40
+ - Not running Selenium or Chromium saves you like **half a gig** of ram :/
41
+ - Baileys supports interacting with the multi-device & web versions of WhatsApp.
42
+ - Thank you to [@pokearaujo](https://github.com/pokearaujo/multidevice) for writing his observations on the workings of WhatsApp Multi-Device. Also, thank you to [@Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing his observations on the workings of WhatsApp Web and thanks to [@Rhymen](https://github.com/Rhymen/go-whatsapp/) for the __go__ implementation.
43
+
44
+ > [!IMPORTANT]
45
+ > The original repository had to be removed by the original author - we now continue development in this repository here.
46
+ This is the only official repository and is maintained by the community.
47
+ > **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
48
+
49
+ ## Example
50
+
51
+ Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
52
+ The script covers most common use cases.
53
+ To run the example script, download or clone the repo and then type the following in a terminal:
54
+ 1. ``` cd path/to/Baileys ```
55
+ 2. ``` yarn ```
56
+ 3. ``` yarn example ```
57
+
58
+ ## Install
59
+
60
+ Use the stable version:
61
+ ```
62
+ yarn add @vsxid/alya-baileys
63
+ ```
64
+
65
+ Use the edge version (no guarantee of stability, but latest fixes + features)
66
+ ```
67
+ yarn add github:Plenger-final/alya-baileys
68
+ ```
69
+
70
+ Then import your code using:
71
+ ```ts
72
+ import makeWASocket from '@vsxid/alya-baileys'
73
+ ```
74
+
75
+ # Links
76
+
77
+ - [Discord](https://discord.gg/WeJM5FP9GG)
78
+ - [Docs](https://baileys.wiki/docs/intro/)
79
+
80
+ #index
81
+
82
+ - [Installation / Instalasi](#installation--instalasi)
83
+ - [Basic Connection & Custom Pairing / Koneksi Dasar & Custom Pairing](#basic-connection--custom-pairing--koneksi-dasar--custom-pairing)
84
+ - [Interactive Buttons & Thumbnail (`<biz>` Fix) / Tombol Interaktif & Thumbnail](#interactive-buttons--thumbnail-biz-fix--tombol-interaktif--thumbnail)
85
+ - [Carousel, Offer, Location & URL / Carousel, Promo, Lokasi & URL](#carousel-offer-location--url--carousel-promo-lokasi--url)
86
+ - [AI Rich Response & Code Snippets / Pesan AI & Kirim Kode](#ai-rich-response--code-snippets--pesan-ai--kirim-kode)
87
+ - [Group (`@g.us`), `@lid` Resolver, Community & Newsletter / Grup, `@lid`, Komunitas & Saluran](#group-gus-lid-resolver-community--newsletter--grup-lid-komunitas--saluran)
88
+ - [Auto-Reply, Presence, Poll, Broadcast & Store / Auto-Reply, Status, Polling, Broadcast & Store](#auto-reply-presence-poll-broadcast--store--auto-reply-status-polling-broadcast--store)
89
+ - [VoIP WebRTC Audio & Call Link / Panggilan Suara WebRTC & Call Link](#voip-webrtc-audio--call-link--panggilan-suara-webrtc--call-link)
90
+ - [Anti-Delete Message / Anti Hapus Pesan](#anti-delete-message--anti-hapus-pesan)
91
+ - [Auto View & React Story / Auto Lihat & React Status](#auto-view--react-story--auto-lihat--react-status)
92
+ - [Custom Fake Quoted Presets / Preset Fake Quoted Custom](#custom-fake-quoted-presets--preset-fake-quoted-custom)
93
+
94
+
95
+ - [Connecting Account](#connecting-account)
96
+ - [Connect with QR-CODE](#starting-socket-with-qr-code)
97
+ - [Connect with Pairing Code](#starting-socket-with-pairing-code)
98
+ - [Receive Full History](#receive-full-history)
99
+ - [Important Notes About Socket Config](#important-notes-about-socket-config)
100
+ - [Caching Group Metadata (Recommended)](#caching-group-metadata-recommended)
101
+ - [Improve Retry System & Decrypt Poll Votes](#improve-retry-system--decrypt-poll-votes)
102
+ - [Receive Notifications in Whatsapp App](#receive-notifications-in-whatsapp-app)
103
+
104
+ - [Save Auth Info](#saving--restoring-sessions)
105
+ - [Handling Events](#handling-events)
106
+ - [Example to Start](#example-to-start)
107
+ - [Decrypt Poll Votes](#decrypt-poll-votes)
108
+ - [Summary of Events on First Connection](#summary-of-events-on-first-connection)
109
+ - [Implementing a Data Store](#implementing-a-data-store)
110
+ - [Whatsapp IDs Explain](#whatsapp-ids-explain)
111
+ - [Utility Functions](#utility-functions)
112
+ - [Sending Messages](#sending-messages)
113
+ - [Non-Media Messages](#non-media-messages)
114
+ - [Text Message](#text-message)
115
+ - [Quote Message](#quote-message-works-with-all-types)
116
+ - [Mention User](#mention-user-works-with-most-types)
117
+ - [Forward Messages](#forward-messages)
118
+ - [Location Message](#location-message)
119
+ - [Contact Message](#contact-message)
120
+ - [Reaction Message](#reaction-message)
121
+ - [Pin Message](#pin-message)
122
+ - [Poll Message](#poll-message)
123
+ - [Sending with Link Preview](#sending-messages-with-link-previews)
124
+ - [Media Messages](#media-messages)
125
+ - [Gif Message](#gif-message)
126
+ - [Video Message](#video-message)
127
+ - [Audio Message](#audio-message)
128
+ - [Image Message](#image-message)
129
+ - [ViewOnce Message](#view-once-message)
130
+ - [Modify Messages](#modify-messages)
131
+ - [Delete Messages (for everyone)](#deleting-messages-for-everyone)
132
+ - [Edit Messages](#editing-messages)
133
+ - [Manipulating Media Messages](#manipulating-media-messages)
134
+ - [Thumbnail in Media Messages](#thumbnail-in-media-messages)
135
+ - [Downloading Media Messages](#downloading-media-messages)
136
+ - [Re-upload Media Message to Whatsapp](#re-upload-media-message-to-whatsapp)
137
+ - [Reject Call](#reject-call)
138
+ - [Send States in Chat](#send-states-in-chat)
139
+ - [Reading Messages](#reading-messages)
140
+ - [Update Presence](#update-presence)
141
+ - [Modifying Chats](#modifying-chats)
142
+ - [Archive a Chat](#archive-a-chat)
143
+ - [Mute/Unmute a Chat](#muteunmute-a-chat)
144
+ - [Mark a Chat Read/Unread](#mark-a-chat-readunread)
145
+ - [Delete a Message for Me](#delete-a-message-for-me)
146
+ - [Delete a Chat](#delete-a-chat)
147
+ - [Star/Unstar a Message](#starunstar-a-message)
148
+ - [Disappearing Messages](#disappearing-messages)
149
+ - [User Querys](#user-querys)
150
+ - [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
151
+ - [Query Chat History (groups too)](#query-chat-history-groups-too)
152
+ - [Fetch Status](#fetch-status)
153
+ - [Fetch Profile Picture (groups too)](#fetch-profile-picture-groups-too)
154
+ - [Fetch Bussines Profile (such as description or category)](#fetch-bussines-profile-such-as-description-or-category)
155
+ - [Fetch Someone's Presence (if they're typing or online)](#fetch-someones-presence-if-theyre-typing-or-online)
156
+ - [Change Profile](#change-profile)
157
+ - [Change Profile Status](#change-profile-status)
158
+ - [Change Profile Name](#change-profile-name)
159
+ - [Change Display Picture (groups too)](#change-display-picture-groups-too)
160
+ - [Remove display picture (groups too)](#remove-display-picture-groups-too)
161
+ - [Groups](#groups)
162
+ - [Create a Group](#create-a-group)
163
+ - [Add/Remove or Demote/Promote](#addremove-or-demotepromote)
164
+ - [Change Subject (name)](#change-subject-name)
165
+ - [Change Description](#change-description)
166
+ - [Change Settings](#change-settings)
167
+ - [Leave a Group](#leave-a-group)
168
+ - [Get Invite Code](#get-invite-code)
169
+ - [Revoke Invite Code](#revoke-invite-code)
170
+ - [Join Using Invitation Code](#join-using-invitation-code)
171
+ - [Get Group Info by Invite Code](#get-group-info-by-invite-code)
172
+ - [Query Metadata (participants, name, description...)](#query-metadata-participants-name-description)
173
+ - [Join using groupInviteMessage](#join-using-groupinvitemessage)
174
+ - [Get Request Join List](#get-request-join-list)
175
+ - [Approve/Reject Request Join](#approvereject-request-join)
176
+ - [Get All Participating Groups Metadata](#get-all-participating-groups-metadata)
177
+ - [Toggle Ephemeral](#toggle-ephemeral)
178
+ - [Change Add Mode](#change-add-mode)
179
+ - [Privacy](#privacy)
180
+ - [Block/Unblock User](#blockunblock-user)
181
+ - [Get Privacy Settings](#get-privacy-settings)
182
+ - [Get BlockList](#get-blocklist)
183
+ - [Update LastSeen Privacy](#update-lastseen-privacy)
184
+ - [Update Online Privacy](#update-online-privacy)
185
+ - [Update Profile Picture Privacy](#update-profile-picture-privacy)
186
+ - [Update Status Privacy](#update-status-privacy)
187
+ - [Update Read Receipts Privacy](#update-read-receipts-privacy)
188
+ - [Update Groups Add Privacy](#update-groups-add-privacy)
189
+ - [Update Default Disappearing Mode](#update-default-disappearing-mode)
190
+ - [Broadcast Lists & Stories](#broadcast-lists--stories)
191
+ - [Send Broadcast & Stories](#send-broadcast--stories)
192
+ - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
193
+ - [Writing Custom Functionality](#writing-custom-functionality)
194
+ - [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
195
+ - [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
196
+ - [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
197
+
198
+ ## Connecting Account
199
+
200
+ WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a **QR code** or **Pairing Code** with WhatsApp on your phone.
201
+
202
+ > [!NOTE]
203
+ > **[Here](#example-to-start) is a simple example of event handling**
204
+
205
+ > [!TIP]
206
+ > **You can see all supported socket configs in the [SocketConfig type alias](https://baileys.wiki/docs/api/type-aliases/SocketConfig/) (Recommended)**
207
+
208
+ # @vsxid/alya-baileys
209
+
210
+ Modified WhatsApp Web API library based on Baileys with built-in `<biz>` node injection, `@lid` JID resolver, custom 8-digit pairing code, interactive buttons, carousel, AI rich response, code snippet sender, newsletter, community, and VoIP WebRTC support.
211
+
212
+ Library WhatsApp Web API modifikasi berbasis Baileys dengan injeksi node `<biz>`, resolver JID `@lid`, custom pairing code 8 digit, tombol interaktif, carousel, AI rich response, kirim snippet kode, saluran, komunitas, dan dukungan VoIP WebRTC.
213
+
214
+ ---
215
+
216
+ ## Installation / Instalasi
217
+
218
+ ```bash
219
+ npm install @vsxid/alya-baileys
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Basic Connection & Custom Pairing / Koneksi Dasar & Custom Pairing
225
+
226
+ ```javascript
227
+ import makeWASocket, {
228
+ useMultiFileAuthState,
229
+ DisconnectReason,
230
+ requestFixedPairing
231
+ } from '@vsxid/alya-baileys';
232
+
233
+ async function startBot() {
234
+ const { state, saveCreds } = await useMultiFileAuthState('./session'); // session folder / folder sesi
235
+
236
+ const sock = makeWASocket({
237
+ auth: state,
238
+ printQRInTerminal: false, // false for pairing code / false untuk pairing code
239
+ browser: ['Ubuntu', 'Chrome', '20.0.04'] // OS: Ubuntu, Windows, macOS | Browser: Chrome, Edge, Firefox, Safari
240
+ });
241
+
242
+ if (!sock.authState.creds.registered) {
243
+ const code = await requestFixedPairing(sock, '628123456789', {
244
+ customCode: 'ALYABOT1', // exact 8 chars A-Z 0-9 / wajib 8 karakter huruf/angka
245
+ maxRetries: 3 // retry attempts / jumlah percobaan ulang
246
+ });
247
+ console.log('Pairing Code:', code);
248
+ }
249
+
250
+ sock.ev.on('creds.update', saveCreds);
251
+
252
+ sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
253
+ if (connection === 'close') {
254
+ const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut;
255
+ if (shouldReconnect) startBot();
256
+ } else if (connection === 'open') {
257
+ console.log('Connected / Terhubung!');
258
+ }
259
+ });
260
+ }
261
+
262
+ startBot();
263
+ ```
264
+
265
+ ---
266
+
267
+ ## Interactive Buttons & Thumbnail (`<biz>` Fix) / Tombol Interaktif & Thumbnail
268
+
269
+ ```javascript
270
+ import { sendBizMessage, sendButtonsSheet } from '@vsxid/alya-baileys';
271
+
272
+ await sendBizMessage(sock, jid, {
273
+ title: 'MAIN MENU',
274
+ text: 'Select an option below / Pilih menu di bawah:',
275
+ footer: '© Alya-Baileys',
276
+ buttons: [
277
+ { type: 'quick_reply', text: 'Ping', id: '.ping' }, // types: quick_reply, cta_url, cta_copy
278
+ { type: 'cta_url', text: 'GitHub', url: 'https://github.com' },
279
+ { type: 'cta_copy', text: 'Copy Token', copy: 'ALYA-2026' }
280
+ ],
281
+ contextInfo: {
282
+ externalAdReply: {
283
+ title: 'Alya Bot',
284
+ body: 'Fast & Lightweight',
285
+ mediaType: 1, // 1: image, 2: video
286
+ renderLargerThumbnail: true, // true: big banner, false: small square
287
+ thumbnailUrl: 'https://example.com',
288
+ sourceUrl: 'https://example.com'
289
+ }
290
+ }
291
+ });
292
+
293
+ await sendButtonsSheet(sock, jid, {
294
+ title: 'BOT FEATURES',
295
+ text: 'Open list / Buka daftar fitur',
296
+ buttonTitle: 'Select Menu', // bottom sheet button label / teks tombol list
297
+ sections: [
298
+ {
299
+ title: 'General',
300
+ rows: [
301
+ { title: 'Speed Test', description: 'Check latency', id: '.ping' },
302
+ { title: 'Owner Info', description: 'Contact dev', id: '.owner' }
303
+ ]
304
+ }
305
+ ]
306
+ });
307
+ ```
308
+
309
+ ---
310
+
311
+ ## Carousel, Offer, Location & URL / Carousel, Promo, Lokasi & URL
312
+
313
+ ```javascript
314
+ import {
315
+ sendCarousel,
316
+ sendLimitedOffer,
317
+ sendCustomLocation,
318
+ sendUrlPreview
319
+ } from '@vsxid/alya-baileys';
320
+
321
+ await sendCarousel(sock, jid, {
322
+ text: 'Featured Items / Produk Pilihan',
323
+ footer: 'Swipe left or right / Geser kanan atau kiri',
324
+ cards: [
325
+ {
326
+ title: 'Item 1',
327
+ subtitle: 'Promo',
328
+ body: 'Description 1',
329
+ image: 'https://example.com', // URL or Buffer / URL atau Buffer gambar
330
+ buttons: [{ type: 'quick_reply', text: 'Buy / Beli', id: '.buy1' }]
331
+ }
332
+ ]
333
+ });
334
+
335
+ await sendLimitedOffer(sock, jid, {
336
+ text: 'Claim your discount / Klaim diskon sekarang',
337
+ offerTitle: '50% OFF', // promo badge text / teks label promo
338
+ couponCode: 'ALYA50',
339
+ expirationTime: Date.now() + 86400000, // 24h in ms / durasi kadaluarsa ms
340
+ url: 'https://example.com',
341
+ buttonText: 'Claim / Klaim'
342
+ });
343
+
344
+ await sendCustomLocation(sock, jid, {
345
+ latitude: -7.2575,
346
+ longitude: 112.7521,
347
+ name: 'Surabaya, East Java',
348
+ address: 'Indonesia',
349
+ isLive: false // true: live location, false: static pin
350
+ });
351
+
352
+ await sendUrlPreview(sock, jid, {
353
+ text: 'Check this link / Cek tautan ini: https://example.com',
354
+ title: 'Example Title',
355
+ body: 'Short description',
356
+ thumbnailUrl: 'https://example.com',
357
+ sourceUrl: 'https://example.com',
358
+ largeThumbnail: true // true: large, false: small
359
+ });
360
+ ```
361
+
362
+ ---
363
+
364
+ ## AI Rich Response & Code Snippets / Pesan AI & Kirim Kode
365
+
366
+ ```javascript
367
+ import { sendAiRichMessage, sendCodeSnippet } from '@vsxid/alya-baileys';
368
+
369
+ await sendAiRichMessage(sock, jid, {
370
+ title: '✨ Alya AI',
371
+ text: 'Here is the function / Ini fungsinya:',
372
+ codeLanguage: 'javascript', // javascript, python, html, php, css, bash, json, cpp, java, sql
373
+ codeBlock: 'const greet = (name) => `Hello ${name}`;',
374
+ sources: ['https://nodejs.org']
375
+ });
376
+
377
+ await sendCodeSnippet(sock, jid, {
378
+ language: 'python', // html, js, py, php, css, json, sh, cpp, java, sql
379
+ caption: 'Python Script:',
380
+ code: 'print("Hello from Alya-Baileys!")',
381
+ sendAsFile: false, // true: send as .py/.html/.js document, false: chat + copy button
382
+ fileName: 'script.py'
383
+ });
384
+ ```
385
+
386
+ ---
387
+
388
+ ## Group (`@g.us`), `@lid` Resolver, Community & Newsletter / Grup, `@lid`, Komunitas & Saluran
389
+
390
+ ```javascript
391
+ import {
392
+ resolveJid,
393
+ isGroupAdmin,
394
+ sendHidetag,
395
+ sendTagall,
396
+ getCommunityInfo,
397
+ sendNewsletter,
398
+ reactNewsletter
399
+ } from '@vsxid/alya-baileys';
400
+
401
+ const realJid = resolveJid(senderLid, groupMetadata.participants); // @lid -> @s.whatsapp.net
402
+ const adminStatus = isGroupAdmin(senderLid, groupMetadata.participants); // true / false
403
+
404
+ await sendHidetag(sock, groupJid, 'Announcement / Pengumuman penting!', quotedMsg);
405
+ await sendTagall(sock, groupJid, '📢 *MENTION ALL*', quotedMsg);
406
+
407
+ const commInfo = await getCommunityInfo(sock, groupJid); // check parent/sub-group / cek info komunitas
408
+ await sendNewsletter(sock, '120363xxxx@newsletter', { text: 'Channel update!' });
409
+ await reactNewsletter(sock, '120363xxxx@newsletter', '102', '🔥'); // serverId, emoji
410
+ ```
411
+
412
+ ---
413
+
414
+ ## Auto-Reply, Presence, Poll, Broadcast & Store / Auto-Reply, Status, Polling, Broadcast & Store
415
+
416
+ ```javascript
417
+ import {
418
+ setupAutoReply,
419
+ setupAutoPresence,
420
+ sendPoll,
421
+ sendBroadcast,
422
+ createJsonStore,
423
+ enableAntiCall
424
+ } from '@vsxid/alya-baileys';
425
+
426
+ setupAutoReply(sock, [
427
+ { trigger: 'ping', exact: true, reply: 'Pong! 🚀' }, // exact: true (persis), false (mengandung kata)
428
+ { trigger: /^hi|halo/i, reply: 'Hello! / Halo!' } // support RegEx, string, or function
429
+ ], { onlyGroup: false, onlyPrivate: false, quoteMessage: true });
430
+
431
+ setupAutoPresence(sock, {
432
+ autoRead: true, // true: blue tick / centang biru otomatis
433
+ autoTyping: true, // true: typing / mengetik (false jika pakai autoRecording)
434
+ autoRecording: false, // true: recording audio / merekam suara
435
+ durationMs: 1500
436
+ });
437
+
438
+ enableAntiCall(sock, {
439
+ rejectMessage: 'No calls allowed / Bot tidak menerima telepon.',
440
+ blockCaller: false // true: auto block caller / blokir penelpon
441
+ });
442
+
443
+ await sendPoll(sock, jid, {
444
+ name: 'Vote:',
445
+ values: ['Option A', 'Option B'], // min 2, max 12 options
446
+ selectableCount: 1 // 1: single choice, >1: multiple choice
447
+ });
448
+
449
+ await sendBroadcast(sock, ['628111@s.whatsapp.net', '628222@s.whatsapp.net'], {
450
+ text: 'Info!'
451
+ }, { delayMs: 2000 }); // delay in ms to prevent ban / jeda aman anti-banned
452
+
453
+ const store = createJsonStore('./alya_store', 50); // folder path, max chat per JID
454
+ store.bind(sock.ev);
455
+ // store.clearTrash(); // delete all stored chats / hapus semua sampah chat
456
+ ```
457
+
458
+ ---
459
+
460
+ ## VoIP WebRTC Audio & Call Link / Panggilan Suara WebRTC & Call Link
461
+
462
+ ```javascript
463
+ import { createCallLink, sendVoipCall, streamAudioToCall, onVoipEvent } from '@vsxid/alya-baileys';
464
+
465
+ const link = await createCallLink(sock, false); // false: audio call, true: video call
466
+
467
+ const call = await sendVoipCall(sock, '628123456789@s.whatsapp.net', { isVideo: false });
468
+ streamAudioToCall(call.session, './audio.mp3'); // supports mp3, wav, ogg (requires ffmpeg)
469
+
470
+ onVoipEvent(sock, (event) => {
471
+ console.log(`Call from ${event.from} | Status: ${event.status}`); // status: offer, ringing, accept, reject, terminate
472
+ });
473
+ ```
474
+ #### Anti-Delete Message / Anti Hapus Pesan
475
+
476
+ ```javascript
477
+ import { enableAntiDelete } from '@vsxid/alya-baileys';
478
+
479
+ // Catch deleted/revoked messages / Tangkap pesan yang ditarik user
480
+ enableAntiDelete(sock, {
481
+ forwardTo: null, // null: origin chat, or '628xxx@s.whatsapp.net' / null: chat asal
482
+ customHeader: '🚨 *ANTI-DELETE DETECTED*'
483
+ });
484
+ ```
485
+
486
+ #### Auto View & React Story / Auto Lihat & React Status
487
+
488
+ ```javascript
489
+ import { enableAutoStory } from '@vsxid/alya-baileys';
490
+
491
+ // Auto view & react WhatsApp status / Auto nonton & react story WA
492
+ enableAutoStory(sock, {
493
+ autoRead: true, // true: view story, false: skip / lihat status
494
+ autoReact: true, // true: send emoji reaction / kirim reaksi emoji
495
+ emojis: ['🔥', '❤️', '👍', '😂'], // random emoji list / daftar emoji acak
496
+ ignoreJids: ['628111@s.whatsapp.net'] // excluded contacts / nomor yang dilewati
497
+ });
498
+ ```
499
+
500
+ #### Custom Fake Quoted Presets / Preset Fake Quoted Custom
501
+
502
+ ```javascript
503
+ import { fakeQuoted } from '@vsxid/alya-baileys';
504
+
505
+ const qVerified = fakeQuoted.verified('Official Bot', '0@s.whatsapp.net');
506
+ const qChannel = fakeQuoted.newsletter('Alya Channel', '120363xxxx@newsletter');
507
+ const qOrder = fakeQuoted.order('Alya Premium', 999);
508
+ const qStatus = fakeQuoted.fstatus({ name: 'ALYA-MD', thumb: thumbBuffer, id: 'ALYA-01' });
509
+ const qKontak = fakeQuoted.fkontak({ wm: 'Owner Bot', sender: m.sender, thumb: thumbBuffer });
510
+ const qVn = fakeQuoted.fvn({ seconds: '999999', ptt: true }); // ptt: true (voice note), false (audio)
511
+ const qText = fakeQuoted.ftextt({ wm: 'Alya-Baileys', title: 'Official', thumb: thumbBuffer });
512
+ const qGif = fakeQuoted.fgif({ wm: 'Alya Video', seconds: '999', thumb: thumbBuffer });
513
+ const qToko = fakeQuoted.ftoko({ wm: 'Alya Store', priceAmount1000: '20000000', retailerId: 'ALYA-SHOP', thumb: thumbBuffer });
514
+ const qDocs = fakeQuoted.fdocs({ wm: 'Document.pdf', thumb: thumbBuffer });
515
+ const qGc = fakeQuoted.fgclink({ groupJid: '628xxx@g.us', groupName: 'ALYA GROUP', wm: 'Join Now', thumb: thumbBuffer });
516
+
517
+ // Send message with custom fake quoted / Kirim pesan pakai fake quoted custom
518
+ await sock.sendMessage(jid, { text: 'Hello! / Halo!' }, { quoted: qToko });
519
+ ```
520
+
521
+
522
+
523
+ ### Starting socket with **QR-CODE**
524
+
525
+ > [!TIP]
526
+ > You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see the [BrowsersMap type alias](https://baileys.wiki/docs/api/type-aliases/BrowsersMap/)**
527
+
528
+ ```ts
529
+ import makeWASocket from '@vsxid/alya-baileys'
530
+
531
+ const sock = makeWASocket({
532
+ // can provide additional config here
533
+ browser: Browsers.ubuntu('My App'),
534
+ printQRInTerminal: true
535
+ })
536
+ ```
537
+
538
+ If the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in!
539
+
540
+ ### Starting socket with **Pairing Code**
541
+
542
+
543
+ > [!IMPORTANT]
544
+ > Pairing Code isn't Mobile API, it's a method to connect Whatsapp Web without QR-CODE, you can connect only with one device, see [here](https://faq.whatsapp.com/1324084875126592/?cms_platform=web)
545
+
546
+ The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
547
+
548
+ ```ts
549
+ import makeWASocket from '@vsxid/alya-baileys'
550
+
551
+ const sock = makeWASocket({
552
+ // can provide additional config here
553
+ printQRInTerminal: false //need to be false
554
+ })
555
+
556
+ if (!sock.authState.creds.registered) {
557
+ const number = 'XXXXXXXXXXX'
558
+ const code = await sock.requestPairingCode(number)
559
+ console.log(code)
560
+ }
561
+ ```
562
+
563
+ ### Receive Full History
564
+
565
+ 1. Set `syncFullHistory` as `true`
566
+ 2. Baileys, by default, use chrome browser config
567
+ - If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
568
+
569
+ ```ts
570
+ const sock = makeWASocket({
571
+ ...otherOpts,
572
+ // can use Windows, Ubuntu here too
573
+ browser: Browsers.macOS('Desktop'),
574
+ syncFullHistory: true
575
+ })
576
+ ```
577
+
578
+ ## Important Notes About Socket Config
579
+
580
+ ### Caching Group Metadata (Recommended)
581
+ - If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
582
+
583
+ ```ts
584
+ const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
585
+
586
+ const sock = makeWASocket({
587
+ cachedGroupMetadata: async (jid) => groupCache.get(jid)
588
+ })
589
+
590
+ sock.ev.on('groups.update', async ([event]) => {
591
+ const metadata = await sock.groupMetadata(event.id)
592
+ groupCache.set(event.id, metadata)
593
+ })
594
+
595
+ sock.ev.on('group-participants.update', async (event) => {
596
+ const metadata = await sock.groupMetadata(event.id)
597
+ groupCache.set(event.id, metadata)
598
+ })
599
+ ```
600
+
601
+ ### Improve Retry System & Decrypt Poll Votes
602
+ - If you want to improve sending message, retrying when error occurs and decrypt poll votes, you need to have a store and set `getMessage` config in socket like this:
603
+ ```ts
604
+ const sock = makeWASocket({
605
+ getMessage: async (key) => await getMessageFromStore(key)
606
+ })
607
+ ```
608
+
609
+ ### Receive Notifications in Whatsapp App
610
+ - If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
611
+ ```ts
612
+ const sock = makeWASocket({
613
+ markOnlineOnConnect: false
614
+ })
615
+ ```
616
+ ## Saving & Restoring Sessions
617
+
618
+ You obviously don't want to keep scanning the QR code every time you want to connect.
619
+
620
+ So, you can load the credentials to log back in:
621
+ ```ts
622
+ import makeWASocket, { useMultiFileAuthState } from '@vsxid/alya-baileys'
623
+
624
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
625
+
626
+ // will use the given state to connect
627
+ // so if valid credentials are available -- it'll connect without QR
628
+ const sock = makeWASocket({ auth: state })
629
+
630
+ // this will be called as soon as the credentials are updated
631
+ sock.ev.on('creds.update', saveCreds)
632
+ ```
633
+
634
+ > [!IMPORTANT]
635
+ > `useMultiFileAuthState` is a utility function to help save the auth state in a single folder, this function serves as a good guide to help write auth & key states for SQL/no-SQL databases, which I would recommend in any production grade system.
636
+
637
+ > [!NOTE]
638
+ > When a message is received/sent, due to signal sessions needing updating, the auth keys (`authState.keys`) will update. Whenever that happens, you must save the updated keys (`authState.keys.set()` is called). Not doing so will prevent your messages from reaching the recipient & cause other unexpected consequences. The `useMultiFileAuthState` function automatically takes care of that, but for any other serious implementation -- you will need to be very careful with the key state management.
639
+
640
+ ## Handling Events
641
+
642
+ - Baileys uses the EventEmitter syntax for events.
643
+ They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
644
+
645
+ > [!IMPORTANT]
646
+ > **The events are in the [BaileysEventMap type alias](https://baileys.wiki/docs/api/type-aliases/BaileysEventMap/)**, it's important you see all events
647
+
648
+ You can listen to these events like this:
649
+ ```ts
650
+ const sock = makeWASocket()
651
+ sock.ev.on('messages.upsert', ({ messages }) => {
652
+ console.log('got messages', messages)
653
+ })
654
+ ```
655
+
656
+ ### Example to Start
657
+
658
+ > [!NOTE]
659
+ > This example includes basic auth storage too
660
+
661
+ > [!NOTE]
662
+ > For reliable serialization of the authentication state, especially when storing as JSON, always use the BufferJSON utility.
663
+
664
+ ```ts
665
+ import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@vsxid/alya-baileys'
666
+ import { Boom } from '@hapi/boom'
667
+
668
+ async function connectToWhatsApp () {
669
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
670
+ const sock = makeWASocket({
671
+ // can provide additional config here
672
+ auth: state,
673
+ printQRInTerminal: true
674
+ })
675
+ sock.ev.on('connection.update', (update) => {
676
+ const { connection, lastDisconnect } = update
677
+ if(connection === 'close') {
678
+ const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
679
+ console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
680
+ // reconnect if not logged out
681
+ if(shouldReconnect) {
682
+ connectToWhatsApp()
683
+ }
684
+ } else if(connection === 'open') {
685
+ console.log('opened connection')
686
+ }
687
+ })
688
+ sock.ev.on('messages.upsert', event => {
689
+ for (const m of event.messages) {
690
+ console.log(JSON.stringify(m, undefined, 2))
691
+
692
+ console.log('replying to', m.key.remoteJid)
693
+ await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
694
+ }
695
+ })
696
+
697
+ // to storage creds (session info) when it updates
698
+ sock.ev.on('creds.update', saveCreds)
699
+ }
700
+ // run in main file
701
+ connectToWhatsApp()
702
+ ```
703
+
704
+ > [!IMPORTANT]
705
+ > In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
706
+
707
+ ### Decrypt Poll Votes
708
+
709
+ - By default poll votes are encrypted and handled in `messages.update`
710
+ - That's a simple example
711
+ ```ts
712
+ sock.ev.on('messages.update', event => {
713
+ for(const { key, update } of event) {
714
+ if(update.pollUpdates) {
715
+ const pollCreation = await getMessage(key)
716
+ if(pollCreation) {
717
+ console.log(
718
+ 'got poll update, aggregation: ',
719
+ getAggregateVotesInPollMessage({
720
+ message: pollCreation,
721
+ pollUpdates: update.pollUpdates,
722
+ })
723
+ )
724
+ }
725
+ }
726
+ }
727
+ })
728
+ ```
729
+
730
+ - `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
731
+
732
+ ### Summary of Events on First Connection
733
+
734
+ 1. When you connect first time, `connection.update` will be fired requesting you to restart sock
735
+ 2. Then, history messages will be received in `messaging.history-set`
736
+
737
+ ## Implementing a Data Store
738
+
739
+ - Baileys does not come with a defacto storage for chats, contacts, or messages. However, a simple in-memory implementation has been provided. The store listens for chat updates, new messages, message updates, etc., to always have an up-to-date version of the data.
740
+
741
+ > [!IMPORTANT]
742
+ > I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
743
+
744
+ It can be used as follows:
745
+
746
+ ```ts
747
+ import makeWASocket, { makeInMemoryStore } from '@vsxid/alya-baileys'
748
+ // the store maintains the data of the WA connection in memory
749
+ // can be written out to a file & read from it
750
+ const store = makeInMemoryStore({ })
751
+ // can be read from a file
752
+ store.readFromFile('./baileys_store.json')
753
+ // saves the state to a file every 10s
754
+ setInterval(() => {
755
+ store.writeToFile('./baileys_store.json')
756
+ }, 10_000)
757
+
758
+ const sock = makeWASocket({ })
759
+ // will listen from this socket
760
+ // the store can listen from a new socket once the current socket outlives its lifetime
761
+ store.bind(sock.ev)
762
+
763
+ sock.ev.on('chats.upsert', () => {
764
+ // can use 'store.chats' however you want, even after the socket dies out
765
+ // 'chats' => a KeyedDB instance
766
+ console.log('got chats', store.chats.all())
767
+ })
768
+
769
+ sock.ev.on('contacts.upsert', () => {
770
+ console.log('got contacts', Object.values(store.contacts))
771
+ })
772
+
773
+ ```
774
+
775
+ The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
776
+
777
+ ## Whatsapp IDs Explain
778
+
779
+ - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
780
+ - It must be in the format ```[country code][phone number]@s.whatsapp.net```
781
+ - Example for people: ```+19999999999@s.whatsapp.net```.
782
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
783
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
784
+ - For stories, the ID is `status@broadcast`.
785
+
786
+ ## Utility Functions
787
+
788
+ - `getContentType`, returns the content type for any message
789
+ - `getDevice`, returns the device from message
790
+ - `makeCacheableSignalKeyStore`, make auth store more fast
791
+ - `downloadContentFromMessage`, download content from any message
792
+
793
+ ## Sending Messages
794
+
795
+ - Send all types of messages with a single function
796
+ - **In the [AnyMessageContent type alias](https://baileys.wiki/docs/api/type-aliases/AnyMessageContent/) you can see all message contents supported, like text message**
797
+ - **In the [MiscMessageGenerationOptions type alias](https://baileys.wiki/docs/api/type-aliases/MiscMessageGenerationOptions/) you can see all options supported, like quote message**
798
+
799
+ ```ts
800
+ const jid: string
801
+ const content: AnyMessageContent
802
+ const options: MiscMessageGenerationOptions
803
+
804
+ sock.sendMessage(jid, content, options)
805
+ ```
806
+
807
+ ### Non-Media Messages
808
+
809
+ #### Text Message
810
+ ```ts
811
+ await sock.sendMessage(jid, { text: 'hello word' })
812
+ ```
813
+
814
+ #### Quote Message (works with all types)
815
+ ```ts
816
+ await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
817
+ ```
818
+
819
+ #### Mention User (works with most types)
820
+ - @number is to mention in text, it's optional
821
+ ```ts
822
+ await sock.sendMessage(
823
+ jid,
824
+ {
825
+ text: '@12345678901',
826
+ mentions: ['12345678901@s.whatsapp.net']
827
+ }
828
+ )
829
+ ```
830
+
831
+ #### Forward Messages
832
+ - You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.wiki/docs/api/type-aliases/WAMessage/) object
833
+ ```ts
834
+ const msg = getMessageFromStore() // implement this on your end
835
+ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
836
+ ```
837
+
838
+ #### Location Message
839
+ ```ts
840
+ await sock.sendMessage(
841
+ jid,
842
+ {
843
+ location: {
844
+ degreesLatitude: 24.121231,
845
+ degreesLongitude: 55.1121221
846
+ }
847
+ }
848
+ )
849
+ ```
850
+ #### Contact Message
851
+ ```ts
852
+ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
853
+ + 'VERSION:3.0\n'
854
+ + 'FN:Jeff Singh\n' // full name
855
+ + 'ORG:Ashoka Uni;\n' // the organization of the contact
856
+ + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
857
+ + 'END:VCARD'
858
+
859
+ await sock.sendMessage(
860
+ id,
861
+ {
862
+ contacts: {
863
+ displayName: 'Jeff',
864
+ contacts: [{ vcard }]
865
+ }
866
+ }
867
+ )
868
+ ```
869
+
870
+ #### Reaction Message
871
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.wiki/docs/api/type-aliases/WAMessageKey/) object
872
+ ```ts
873
+ await sock.sendMessage(
874
+ jid,
875
+ {
876
+ react: {
877
+ text: '💖', // use an empty string to remove the reaction
878
+ key: message.key
879
+ }
880
+ }
881
+ )
882
+ ```
883
+
884
+ #### Pin Message
885
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.wiki/docs/api/type-aliases/WAMessageKey/) object
886
+
887
+ - Time can be:
888
+
889
+ | Time | Seconds |
890
+ |-------|----------------|
891
+ | 24h | 86.400 |
892
+ | 7d | 604.800 |
893
+ | 30d | 2.592.000 |
894
+
895
+ ```ts
896
+ await sock.sendMessage(
897
+ jid,
898
+ {
899
+ pin: {
900
+ type: 1, // 0 to remove
901
+ time: 86400
902
+ key: message.key
903
+ }
904
+ }
905
+ )
906
+ ```
907
+
908
+ #### Poll Message
909
+ ```ts
910
+ await sock.sendMessage(
911
+ jid,
912
+ {
913
+ poll: {
914
+ name: 'My Poll',
915
+ values: ['Option 1', 'Option 2', ...],
916
+ selectableCount: 1,
917
+ toAnnouncementGroup: false // or true
918
+ }
919
+ }
920
+ )
921
+ ```
922
+
923
+ ### Sending Messages with Link Previews
924
+
925
+ 1. By default, wa does not have link generation when sent from the web
926
+ 2. Baileys has a function to generate the content for these link previews
927
+ 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
928
+ 4. Send a link:
929
+ ```ts
930
+ await sock.sendMessage(
931
+ jid,
932
+ {
933
+ text: 'Hi, this was sent using https://github.com/vsxid/alya-baileys'
934
+ }
935
+ )
936
+ ```
937
+
938
+ ### Media Messages
939
+
940
+ Sending media (video, stickers, images) is easier & more efficient than ever.
941
+
942
+ > [!NOTE]
943
+ > In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more in the [WAMediaUpload type alias](https://baileys.wiki/docs/api/type-aliases/WAMediaUpload/)
944
+
945
+ - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
946
+
947
+ > [!TIP]
948
+ > It's recommended to use Stream or Url to save memory
949
+
950
+ #### Gif Message
951
+ - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
952
+ ```ts
953
+ await sock.sendMessage(
954
+ jid,
955
+ {
956
+ video: fs.readFileSync('Media/ma_gif.mp4'),
957
+ caption: 'hello word',
958
+ gifPlayback: true
959
+ }
960
+ )
961
+ ```
962
+
963
+ #### Video Message
964
+ ```ts
965
+ await sock.sendMessage(
966
+ id,
967
+ {
968
+ video: {
969
+ url: './Media/ma_gif.mp4'
970
+ },
971
+ caption: 'hello word',
972
+ ptv: false // if set to true, will send as a `video note`
973
+ }
974
+ )
975
+ ```
976
+
977
+ #### Audio Message
978
+ - To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
979
+ ```bash
980
+ codec: libopus //ogg file
981
+ ac: 1 //one channel
982
+ avoid_negative_ts
983
+ make_zero
984
+ ```
985
+ - Example:
986
+ ```bash
987
+ ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
988
+ ```
989
+ ```ts
990
+ await sock.sendMessage(
991
+ jid,
992
+ {
993
+ audio: {
994
+ url: './Media/audio.mp3'
995
+ },
996
+ mimetype: 'audio/mp4'
997
+ }
998
+ )
999
+ ```
1000
+
1001
+ #### Image Message
1002
+ ```ts
1003
+ await sock.sendMessage(
1004
+ id,
1005
+ {
1006
+ image: {
1007
+ url: './Media/ma_img.png'
1008
+ },
1009
+ caption: 'hello word'
1010
+ }
1011
+ )
1012
+ ```
1013
+
1014
+ #### View Once Message
1015
+
1016
+ - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
1017
+
1018
+ ```ts
1019
+ await sock.sendMessage(
1020
+ id,
1021
+ {
1022
+ image: {
1023
+ url: './Media/ma_img.png'
1024
+ },
1025
+ viewOnce: true, //works with video, audio too
1026
+ caption: 'hello word'
1027
+ }
1028
+ )
1029
+ ```
1030
+
1031
+ ## Modify Messages
1032
+
1033
+ ### Deleting Messages (for everyone)
1034
+
1035
+ ```ts
1036
+ const msg = await sock.sendMessage(jid, { text: 'hello word' })
1037
+ await sock.sendMessage(jid, { delete: msg.key })
1038
+ ```
1039
+
1040
+ **Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
1041
+
1042
+ ### Editing Messages
1043
+
1044
+ - You can pass all editable contents here
1045
+ ```ts
1046
+ await sock.sendMessage(jid, {
1047
+ text: 'updated text goes here',
1048
+ edit: response.key,
1049
+ });
1050
+ ```
1051
+
1052
+ ## Manipulating Media Messages
1053
+
1054
+ ### Thumbnail in Media Messages
1055
+ - For media messages, the thumbnail can be generated automatically for images & stickers provided you add `jimp` or `sharp` as a dependency in your project using `yarn add jimp` or `yarn add sharp`.
1056
+ - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
1057
+
1058
+ ### Downloading Media Messages
1059
+
1060
+ If you want to save the media you received
1061
+ ```ts
1062
+ import { createWriteStream } from 'fs'
1063
+ import { downloadMediaMessage, getContentType } from '@vsxid/alya-baileys'
1064
+
1065
+ sock.ev.on('messages.upsert', async ({ [m] }) => {
1066
+ if (!m.message) return // if there is no text or media message
1067
+ const messageType = getContentType(m) // get what type of message it is (text, image, video...)
1068
+
1069
+ // if the message is an image
1070
+ if (messageType === 'imageMessage') {
1071
+ // download the message
1072
+ const stream = await downloadMediaMessage(
1073
+ m,
1074
+ 'stream', // can be 'buffer' too
1075
+ { },
1076
+ {
1077
+ logger,
1078
+ // pass this so that baileys can request a reupload of media
1079
+ // that has been deleted
1080
+ reuploadRequest: sock.updateMediaMessage
1081
+ }
1082
+ )
1083
+ // save to file
1084
+ const writeStream = createWriteStream('./my-download.jpeg')
1085
+ stream.pipe(writeStream)
1086
+ }
1087
+ }
1088
+ ```
1089
+
1090
+ ### Re-upload Media Message to Whatsapp
1091
+
1092
+ - WhatsApp automatically removes old media from their servers. For the device to access said media -- a re-upload is required by another device that has it. This can be accomplished using:
1093
+ ```ts
1094
+ await sock.updateMediaMessage(msg)
1095
+ ```
1096
+
1097
+ ## Reject Call
1098
+
1099
+ - You can obtain `callId` and `callFrom` from `call` event
1100
+
1101
+ ```ts
1102
+ await sock.rejectCall(callId, callFrom)
1103
+ ```
1104
+
1105
+ ## Send States in Chat
1106
+
1107
+ ### Reading Messages
1108
+ - A set of message [keys](https://baileys.wiki/docs/api/type-aliases/WAMessageKey/) must be explicitly marked read now.
1109
+ - You cannot mark an entire 'chat' read as it were with Baileys Web.
1110
+ This means you have to keep track of unread messages.
1111
+
1112
+ ```ts
1113
+ const key: WAMessageKey
1114
+ // can pass multiple keys to read multiple messages as well
1115
+ await sock.readMessages([key])
1116
+ ```
1117
+
1118
+ The message ID is the unique identifier of the message that you are marking as read.
1119
+ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
1120
+
1121
+ ### Update Presence
1122
+
1123
+ - ``` presence ``` can be one of the values in the [WAPresence type alias](https://baileys.wiki/docs/api/type-aliases/WAPresence/)
1124
+ - The presence expires after about 10 seconds.
1125
+ - This lets the person/group with `jid` know whether you're online, offline, typing etc.
1126
+
1127
+ ```ts
1128
+ await sock.sendPresenceUpdate('available', jid)
1129
+ ```
1130
+
1131
+ > [!NOTE]
1132
+ > If a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `sock.sendPresenceUpdate('unavailable')`
1133
+
1134
+ ## Modifying Chats
1135
+
1136
+ WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
1137
+
1138
+ > [!IMPORTANT]
1139
+ > If you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again.
1140
+
1141
+ ### Archive a Chat
1142
+ ```ts
1143
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1144
+ await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
1145
+ ```
1146
+ ### Mute/Unmute a Chat
1147
+
1148
+ - Supported times:
1149
+
1150
+ | Time | Miliseconds |
1151
+ |-------|-----------------|
1152
+ | Remove | null |
1153
+ | 8h | 86.400.000 |
1154
+ | 7d | 604.800.000 |
1155
+
1156
+ ```ts
1157
+ // mute for 8 hours
1158
+ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
1159
+ // unmute
1160
+ await sock.chatModify({ mute: null }, jid)
1161
+ ```
1162
+ ### Mark a Chat Read/Unread
1163
+ ```ts
1164
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1165
+ // mark it unread
1166
+ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
1167
+ ```
1168
+
1169
+ ### Delete a Message for Me
1170
+ ```ts
1171
+ await sock.chatModify(
1172
+ {
1173
+ clear: {
1174
+ messages: [
1175
+ {
1176
+ id: 'ATWYHDNNWU81732J',
1177
+ fromMe: true,
1178
+ timestamp: '1654823909'
1179
+ }
1180
+ ]
1181
+ }
1182
+ },
1183
+ jid
1184
+ )
1185
+
1186
+ ```
1187
+ ### Delete a Chat
1188
+ ```ts
1189
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1190
+ await sock.chatModify({
1191
+ delete: true,
1192
+ lastMessages: [
1193
+ {
1194
+ key: lastMsgInChat.key,
1195
+ messageTimestamp: lastMsgInChat.messageTimestamp
1196
+ }
1197
+ ]
1198
+ },
1199
+ jid
1200
+ )
1201
+ ```
1202
+ ### Pin/Unpin a Chat
1203
+ ```ts
1204
+ await sock.chatModify({
1205
+ pin: true // or `false` to unpin
1206
+ },
1207
+ jid
1208
+ )
1209
+ ```
1210
+ ### Star/Unstar a Message
1211
+ ```ts
1212
+ await sock.chatModify({
1213
+ star: {
1214
+ messages: [
1215
+ {
1216
+ id: 'messageID',
1217
+ fromMe: true // or `false`
1218
+ }
1219
+ ],
1220
+ star: true // - true: Star Message; false: Unstar Message
1221
+ }
1222
+ },
1223
+ jid
1224
+ )
1225
+ ```
1226
+
1227
+ ### Disappearing Messages
1228
+
1229
+ - Ephemeral can be:
1230
+
1231
+ | Time | Seconds |
1232
+ |-------|----------------|
1233
+ | Remove | 0 |
1234
+ | 24h | 86.400 |
1235
+ | 7d | 604.800 |
1236
+ | 90d | 7.776.000 |
1237
+
1238
+ - You need to pass in **Seconds**, default is 7 days
1239
+
1240
+ ```ts
1241
+ // turn on disappearing messages
1242
+ await sock.sendMessage(
1243
+ jid,
1244
+ // this is 1 week in seconds -- how long you want messages to appear for
1245
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
1246
+ )
1247
+
1248
+ // will send as a disappearing message
1249
+ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
1250
+
1251
+ // turn off disappearing messages
1252
+ await sock.sendMessage(
1253
+ jid,
1254
+ { disappearingMessagesInChat: false }
1255
+ )
1256
+ ```
1257
+
1258
+ ## User Querys
1259
+
1260
+ ### Check If ID Exists in Whatsapp
1261
+ ```ts
1262
+ const [result] = await sock.onWhatsApp(jid)
1263
+ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
1264
+ ```
1265
+
1266
+ ### Query Chat History (groups too)
1267
+
1268
+ - You need to have oldest message in chat
1269
+ ```ts
1270
+ const msg = await getOldestMessageInChat(jid) // implement this on your end
1271
+ await sock.fetchMessageHistory(
1272
+ 50, //quantity (max: 50 per query)
1273
+ msg.key,
1274
+ msg.messageTimestamp
1275
+ )
1276
+ ```
1277
+ - Messages will be received in `messaging.history-set` event
1278
+
1279
+ ### Fetch Status
1280
+ ```ts
1281
+ const status = await sock.fetchStatus(jid)
1282
+ console.log('status: ' + status)
1283
+ ```
1284
+
1285
+ ### Fetch Profile Picture (groups too)
1286
+ - To get the display picture of some person/group
1287
+ ```ts
1288
+ // for low res picture
1289
+ const ppUrl = await sock.profilePictureUrl(jid)
1290
+ console.log(ppUrl)
1291
+
1292
+ // for high res picture
1293
+ const ppUrl = await sock.profilePictureUrl(jid, 'image')
1294
+ ```
1295
+
1296
+ ### Fetch Bussines Profile (such as description or category)
1297
+ ```ts
1298
+ const profile = await sock.getBusinessProfile(jid)
1299
+ console.log('business description: ' + profile.description + ', category: ' + profile.category)
1300
+ ```
1301
+
1302
+ ### Fetch Someone's Presence (if they're typing or online)
1303
+ ```ts
1304
+ // the presence update is fetched and called here
1305
+ sock.ev.on('presence.update', console.log)
1306
+
1307
+ // request updates for a chat
1308
+ await sock.presenceSubscribe(jid)
1309
+ ```
1310
+
1311
+ ## Change Profile
1312
+
1313
+ ### Change Profile Status
1314
+ ```ts
1315
+ await sock.updateProfileStatus('Hello World!')
1316
+ ```
1317
+ ### Change Profile Name
1318
+ ```ts
1319
+ await sock.updateProfileName('My name')
1320
+ ```
1321
+ ### Change Display Picture (groups too)
1322
+ - To change your display picture or a group's
1323
+
1324
+ > [!NOTE]
1325
+ > Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more in the [WAMediaUpload type alias](https://baileys.wiki/docs/api/type-aliases/WAMediaUpload/)
1326
+
1327
+ ```ts
1328
+ await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
1329
+ ```
1330
+ ### Remove display picture (groups too)
1331
+ ```ts
1332
+ await sock.removeProfilePicture(jid)
1333
+ ```
1334
+
1335
+ ## Groups
1336
+
1337
+ - To change group properties you need to be admin
1338
+
1339
+ ### Create a Group
1340
+ ```ts
1341
+ // title & participants
1342
+ const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1343
+ console.log('created group with id: ' + group.gid)
1344
+ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1345
+ ```
1346
+ ### Add/Remove or Demote/Promote
1347
+ ```ts
1348
+ // id & people to add to the group (will throw error if it fails)
1349
+ await sock.groupParticipantsUpdate(
1350
+ jid,
1351
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1352
+ 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1353
+ )
1354
+ ```
1355
+ ### Change Subject (name)
1356
+ ```ts
1357
+ await sock.groupUpdateSubject(jid, 'New Subject!')
1358
+ ```
1359
+ ### Change Description
1360
+ ```ts
1361
+ await sock.groupUpdateDescription(jid, 'New Description!')
1362
+ ```
1363
+ ### Change Settings
1364
+ ```ts
1365
+ // only allow admins to send messages
1366
+ await sock.groupSettingUpdate(jid, 'announcement')
1367
+ // allow everyone to send messages
1368
+ await sock.groupSettingUpdate(jid, 'not_announcement')
1369
+ // allow everyone to modify the group's settings -- like display picture etc.
1370
+ await sock.groupSettingUpdate(jid, 'unlocked')
1371
+ // only allow admins to modify the group's settings
1372
+ await sock.groupSettingUpdate(jid, 'locked')
1373
+ ```
1374
+ ### Leave a Group
1375
+ ```ts
1376
+ // will throw error if it fails
1377
+ await sock.groupLeave(jid)
1378
+ ```
1379
+ ### Get Invite Code
1380
+ - To create link with code use `'https://chat.whatsapp.com/' + code`
1381
+ ```ts
1382
+ const code = await sock.groupInviteCode(jid)
1383
+ console.log('group code: ' + code)
1384
+ ```
1385
+ ### Revoke Invite Code
1386
+ ```ts
1387
+ const code = await sock.groupRevokeInvite(jid)
1388
+ console.log('New group code: ' + code)
1389
+ ```
1390
+ ### Join Using Invitation Code
1391
+ - Code can't have `https://chat.whatsapp.com/`, only code
1392
+ ```ts
1393
+ const response = await sock.groupAcceptInvite(code)
1394
+ console.log('joined to: ' + response)
1395
+ ```
1396
+ ### Get Group Info by Invite Code
1397
+ ```ts
1398
+ const response = await sock.groupGetInviteInfo(code)
1399
+ console.log('group information: ' + response)
1400
+ ```
1401
+ ### Query Metadata (participants, name, description...)
1402
+ ```ts
1403
+ const metadata = await sock.groupMetadata(jid)
1404
+ console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1405
+ ```
1406
+ ### Join using `groupInviteMessage`
1407
+ ```ts
1408
+ const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1409
+ console.log('joined to: ' + response)
1410
+ ```
1411
+ ### Get Request Join List
1412
+ ```ts
1413
+ const response = await sock.groupRequestParticipantsList(jid)
1414
+ console.log(response)
1415
+ ```
1416
+ ### Approve/Reject Request Join
1417
+ ```ts
1418
+ const response = await sock.groupRequestParticipantsUpdate(
1419
+ jid, // group id
1420
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1421
+ 'approve' // or 'reject'
1422
+ )
1423
+ console.log(response)
1424
+ ```
1425
+ ### Get All Participating Groups Metadata
1426
+ ```ts
1427
+ const response = await sock.groupFetchAllParticipating()
1428
+ console.log(response)
1429
+ ```
1430
+ ### Toggle Ephemeral
1431
+
1432
+ - Ephemeral can be:
1433
+
1434
+ | Time | Seconds |
1435
+ |-------|----------------|
1436
+ | Remove | 0 |
1437
+ | 24h | 86.400 |
1438
+ | 7d | 604.800 |
1439
+ | 90d | 7.776.000 |
1440
+
1441
+ ```ts
1442
+ await sock.groupToggleEphemeral(jid, 86400)
1443
+ ```
1444
+
1445
+ ### Change Add Mode
1446
+ ```ts
1447
+ await sock.groupMemberAddMode(
1448
+ jid,
1449
+ 'all_member_add' // or 'admin_add'
1450
+ )
1451
+ ```
1452
+
1453
+ ## Privacy
1454
+
1455
+ ### Block/Unblock User
1456
+ ```ts
1457
+ await sock.updateBlockStatus(jid, 'block') // Block user
1458
+ await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1459
+ ```
1460
+ ### Get Privacy Settings
1461
+ ```ts
1462
+ const privacySettings = await sock.fetchPrivacySettings(true)
1463
+ console.log('privacy settings: ' + privacySettings)
1464
+ ```
1465
+ ### Get BlockList
1466
+ ```ts
1467
+ const response = await sock.fetchBlocklist()
1468
+ console.log(response)
1469
+ ```
1470
+ ### Update LastSeen Privacy
1471
+ ```ts
1472
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1473
+ await sock.updateLastSeenPrivacy(value)
1474
+ ```
1475
+ ### Update Online Privacy
1476
+ ```ts
1477
+ const value = 'all' // 'match_last_seen'
1478
+ await sock.updateOnlinePrivacy(value)
1479
+ ```
1480
+ ### Update Profile Picture Privacy
1481
+ ```ts
1482
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1483
+ await sock.updateProfilePicturePrivacy(value)
1484
+ ```
1485
+ ### Update Status Privacy
1486
+ ```ts
1487
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1488
+ await sock.updateStatusPrivacy(value)
1489
+ ```
1490
+ ### Update Read Receipts Privacy
1491
+ ```ts
1492
+ const value = 'all' // 'none'
1493
+ await sock.updateReadReceiptsPrivacy(value)
1494
+ ```
1495
+ ### Update Groups Add Privacy
1496
+ ```ts
1497
+ const value = 'all' // 'contacts' | 'contact_blacklist'
1498
+ await sock.updateGroupsAddPrivacy(value)
1499
+ ```
1500
+ ### Update Default Disappearing Mode
1501
+
1502
+ - Like [this](#disappearing-messages), ephemeral can be:
1503
+
1504
+ | Time | Seconds |
1505
+ |-------|----------------|
1506
+ | Remove | 0 |
1507
+ | 24h | 86.400 |
1508
+ | 7d | 604.800 |
1509
+ | 90d | 7.776.000 |
1510
+
1511
+ ```ts
1512
+ const ephemeral = 86400
1513
+ await sock.updateDefaultDisappearingMode(ephemeral)
1514
+ ```
1515
+
1516
+ ## Broadcast Lists & Stories
1517
+
1518
+ ### Send Broadcast & Stories
1519
+ - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1520
+ ```ts
1521
+ await sock.sendMessage(
1522
+ jid,
1523
+ {
1524
+ image: {
1525
+ url: url
1526
+ },
1527
+ caption: caption
1528
+ },
1529
+ {
1530
+ backgroundColor: backgroundColor,
1531
+ font: font,
1532
+ statusJidList: statusJidList,
1533
+ broadcast: true
1534
+ }
1535
+ )
1536
+ ```
1537
+ - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see the [AnyRegularMessageContent type alias](https://baileys.wiki/docs/api/type-aliases/AnyRegularMessageContent/)
1538
+ - You can add `backgroundColor` and other options in the message options, see the [MiscMessageGenerationOptions type alias](https://baileys.wiki/docs/api/type-aliases/MiscMessageGenerationOptions/)
1539
+ - `broadcast: true` enables broadcast mode
1540
+ - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1541
+
1542
+ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1543
+ - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1544
+ - Broadcast IDs are in the format `12345678@broadcast`
1545
+ ### Query a Broadcast List's Recipients & Name
1546
+ ```ts
1547
+ const bList = await sock.getBroadcastListInfo('1234@broadcast')
1548
+ console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1549
+ ```
1550
+
1551
+ ## Writing Custom Functionality
1552
+ Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1553
+
1554
+ ### Enabling Debug Level in Baileys Logs
1555
+ First, enable the logging of unhandled messages from WhatsApp by setting:
1556
+ ```ts
1557
+ const sock = makeWASocket({
1558
+ logger: P({ level: 'debug' }),
1559
+ })
1560
+ ```
1561
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
1562
+
1563
+ ### How Whatsapp Communicate With Us
1564
+
1565
+ > [!TIP]
1566
+ > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1567
+
1568
+ - **Example:** Functionality to track the battery percentage of your phone. You enable logging and you'll see a message about your battery pop up in the console:
1569
+ ```
1570
+ {
1571
+ "level": 10,
1572
+ "fromMe": false,
1573
+ "frame": {
1574
+ "tag": "ib",
1575
+ "attrs": {
1576
+ "from": "@s.whatsapp.net"
1577
+ },
1578
+ "content": [
1579
+ {
1580
+ "tag": "edge_routing",
1581
+ "attrs": {},
1582
+ "content": [
1583
+ {
1584
+ "tag": "routing_info",
1585
+ "attrs": {},
1586
+ "content": {
1587
+ "type": "Buffer",
1588
+ "data": [8,2,8,5]
1589
+ }
1590
+ }
1591
+ ]
1592
+ }
1593
+ ]
1594
+ },
1595
+ "msg":"communication"
1596
+ }
1597
+ ```
1598
+
1599
+ The `'frame'` is what the message received is, it has three components:
1600
+ - `tag` -- what this frame is about (eg. message will have 'message')
1601
+ - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1602
+ - `content` -- the actual data (eg. a message node will have the actual message content in it)
1603
+ - read more about this format [here](/src/WABinary/readme.md)
1604
+
1605
+ ### Register a Callback for Websocket Events
1606
+
1607
+ > [!TIP]
1608
+ > Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired
1609
+
1610
+ ```ts
1611
+ // for any message with tag 'edge_routing'
1612
+ sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1613
+
1614
+ // for any message with tag 'edge_routing' and id attribute = abcd
1615
+ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1616
+
1617
+ // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
1618
+ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
1619
+ ```
1620
+
1621
+ # License
1622
+ Copyright (c) 2025 Rajeh Taher/WhiskeySockets/alya/baileys
1623
+
1624
+ Licensed under the MIT License:
1625
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1626
+ of this software and associated documentation files (the "Software"), to deal
1627
+ in the Software without restriction, including without limitation the rights
1628
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1629
+ copies of the Software, and to permit persons to whom the Software is
1630
+ furnished to do so, subject to the following conditions:
1631
+
1632
+ The above copyright notice and this permission notice shall be included in all
1633
+ copies or substantial portions of the Software.
1634
+
1635
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1636
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1637
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1638
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1639
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1640
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1641
+ SOFTWARE.
1642
+
1643
+ Thus, the maintainers of the project can't be held liable for any potential misuse of this project.