@blckrose/baileys 1.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 (385) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1312 -0
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +5479 -0
  5. package/WAProto/fix-imports.js +81 -0
  6. package/WAProto/index.d.ts +14017 -0
  7. package/WAProto/index.js +97687 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/index.d.ts +74 -0
  10. package/lib/Defaults/index.d.ts.map +1 -0
  11. package/lib/Defaults/index.js +128 -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 +403 -0
  64. package/lib/Signal/libsignal.js.map +1 -0
  65. package/lib/Signal/lid-mapping.d.ts +19 -0
  66. package/lib/Signal/lid-mapping.d.ts.map +1 -0
  67. package/lib/Signal/lid-mapping.js +271 -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 +202 -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 +111 -0
  86. package/lib/Socket/chats.d.ts.map +1 -0
  87. package/lib/Socket/chats.js +1037 -0
  88. package/lib/Socket/chats.js.map +1 -0
  89. package/lib/Socket/communities.d.ts +258 -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 +150 -0
  94. package/lib/Socket/groups.d.ts.map +1 -0
  95. package/lib/Socket/groups.js +327 -0
  96. package/lib/Socket/groups.js.map +1 -0
  97. package/lib/Socket/index.d.ts +245 -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 +187 -0
  102. package/lib/Socket/messages-recv.d.ts.map +1 -0
  103. package/lib/Socket/messages-recv.js +1476 -0
  104. package/lib/Socket/messages-recv.js.map +1 -0
  105. package/lib/Socket/messages-send.d.ts +183 -0
  106. package/lib/Socket/messages-send.d.ts.map +1 -0
  107. package/lib/Socket/messages-send.js +1043 -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 +160 -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 +55 -0
  118. package/lib/Socket/socket.d.ts.map +1 -0
  119. package/lib/Socket/socket.js +942 -0
  120. package/lib/Socket/socket.js.map +1 -0
  121. package/lib/Types/Auth.d.ts +116 -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 +123 -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 +24 -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 +237 -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 +67 -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 +305 -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/Newsletter.d.ts +135 -0
  162. package/lib/Types/Newsletter.d.ts.map +1 -0
  163. package/lib/Types/Newsletter.js +31 -0
  164. package/lib/Types/Newsletter.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 +76 -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 +133 -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 +39 -0
  178. package/lib/Types/State.d.ts.map +1 -0
  179. package/lib/Types/State.js +13 -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 +65 -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 +19 -0
  190. package/lib/Utils/auth-utils.d.ts.map +1 -0
  191. package/lib/Utils/auth-utils.js +290 -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 +28 -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 +70 -0
  202. package/lib/Utils/chat-utils.d.ts.map +1 -0
  203. package/lib/Utils/chat-utils.js +812 -0
  204. package/lib/Utils/chat-utils.js.map +1 -0
  205. package/lib/Utils/crypto.d.ts +37 -0
  206. package/lib/Utils/crypto.d.ts.map +1 -0
  207. package/lib/Utils/crypto.js +118 -0
  208. package/lib/Utils/crypto.js.map +1 -0
  209. package/lib/Utils/decode-wa-message.d.ts +48 -0
  210. package/lib/Utils/decode-wa-message.d.ts.map +1 -0
  211. package/lib/Utils/decode-wa-message.js +283 -0
  212. package/lib/Utils/decode-wa-message.js.map +1 -0
  213. package/lib/Utils/event-buffer.d.ts +34 -0
  214. package/lib/Utils/event-buffer.d.ts.map +1 -0
  215. package/lib/Utils/event-buffer.js +574 -0
  216. package/lib/Utils/event-buffer.js.map +1 -0
  217. package/lib/Utils/generics.d.ts +91 -0
  218. package/lib/Utils/generics.d.ts.map +1 -0
  219. package/lib/Utils/generics.js +384 -0
  220. package/lib/Utils/generics.js.map +1 -0
  221. package/lib/Utils/history.d.ts +22 -0
  222. package/lib/Utils/history.d.ts.map +1 -0
  223. package/lib/Utils/history.js +131 -0
  224. package/lib/Utils/history.js.map +1 -0
  225. package/lib/Utils/identity-change-handler.d.ts +37 -0
  226. package/lib/Utils/identity-change-handler.d.ts.map +1 -0
  227. package/lib/Utils/identity-change-handler.js +49 -0
  228. package/lib/Utils/identity-change-handler.js.map +1 -0
  229. package/lib/Utils/index.d.ts +20 -0
  230. package/lib/Utils/index.d.ts.map +1 -0
  231. package/lib/Utils/index.js +20 -0
  232. package/lib/Utils/index.js.map +1 -0
  233. package/lib/Utils/link-preview.d.ts +21 -0
  234. package/lib/Utils/link-preview.d.ts.map +1 -0
  235. package/lib/Utils/link-preview.js +85 -0
  236. package/lib/Utils/link-preview.js.map +1 -0
  237. package/lib/Utils/logger.d.ts +13 -0
  238. package/lib/Utils/logger.d.ts.map +1 -0
  239. package/lib/Utils/logger.js +3 -0
  240. package/lib/Utils/logger.js.map +1 -0
  241. package/lib/Utils/lt-hash.d.ts +8 -0
  242. package/lib/Utils/lt-hash.d.ts.map +1 -0
  243. package/lib/Utils/lt-hash.js +8 -0
  244. package/lib/Utils/lt-hash.js.map +1 -0
  245. package/lib/Utils/make-mutex.d.ts +9 -0
  246. package/lib/Utils/make-mutex.d.ts.map +1 -0
  247. package/lib/Utils/make-mutex.js +33 -0
  248. package/lib/Utils/make-mutex.js.map +1 -0
  249. package/lib/Utils/message-retry-manager.d.ts +110 -0
  250. package/lib/Utils/message-retry-manager.d.ts.map +1 -0
  251. package/lib/Utils/message-retry-manager.js +225 -0
  252. package/lib/Utils/message-retry-manager.js.map +1 -0
  253. package/lib/Utils/messages-media.d.ts +130 -0
  254. package/lib/Utils/messages-media.d.ts.map +1 -0
  255. package/lib/Utils/messages-media.js +774 -0
  256. package/lib/Utils/messages-media.js.map +1 -0
  257. package/lib/Utils/messages.d.ts +91 -0
  258. package/lib/Utils/messages.d.ts.map +1 -0
  259. package/lib/Utils/messages.js +870 -0
  260. package/lib/Utils/messages.js.map +1 -0
  261. package/lib/Utils/noise-handler.d.ts +20 -0
  262. package/lib/Utils/noise-handler.d.ts.map +1 -0
  263. package/lib/Utils/noise-handler.js +201 -0
  264. package/lib/Utils/noise-handler.js.map +1 -0
  265. package/lib/Utils/pre-key-manager.d.ts +28 -0
  266. package/lib/Utils/pre-key-manager.d.ts.map +1 -0
  267. package/lib/Utils/pre-key-manager.js +106 -0
  268. package/lib/Utils/pre-key-manager.js.map +1 -0
  269. package/lib/Utils/process-message.d.ts +60 -0
  270. package/lib/Utils/process-message.d.ts.map +1 -0
  271. package/lib/Utils/process-message.js +528 -0
  272. package/lib/Utils/process-message.js.map +1 -0
  273. package/lib/Utils/reporting-utils.d.ts +11 -0
  274. package/lib/Utils/reporting-utils.d.ts.map +1 -0
  275. package/lib/Utils/reporting-utils.js +258 -0
  276. package/lib/Utils/reporting-utils.js.map +1 -0
  277. package/lib/Utils/signal.d.ts +34 -0
  278. package/lib/Utils/signal.d.ts.map +1 -0
  279. package/lib/Utils/signal.js +159 -0
  280. package/lib/Utils/signal.js.map +1 -0
  281. package/lib/Utils/sync-action-utils.d.ts +19 -0
  282. package/lib/Utils/sync-action-utils.d.ts.map +1 -0
  283. package/lib/Utils/sync-action-utils.js +48 -0
  284. package/lib/Utils/sync-action-utils.js.map +1 -0
  285. package/lib/Utils/tc-token-utils.d.ts +12 -0
  286. package/lib/Utils/tc-token-utils.d.ts.map +1 -0
  287. package/lib/Utils/tc-token-utils.js +18 -0
  288. package/lib/Utils/tc-token-utils.js.map +1 -0
  289. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  290. package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
  291. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  292. package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
  293. package/lib/Utils/validate-connection.d.ts +11 -0
  294. package/lib/Utils/validate-connection.d.ts.map +1 -0
  295. package/lib/Utils/validate-connection.js +200 -0
  296. package/lib/Utils/validate-connection.js.map +1 -0
  297. package/lib/WABinary/constants.d.ts +28 -0
  298. package/lib/WABinary/constants.d.ts.map +1 -0
  299. package/lib/WABinary/constants.js +1301 -0
  300. package/lib/WABinary/constants.js.map +1 -0
  301. package/lib/WABinary/decode.d.ts +7 -0
  302. package/lib/WABinary/decode.d.ts.map +1 -0
  303. package/lib/WABinary/decode.js +262 -0
  304. package/lib/WABinary/decode.js.map +1 -0
  305. package/lib/WABinary/encode.d.ts +3 -0
  306. package/lib/WABinary/encode.d.ts.map +1 -0
  307. package/lib/WABinary/encode.js +220 -0
  308. package/lib/WABinary/encode.js.map +1 -0
  309. package/lib/WABinary/generic-utils.d.ts +15 -0
  310. package/lib/WABinary/generic-utils.d.ts.map +1 -0
  311. package/lib/WABinary/generic-utils.js +113 -0
  312. package/lib/WABinary/generic-utils.js.map +1 -0
  313. package/lib/WABinary/index.d.ts +6 -0
  314. package/lib/WABinary/index.d.ts.map +1 -0
  315. package/lib/WABinary/index.js +6 -0
  316. package/lib/WABinary/index.js.map +1 -0
  317. package/lib/WABinary/jid-utils.d.ts +48 -0
  318. package/lib/WABinary/jid-utils.d.ts.map +1 -0
  319. package/lib/WABinary/jid-utils.js +96 -0
  320. package/lib/WABinary/jid-utils.js.map +1 -0
  321. package/lib/WABinary/types.d.ts +19 -0
  322. package/lib/WABinary/types.d.ts.map +1 -0
  323. package/lib/WABinary/types.js +2 -0
  324. package/lib/WABinary/types.js.map +1 -0
  325. package/lib/WAM/BinaryInfo.d.ts +9 -0
  326. package/lib/WAM/BinaryInfo.d.ts.map +1 -0
  327. package/lib/WAM/BinaryInfo.js +10 -0
  328. package/lib/WAM/BinaryInfo.js.map +1 -0
  329. package/lib/WAM/constants.d.ts +40 -0
  330. package/lib/WAM/constants.d.ts.map +1 -0
  331. package/lib/WAM/constants.js +22853 -0
  332. package/lib/WAM/constants.js.map +1 -0
  333. package/lib/WAM/encode.d.ts +3 -0
  334. package/lib/WAM/encode.d.ts.map +1 -0
  335. package/lib/WAM/encode.js +150 -0
  336. package/lib/WAM/encode.js.map +1 -0
  337. package/lib/WAM/index.d.ts +4 -0
  338. package/lib/WAM/index.d.ts.map +1 -0
  339. package/lib/WAM/index.js +4 -0
  340. package/lib/WAM/index.js.map +1 -0
  341. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  342. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
  343. package/lib/WAUSync/Protocols/USyncContactProtocol.js +29 -0
  344. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
  345. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  346. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
  347. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  348. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
  349. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  350. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
  351. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  352. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
  353. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  354. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
  355. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  356. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
  357. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  358. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
  359. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  360. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
  361. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  362. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
  363. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  364. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
  365. package/lib/WAUSync/Protocols/index.d.ts +5 -0
  366. package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
  367. package/lib/WAUSync/Protocols/index.js +5 -0
  368. package/lib/WAUSync/Protocols/index.js.map +1 -0
  369. package/lib/WAUSync/USyncQuery.d.ts +29 -0
  370. package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
  371. package/lib/WAUSync/USyncQuery.js +94 -0
  372. package/lib/WAUSync/USyncQuery.js.map +1 -0
  373. package/lib/WAUSync/USyncUser.d.ts +13 -0
  374. package/lib/WAUSync/USyncUser.d.ts.map +1 -0
  375. package/lib/WAUSync/USyncUser.js +23 -0
  376. package/lib/WAUSync/USyncUser.js.map +1 -0
  377. package/lib/WAUSync/index.d.ts +4 -0
  378. package/lib/WAUSync/index.d.ts.map +1 -0
  379. package/lib/WAUSync/index.js +4 -0
  380. package/lib/WAUSync/index.js.map +1 -0
  381. package/lib/index.d.ts +12 -0
  382. package/lib/index.d.ts.map +1 -0
  383. package/lib/index.js +11 -0
  384. package/lib/index.js.map +1 -0
  385. package/package.json +58 -0
package/README.md ADDED
@@ -0,0 +1,1312 @@
1
+ <h1 align='center'><img alt="Baileys logo" src="https://raw.githubusercontent.com/WhiskeySockets/Baileys/refs/heads/master/Media/logo.png" height="75"/></h1>
2
+
3
+ <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
4
+
5
+
6
+ > [!CAUTION]
7
+ > NOTICE OF BREAKING CHANGE.
8
+ >
9
+ > As of 1.0.0, multiple breaking changes were introduced into the library.
10
+ >
11
+ > Please check out https://whiskey.so/migrate-latest for more information.
12
+
13
+ # Important Note
14
+ 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).
15
+
16
+ New guide link: https://baileys.wiki
17
+
18
+ # Get Support
19
+
20
+ 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.
21
+
22
+ 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.
23
+
24
+ # Sponsor
25
+ If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
26
+
27
+ # Disclaimer
28
+ 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.
29
+ 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.
30
+
31
+ 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.
32
+ Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
33
+
34
+ ##
35
+
36
+ - Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
37
+ - Not running Selenium or Chromium saves you like **half a gig** of ram :/
38
+ - Baileys supports interacting with the multi-device & web versions of WhatsApp.
39
+ - 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.
40
+
41
+ > [!IMPORTANT]
42
+ > The original repository had to be removed by the original author - we now continue development in this repository here.
43
+ This is the only official repository and is maintained by the community.
44
+ > **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
45
+
46
+ ## Example
47
+
48
+ Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
49
+ The script covers most common use cases.
50
+ To run the example script, download or clone the repo and then type the following in a terminal:
51
+ 1. ``` cd path/to/Baileys ```
52
+ 2. ``` yarn ```
53
+ 3. ``` yarn example ```
54
+
55
+ ## Install
56
+
57
+ Use the stable version:
58
+ ```
59
+ yarn add @blckrose/baileys
60
+ ```
61
+
62
+ Use the edge version (no guarantee of stability, but latest fixes + features)
63
+ ```
64
+ yarn add github:WhiskeySockets/Baileys
65
+ ```
66
+
67
+ Then import your code using:
68
+ ```ts
69
+ import makeWASocket from '@blckrose/baileys'
70
+ ```
71
+
72
+ # Links
73
+
74
+ - [Discord](https://discord.gg/WeJM5FP9GG)
75
+ - [Docs](https://guide.whiskeysockets.io/)
76
+
77
+ # Index
78
+
79
+ - [Connecting Account](#connecting-account)
80
+ - [Connect with QR-CODE](#starting-socket-with-qr-code)
81
+ - [Connect with Pairing Code](#starting-socket-with-pairing-code)
82
+ - [Receive Full History](#receive-full-history)
83
+ - [Important Notes About Socket Config](#important-notes-about-socket-config)
84
+ - [Caching Group Metadata (Recommended)](#caching-group-metadata-recommended)
85
+ - [Improve Retry System & Decrypt Poll Votes](#improve-retry-system--decrypt-poll-votes)
86
+ - [Receive Notifications in Whatsapp App](#receive-notifications-in-whatsapp-app)
87
+
88
+ - [Save Auth Info](#saving--restoring-sessions)
89
+ - [Handling Events](#handling-events)
90
+ - [Example to Start](#example-to-start)
91
+ - [Decrypt Poll Votes](#decrypt-poll-votes)
92
+ - [Summary of Events on First Connection](#summary-of-events-on-first-connection)
93
+ - [Implementing a Data Store](#implementing-a-data-store)
94
+ - [Whatsapp IDs Explain](#whatsapp-ids-explain)
95
+ - [Utility Functions](#utility-functions)
96
+ - [Sending Messages](#sending-messages)
97
+ - [Non-Media Messages](#non-media-messages)
98
+ - [Text Message](#text-message)
99
+ - [Quote Message](#quote-message-works-with-all-types)
100
+ - [Mention User](#mention-user-works-with-most-types)
101
+ - [Forward Messages](#forward-messages)
102
+ - [Location Message](#location-message)
103
+ - [Contact Message](#contact-message)
104
+ - [Reaction Message](#reaction-message)
105
+ - [Pin Message](#pin-message)
106
+ - [Poll Message](#poll-message)
107
+ - [Sending with Link Preview](#sending-messages-with-link-previews)
108
+ - [Media Messages](#media-messages)
109
+ - [Gif Message](#gif-message)
110
+ - [Video Message](#video-message)
111
+ - [Audio Message](#audio-message)
112
+ - [Image Message](#image-message)
113
+ - [ViewOnce Message](#view-once-message)
114
+ - [Modify Messages](#modify-messages)
115
+ - [Delete Messages (for everyone)](#deleting-messages-for-everyone)
116
+ - [Edit Messages](#editing-messages)
117
+ - [Manipulating Media Messages](#manipulating-media-messages)
118
+ - [Thumbnail in Media Messages](#thumbnail-in-media-messages)
119
+ - [Downloading Media Messages](#downloading-media-messages)
120
+ - [Re-upload Media Message to Whatsapp](#re-upload-media-message-to-whatsapp)
121
+ - [Reject Call](#reject-call)
122
+ - [Send States in Chat](#send-states-in-chat)
123
+ - [Reading Messages](#reading-messages)
124
+ - [Update Presence](#update-presence)
125
+ - [Modifying Chats](#modifying-chats)
126
+ - [Archive a Chat](#archive-a-chat)
127
+ - [Mute/Unmute a Chat](#muteunmute-a-chat)
128
+ - [Mark a Chat Read/Unread](#mark-a-chat-readunread)
129
+ - [Delete a Message for Me](#delete-a-message-for-me)
130
+ - [Delete a Chat](#delete-a-chat)
131
+ - [Star/Unstar a Message](#starunstar-a-message)
132
+ - [Disappearing Messages](#disappearing-messages)
133
+ - [User Querys](#user-querys)
134
+ - [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
135
+ - [Query Chat History (groups too)](#query-chat-history-groups-too)
136
+ - [Fetch Status](#fetch-status)
137
+ - [Fetch Profile Picture (groups too)](#fetch-profile-picture-groups-too)
138
+ - [Fetch Bussines Profile (such as description or category)](#fetch-bussines-profile-such-as-description-or-category)
139
+ - [Fetch Someone's Presence (if they're typing or online)](#fetch-someones-presence-if-theyre-typing-or-online)
140
+ - [Change Profile](#change-profile)
141
+ - [Change Profile Status](#change-profile-status)
142
+ - [Change Profile Name](#change-profile-name)
143
+ - [Change Display Picture (groups too)](#change-display-picture-groups-too)
144
+ - [Remove display picture (groups too)](#remove-display-picture-groups-too)
145
+ - [Groups](#groups)
146
+ - [Create a Group](#create-a-group)
147
+ - [Add/Remove or Demote/Promote](#addremove-or-demotepromote)
148
+ - [Change Subject (name)](#change-subject-name)
149
+ - [Change Description](#change-description)
150
+ - [Change Settings](#change-settings)
151
+ - [Leave a Group](#leave-a-group)
152
+ - [Get Invite Code](#get-invite-code)
153
+ - [Revoke Invite Code](#revoke-invite-code)
154
+ - [Join Using Invitation Code](#join-using-invitation-code)
155
+ - [Get Group Info by Invite Code](#get-group-info-by-invite-code)
156
+ - [Query Metadata (participants, name, description...)](#query-metadata-participants-name-description)
157
+ - [Join using groupInviteMessage](#join-using-groupinvitemessage)
158
+ - [Get Request Join List](#get-request-join-list)
159
+ - [Approve/Reject Request Join](#approvereject-request-join)
160
+ - [Get All Participating Groups Metadata](#get-all-participating-groups-metadata)
161
+ - [Toggle Ephemeral](#toggle-ephemeral)
162
+ - [Change Add Mode](#change-add-mode)
163
+ - [Privacy](#privacy)
164
+ - [Block/Unblock User](#blockunblock-user)
165
+ - [Get Privacy Settings](#get-privacy-settings)
166
+ - [Get BlockList](#get-blocklist)
167
+ - [Update LastSeen Privacy](#update-lastseen-privacy)
168
+ - [Update Online Privacy](#update-online-privacy)
169
+ - [Update Profile Picture Privacy](#update-profile-picture-privacy)
170
+ - [Update Status Privacy](#update-status-privacy)
171
+ - [Update Read Receipts Privacy](#update-read-receipts-privacy)
172
+ - [Update Groups Add Privacy](#update-groups-add-privacy)
173
+ - [Update Default Disappearing Mode](#update-default-disappearing-mode)
174
+ - [Broadcast Lists & Stories](#broadcast-lists--stories)
175
+ - [Send Broadcast & Stories](#send-broadcast--stories)
176
+ - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
177
+ - [Writing Custom Functionality](#writing-custom-functionality)
178
+ - [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
179
+ - [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
180
+ - [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
181
+
182
+ ## Connecting Account
183
+
184
+ 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.
185
+
186
+ > [!NOTE]
187
+ > **[Here](#example-to-start) is a simple example of event handling**
188
+
189
+ > [!TIP]
190
+ > **You can see all supported socket configs [here](https://baileys.whiskeysockets.io/types/SocketConfig.html) (Recommended)**
191
+
192
+ ### Starting socket with **QR-CODE**
193
+
194
+ > [!TIP]
195
+ > You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
196
+
197
+ ```ts
198
+ import makeWASocket from '@blckrose/baileys'
199
+
200
+ const sock = makeWASocket({
201
+ // can provide additional config here
202
+ browser: Browsers.ubuntu('My App'),
203
+ printQRInTerminal: true
204
+ })
205
+ ```
206
+
207
+ 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!
208
+
209
+ ### Starting socket with **Pairing Code**
210
+
211
+
212
+ > [!IMPORTANT]
213
+ > 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)
214
+
215
+ The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
216
+
217
+ ```ts
218
+ import makeWASocket from '@blckrose/baileys'
219
+
220
+ const sock = makeWASocket({
221
+ // can provide additional config here
222
+ printQRInTerminal: false //need to be false
223
+ })
224
+
225
+ if (!sock.authState.creds.registered) {
226
+ const number = 'XXXXXXXXXXX'
227
+ const code = await sock.requestPairingCode(number)
228
+ console.log(code)
229
+ }
230
+ ```
231
+
232
+ ### Receive Full History
233
+
234
+ 1. Set `syncFullHistory` as `true`
235
+ 2. Baileys, by default, use chrome browser config
236
+ - If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
237
+
238
+ ```ts
239
+ const sock = makeWASocket({
240
+ ...otherOpts,
241
+ // can use Windows, Ubuntu here too
242
+ browser: Browsers.macOS('Desktop'),
243
+ syncFullHistory: true
244
+ })
245
+ ```
246
+
247
+ ## Important Notes About Socket Config
248
+
249
+ ### Caching Group Metadata (Recommended)
250
+ - If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
251
+
252
+ ```ts
253
+ const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
254
+
255
+ const sock = makeWASocket({
256
+ cachedGroupMetadata: async (jid) => groupCache.get(jid)
257
+ })
258
+
259
+ sock.ev.on('groups.update', async ([event]) => {
260
+ const metadata = await sock.groupMetadata(event.id)
261
+ groupCache.set(event.id, metadata)
262
+ })
263
+
264
+ sock.ev.on('group-participants.update', async (event) => {
265
+ const metadata = await sock.groupMetadata(event.id)
266
+ groupCache.set(event.id, metadata)
267
+ })
268
+ ```
269
+
270
+ ### Improve Retry System & Decrypt Poll Votes
271
+ - 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:
272
+ ```ts
273
+ const sock = makeWASocket({
274
+ getMessage: async (key) => await getMessageFromStore(key)
275
+ })
276
+ ```
277
+
278
+ ### Receive Notifications in Whatsapp App
279
+ - If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
280
+ ```ts
281
+ const sock = makeWASocket({
282
+ markOnlineOnConnect: false
283
+ })
284
+ ```
285
+ ## Saving & Restoring Sessions
286
+
287
+ You obviously don't want to keep scanning the QR code every time you want to connect.
288
+
289
+ So, you can load the credentials to log back in:
290
+ ```ts
291
+ import makeWASocket, { useMultiFileAuthState } from '@blckrose/baileys'
292
+
293
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
294
+
295
+ // will use the given state to connect
296
+ // so if valid credentials are available -- it'll connect without QR
297
+ const sock = makeWASocket({ auth: state })
298
+
299
+ // this will be called as soon as the credentials are updated
300
+ sock.ev.on('creds.update', saveCreds)
301
+ ```
302
+
303
+ > [!IMPORTANT]
304
+ > `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.
305
+
306
+ > [!NOTE]
307
+ > 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.
308
+
309
+ ## Handling Events
310
+
311
+ - Baileys uses the EventEmitter syntax for events.
312
+ They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
313
+
314
+ > [!IMPORTANT]
315
+ > **The events are [these](https://baileys.whiskeysockets.io/types/BaileysEventMap.html)**, it's important you see all events
316
+
317
+ You can listen to these events like this:
318
+ ```ts
319
+ const sock = makeWASocket()
320
+ sock.ev.on('messages.upsert', ({ messages }) => {
321
+ console.log('got messages', messages)
322
+ })
323
+ ```
324
+
325
+ ### Example to Start
326
+
327
+ > [!NOTE]
328
+ > This example includes basic auth storage too
329
+
330
+ > [!NOTE]
331
+ > For reliable serialization of the authentication state, especially when storing as JSON, always use the BufferJSON utility.
332
+
333
+ ```ts
334
+ import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@blckrose/baileys'
335
+ import { Boom } from '@hapi/boom'
336
+
337
+ async function connectToWhatsApp () {
338
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
339
+ const sock = makeWASocket({
340
+ // can provide additional config here
341
+ auth: state,
342
+ printQRInTerminal: true
343
+ })
344
+ sock.ev.on('connection.update', (update) => {
345
+ const { connection, lastDisconnect } = update
346
+ if(connection === 'close') {
347
+ const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
348
+ console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
349
+ // reconnect if not logged out
350
+ if(shouldReconnect) {
351
+ connectToWhatsApp()
352
+ }
353
+ } else if(connection === 'open') {
354
+ console.log('opened connection')
355
+ }
356
+ })
357
+ sock.ev.on('messages.upsert', event => {
358
+ for (const m of event.messages) {
359
+ console.log(JSON.stringify(m, undefined, 2))
360
+
361
+ console.log('replying to', m.key.remoteJid)
362
+ await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
363
+ }
364
+ })
365
+
366
+ // to storage creds (session info) when it updates
367
+ sock.ev.on('creds.update', saveCreds)
368
+ }
369
+ // run in main file
370
+ connectToWhatsApp()
371
+ ```
372
+
373
+ > [!IMPORTANT]
374
+ > In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
375
+
376
+ ### Decrypt Poll Votes
377
+
378
+ - By default poll votes are encrypted and handled in `messages.update`
379
+ - That's a simple example
380
+ ```ts
381
+ sock.ev.on('messages.update', event => {
382
+ for(const { key, update } of event) {
383
+ if(update.pollUpdates) {
384
+ const pollCreation = await getMessage(key)
385
+ if(pollCreation) {
386
+ console.log(
387
+ 'got poll update, aggregation: ',
388
+ getAggregateVotesInPollMessage({
389
+ message: pollCreation,
390
+ pollUpdates: update.pollUpdates,
391
+ })
392
+ )
393
+ }
394
+ }
395
+ }
396
+ })
397
+ ```
398
+
399
+ - `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
400
+
401
+ ### Summary of Events on First Connection
402
+
403
+ 1. When you connect first time, `connection.update` will be fired requesting you to restart sock
404
+ 2. Then, history messages will be received in `messaging.history-set`
405
+
406
+ ## Implementing a Data Store
407
+
408
+ - 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.
409
+
410
+ > [!IMPORTANT]
411
+ > I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
412
+
413
+ It can be used as follows:
414
+
415
+ ```ts
416
+ import makeWASocket, { makeInMemoryStore } from '@blckrose/baileys'
417
+ // the store maintains the data of the WA connection in memory
418
+ // can be written out to a file & read from it
419
+ const store = makeInMemoryStore({ })
420
+ // can be read from a file
421
+ store.readFromFile('./baileys_store.json')
422
+ // saves the state to a file every 10s
423
+ setInterval(() => {
424
+ store.writeToFile('./baileys_store.json')
425
+ }, 10_000)
426
+
427
+ const sock = makeWASocket({ })
428
+ // will listen from this socket
429
+ // the store can listen from a new socket once the current socket outlives its lifetime
430
+ store.bind(sock.ev)
431
+
432
+ sock.ev.on('chats.upsert', () => {
433
+ // can use 'store.chats' however you want, even after the socket dies out
434
+ // 'chats' => a KeyedDB instance
435
+ console.log('got chats', store.chats.all())
436
+ })
437
+
438
+ sock.ev.on('contacts.upsert', () => {
439
+ console.log('got contacts', Object.values(store.contacts))
440
+ })
441
+
442
+ ```
443
+
444
+ The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
445
+
446
+ ## Whatsapp IDs Explain
447
+
448
+ - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
449
+ - It must be in the format ```[country code][phone number]@s.whatsapp.net```
450
+ - Example for people: ```+19999999999@s.whatsapp.net```.
451
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
452
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
453
+ - For stories, the ID is `status@broadcast`.
454
+
455
+ ## Utility Functions
456
+
457
+ - `getContentType`, returns the content type for any message
458
+ - `getDevice`, returns the device from message
459
+ - `makeCacheableSignalKeyStore`, make auth store more fast
460
+ - `downloadContentFromMessage`, download content from any message
461
+
462
+ ## Sending Messages
463
+
464
+ - Send all types of messages with a single function
465
+ - **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
466
+ - **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
467
+
468
+ ```ts
469
+ const jid: string
470
+ const content: AnyMessageContent
471
+ const options: MiscMessageGenerationOptions
472
+
473
+ sock.sendMessage(jid, content, options)
474
+ ```
475
+
476
+ ### Non-Media Messages
477
+
478
+ #### Text Message
479
+ ```ts
480
+ await sock.sendMessage(jid, { text: 'hello word' })
481
+ ```
482
+
483
+ #### Quote Message (works with all types)
484
+ ```ts
485
+ await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
486
+ ```
487
+
488
+ #### Mention User (works with most types)
489
+ - @number is to mention in text, it's optional
490
+ ```ts
491
+ await sock.sendMessage(
492
+ jid,
493
+ {
494
+ text: '@12345678901',
495
+ mentions: ['12345678901@s.whatsapp.net']
496
+ }
497
+ )
498
+ ```
499
+
500
+ #### Forward Messages
501
+ - You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.whiskeysockets.io/types/WAMessage.html) object
502
+ ```ts
503
+ const msg = getMessageFromStore() // implement this on your end
504
+ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
505
+ ```
506
+
507
+ #### Location Message
508
+ ```ts
509
+ await sock.sendMessage(
510
+ jid,
511
+ {
512
+ location: {
513
+ degreesLatitude: 24.121231,
514
+ degreesLongitude: 55.1121221
515
+ }
516
+ }
517
+ )
518
+ ```
519
+ #### Contact Message
520
+ ```ts
521
+ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
522
+ + 'VERSION:3.0\n'
523
+ + 'FN:Jeff Singh\n' // full name
524
+ + 'ORG:Ashoka Uni;\n' // the organization of the contact
525
+ + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
526
+ + 'END:VCARD'
527
+
528
+ await sock.sendMessage(
529
+ id,
530
+ {
531
+ contacts: {
532
+ displayName: 'Jeff',
533
+ contacts: [{ vcard }]
534
+ }
535
+ }
536
+ )
537
+ ```
538
+
539
+ #### Reaction Message
540
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
541
+ ```ts
542
+ await sock.sendMessage(
543
+ jid,
544
+ {
545
+ react: {
546
+ text: '💖', // use an empty string to remove the reaction
547
+ key: message.key
548
+ }
549
+ }
550
+ )
551
+ ```
552
+
553
+ #### Pin Message
554
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
555
+
556
+ - Time can be:
557
+
558
+ | Time | Seconds |
559
+ |-------|----------------|
560
+ | 24h | 86.400 |
561
+ | 7d | 604.800 |
562
+ | 30d | 2.592.000 |
563
+
564
+ ```ts
565
+ await sock.sendMessage(
566
+ jid,
567
+ {
568
+ pin: {
569
+ type: 1, // 0 to remove
570
+ time: 86400
571
+ key: message.key
572
+ }
573
+ }
574
+ )
575
+ ```
576
+
577
+ #### Poll Message
578
+ ```ts
579
+ await sock.sendMessage(
580
+ jid,
581
+ {
582
+ poll: {
583
+ name: 'My Poll',
584
+ values: ['Option 1', 'Option 2', ...],
585
+ selectableCount: 1,
586
+ toAnnouncementGroup: false // or true
587
+ }
588
+ }
589
+ )
590
+ ```
591
+
592
+ ### Sending Messages with Link Previews
593
+
594
+ 1. By default, wa does not have link generation when sent from the web
595
+ 2. Baileys has a function to generate the content for these link previews
596
+ 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
597
+ 4. Send a link:
598
+ ```ts
599
+ await sock.sendMessage(
600
+ jid,
601
+ {
602
+ text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
603
+ }
604
+ )
605
+ ```
606
+
607
+ ### Media Messages
608
+
609
+ Sending media (video, stickers, images) is easier & more efficient than ever.
610
+
611
+ > [!NOTE]
612
+ > In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
613
+
614
+ - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
615
+
616
+ > [!TIP]
617
+ > It's recommended to use Stream or Url to save memory
618
+
619
+ #### Gif Message
620
+ - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
621
+ ```ts
622
+ await sock.sendMessage(
623
+ jid,
624
+ {
625
+ video: fs.readFileSync('Media/ma_gif.mp4'),
626
+ caption: 'hello word',
627
+ gifPlayback: true
628
+ }
629
+ )
630
+ ```
631
+
632
+ #### Video Message
633
+ ```ts
634
+ await sock.sendMessage(
635
+ id,
636
+ {
637
+ video: {
638
+ url: './Media/ma_gif.mp4'
639
+ },
640
+ caption: 'hello word',
641
+ ptv: false // if set to true, will send as a `video note`
642
+ }
643
+ )
644
+ ```
645
+
646
+ #### Audio Message
647
+ - To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
648
+ ```bash
649
+ codec: libopus //ogg file
650
+ ac: 1 //one channel
651
+ avoid_negative_ts
652
+ make_zero
653
+ ```
654
+ - Example:
655
+ ```bash
656
+ ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
657
+ ```
658
+ ```ts
659
+ await sock.sendMessage(
660
+ jid,
661
+ {
662
+ audio: {
663
+ url: './Media/audio.mp3'
664
+ },
665
+ mimetype: 'audio/mp4'
666
+ }
667
+ )
668
+ ```
669
+
670
+ #### Image Message
671
+ ```ts
672
+ await sock.sendMessage(
673
+ id,
674
+ {
675
+ image: {
676
+ url: './Media/ma_img.png'
677
+ },
678
+ caption: 'hello word'
679
+ }
680
+ )
681
+ ```
682
+
683
+ #### View Once Message
684
+
685
+ - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
686
+
687
+ ```ts
688
+ await sock.sendMessage(
689
+ id,
690
+ {
691
+ image: {
692
+ url: './Media/ma_img.png'
693
+ },
694
+ viewOnce: true, //works with video, audio too
695
+ caption: 'hello word'
696
+ }
697
+ )
698
+ ```
699
+
700
+ ## Modify Messages
701
+
702
+ ### Deleting Messages (for everyone)
703
+
704
+ ```ts
705
+ const msg = await sock.sendMessage(jid, { text: 'hello word' })
706
+ await sock.sendMessage(jid, { delete: msg.key })
707
+ ```
708
+
709
+ **Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
710
+
711
+ ### Editing Messages
712
+
713
+ - You can pass all editable contents here
714
+ ```ts
715
+ await sock.sendMessage(jid, {
716
+ text: 'updated text goes here',
717
+ edit: response.key,
718
+ });
719
+ ```
720
+
721
+ ## Manipulating Media Messages
722
+
723
+ ### Thumbnail in Media Messages
724
+ - 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`.
725
+ - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
726
+
727
+ ### Downloading Media Messages
728
+
729
+ If you want to save the media you received
730
+ ```ts
731
+ import { createWriteStream } from 'fs'
732
+ import { downloadMediaMessage, getContentType } from '@blckrose/baileys'
733
+
734
+ sock.ev.on('messages.upsert', async ({ [m] }) => {
735
+ if (!m.message) return // if there is no text or media message
736
+ const messageType = getContentType(m) // get what type of message it is (text, image, video...)
737
+
738
+ // if the message is an image
739
+ if (messageType === 'imageMessage') {
740
+ // download the message
741
+ const stream = await downloadMediaMessage(
742
+ m,
743
+ 'stream', // can be 'buffer' too
744
+ { },
745
+ {
746
+ logger,
747
+ // pass this so that baileys can request a reupload of media
748
+ // that has been deleted
749
+ reuploadRequest: sock.updateMediaMessage
750
+ }
751
+ )
752
+ // save to file
753
+ const writeStream = createWriteStream('./my-download.jpeg')
754
+ stream.pipe(writeStream)
755
+ }
756
+ }
757
+ ```
758
+
759
+ ### Re-upload Media Message to Whatsapp
760
+
761
+ - 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:
762
+ ```ts
763
+ await sock.updateMediaMessage(msg)
764
+ ```
765
+
766
+ ## Reject Call
767
+
768
+ - You can obtain `callId` and `callFrom` from `call` event
769
+
770
+ ```ts
771
+ await sock.rejectCall(callId, callFrom)
772
+ ```
773
+
774
+ ## Send States in Chat
775
+
776
+ ### Reading Messages
777
+ - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
778
+ - You cannot mark an entire 'chat' read as it were with Baileys Web.
779
+ This means you have to keep track of unread messages.
780
+
781
+ ```ts
782
+ const key: WAMessageKey
783
+ // can pass multiple keys to read multiple messages as well
784
+ await sock.readMessages([key])
785
+ ```
786
+
787
+ The message ID is the unique identifier of the message that you are marking as read.
788
+ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
789
+
790
+ ### Update Presence
791
+
792
+ - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
793
+ - The presence expires after about 10 seconds.
794
+ - This lets the person/group with `jid` know whether you're online, offline, typing etc.
795
+
796
+ ```ts
797
+ await sock.sendPresenceUpdate('available', jid)
798
+ ```
799
+
800
+ > [!NOTE]
801
+ > 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')`
802
+
803
+ ## Modifying Chats
804
+
805
+ WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
806
+
807
+ > [!IMPORTANT]
808
+ > 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.
809
+
810
+ ### Archive a Chat
811
+ ```ts
812
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
813
+ await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
814
+ ```
815
+ ### Mute/Unmute a Chat
816
+
817
+ - Supported times:
818
+
819
+ | Time | Miliseconds |
820
+ |-------|-----------------|
821
+ | Remove | null |
822
+ | 8h | 86.400.000 |
823
+ | 7d | 604.800.000 |
824
+
825
+ ```ts
826
+ // mute for 8 hours
827
+ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
828
+ // unmute
829
+ await sock.chatModify({ mute: null }, jid)
830
+ ```
831
+ ### Mark a Chat Read/Unread
832
+ ```ts
833
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
834
+ // mark it unread
835
+ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
836
+ ```
837
+
838
+ ### Delete a Message for Me
839
+ ```ts
840
+ await sock.chatModify(
841
+ {
842
+ clear: {
843
+ messages: [
844
+ {
845
+ id: 'ATWYHDNNWU81732J',
846
+ fromMe: true,
847
+ timestamp: '1654823909'
848
+ }
849
+ ]
850
+ }
851
+ },
852
+ jid
853
+ )
854
+
855
+ ```
856
+ ### Delete a Chat
857
+ ```ts
858
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
859
+ await sock.chatModify({
860
+ delete: true,
861
+ lastMessages: [
862
+ {
863
+ key: lastMsgInChat.key,
864
+ messageTimestamp: lastMsgInChat.messageTimestamp
865
+ }
866
+ ]
867
+ },
868
+ jid
869
+ )
870
+ ```
871
+ ### Pin/Unpin a Chat
872
+ ```ts
873
+ await sock.chatModify({
874
+ pin: true // or `false` to unpin
875
+ },
876
+ jid
877
+ )
878
+ ```
879
+ ### Star/Unstar a Message
880
+ ```ts
881
+ await sock.chatModify({
882
+ star: {
883
+ messages: [
884
+ {
885
+ id: 'messageID',
886
+ fromMe: true // or `false`
887
+ }
888
+ ],
889
+ star: true // - true: Star Message; false: Unstar Message
890
+ }
891
+ },
892
+ jid
893
+ )
894
+ ```
895
+
896
+ ### Disappearing Messages
897
+
898
+ - Ephemeral can be:
899
+
900
+ | Time | Seconds |
901
+ |-------|----------------|
902
+ | Remove | 0 |
903
+ | 24h | 86.400 |
904
+ | 7d | 604.800 |
905
+ | 90d | 7.776.000 |
906
+
907
+ - You need to pass in **Seconds**, default is 7 days
908
+
909
+ ```ts
910
+ // turn on disappearing messages
911
+ await sock.sendMessage(
912
+ jid,
913
+ // this is 1 week in seconds -- how long you want messages to appear for
914
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
915
+ )
916
+
917
+ // will send as a disappearing message
918
+ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
919
+
920
+ // turn off disappearing messages
921
+ await sock.sendMessage(
922
+ jid,
923
+ { disappearingMessagesInChat: false }
924
+ )
925
+ ```
926
+
927
+ ## User Querys
928
+
929
+ ### Check If ID Exists in Whatsapp
930
+ ```ts
931
+ const [result] = await sock.onWhatsApp(jid)
932
+ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
933
+ ```
934
+
935
+ ### Query Chat History (groups too)
936
+
937
+ - You need to have oldest message in chat
938
+ ```ts
939
+ const msg = await getOldestMessageInChat(jid) // implement this on your end
940
+ await sock.fetchMessageHistory(
941
+ 50, //quantity (max: 50 per query)
942
+ msg.key,
943
+ msg.messageTimestamp
944
+ )
945
+ ```
946
+ - Messages will be received in `messaging.history-set` event
947
+
948
+ ### Fetch Status
949
+ ```ts
950
+ const status = await sock.fetchStatus(jid)
951
+ console.log('status: ' + status)
952
+ ```
953
+
954
+ ### Fetch Profile Picture (groups too)
955
+ - To get the display picture of some person/group
956
+ ```ts
957
+ // for low res picture
958
+ const ppUrl = await sock.profilePictureUrl(jid)
959
+ console.log(ppUrl)
960
+
961
+ // for high res picture
962
+ const ppUrl = await sock.profilePictureUrl(jid, 'image')
963
+ ```
964
+
965
+ ### Fetch Bussines Profile (such as description or category)
966
+ ```ts
967
+ const profile = await sock.getBusinessProfile(jid)
968
+ console.log('business description: ' + profile.description + ', category: ' + profile.category)
969
+ ```
970
+
971
+ ### Fetch Someone's Presence (if they're typing or online)
972
+ ```ts
973
+ // the presence update is fetched and called here
974
+ sock.ev.on('presence.update', console.log)
975
+
976
+ // request updates for a chat
977
+ await sock.presenceSubscribe(jid)
978
+ ```
979
+
980
+ ## Change Profile
981
+
982
+ ### Change Profile Status
983
+ ```ts
984
+ await sock.updateProfileStatus('Hello World!')
985
+ ```
986
+ ### Change Profile Name
987
+ ```ts
988
+ await sock.updateProfileName('My name')
989
+ ```
990
+ ### Change Display Picture (groups too)
991
+ - To change your display picture or a group's
992
+
993
+ > [!NOTE]
994
+ > Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
995
+
996
+ ```ts
997
+ await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
998
+ ```
999
+ ### Remove display picture (groups too)
1000
+ ```ts
1001
+ await sock.removeProfilePicture(jid)
1002
+ ```
1003
+
1004
+ ## Groups
1005
+
1006
+ - To change group properties you need to be admin
1007
+
1008
+ ### Create a Group
1009
+ ```ts
1010
+ // title & participants
1011
+ const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1012
+ console.log('created group with id: ' + group.gid)
1013
+ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1014
+ ```
1015
+ ### Add/Remove or Demote/Promote
1016
+ ```ts
1017
+ // id & people to add to the group (will throw error if it fails)
1018
+ await sock.groupParticipantsUpdate(
1019
+ jid,
1020
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1021
+ 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1022
+ )
1023
+ ```
1024
+ ### Change Subject (name)
1025
+ ```ts
1026
+ await sock.groupUpdateSubject(jid, 'New Subject!')
1027
+ ```
1028
+ ### Change Description
1029
+ ```ts
1030
+ await sock.groupUpdateDescription(jid, 'New Description!')
1031
+ ```
1032
+ ### Change Settings
1033
+ ```ts
1034
+ // only allow admins to send messages
1035
+ await sock.groupSettingUpdate(jid, 'announcement')
1036
+ // allow everyone to send messages
1037
+ await sock.groupSettingUpdate(jid, 'not_announcement')
1038
+ // allow everyone to modify the group's settings -- like display picture etc.
1039
+ await sock.groupSettingUpdate(jid, 'unlocked')
1040
+ // only allow admins to modify the group's settings
1041
+ await sock.groupSettingUpdate(jid, 'locked')
1042
+ ```
1043
+ ### Leave a Group
1044
+ ```ts
1045
+ // will throw error if it fails
1046
+ await sock.groupLeave(jid)
1047
+ ```
1048
+ ### Get Invite Code
1049
+ - To create link with code use `'https://chat.whatsapp.com/' + code`
1050
+ ```ts
1051
+ const code = await sock.groupInviteCode(jid)
1052
+ console.log('group code: ' + code)
1053
+ ```
1054
+ ### Revoke Invite Code
1055
+ ```ts
1056
+ const code = await sock.groupRevokeInvite(jid)
1057
+ console.log('New group code: ' + code)
1058
+ ```
1059
+ ### Join Using Invitation Code
1060
+ - Code can't have `https://chat.whatsapp.com/`, only code
1061
+ ```ts
1062
+ const response = await sock.groupAcceptInvite(code)
1063
+ console.log('joined to: ' + response)
1064
+ ```
1065
+ ### Get Group Info by Invite Code
1066
+ ```ts
1067
+ const response = await sock.groupGetInviteInfo(code)
1068
+ console.log('group information: ' + response)
1069
+ ```
1070
+ ### Query Metadata (participants, name, description...)
1071
+ ```ts
1072
+ const metadata = await sock.groupMetadata(jid)
1073
+ console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1074
+ ```
1075
+ ### Join using `groupInviteMessage`
1076
+ ```ts
1077
+ const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1078
+ console.log('joined to: ' + response)
1079
+ ```
1080
+ ### Get Request Join List
1081
+ ```ts
1082
+ const response = await sock.groupRequestParticipantsList(jid)
1083
+ console.log(response)
1084
+ ```
1085
+ ### Approve/Reject Request Join
1086
+ ```ts
1087
+ const response = await sock.groupRequestParticipantsUpdate(
1088
+ jid, // group id
1089
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1090
+ 'approve' // or 'reject'
1091
+ )
1092
+ console.log(response)
1093
+ ```
1094
+ ### Get All Participating Groups Metadata
1095
+ ```ts
1096
+ const response = await sock.groupFetchAllParticipating()
1097
+ console.log(response)
1098
+ ```
1099
+ ### Toggle Ephemeral
1100
+
1101
+ - Ephemeral can be:
1102
+
1103
+ | Time | Seconds |
1104
+ |-------|----------------|
1105
+ | Remove | 0 |
1106
+ | 24h | 86.400 |
1107
+ | 7d | 604.800 |
1108
+ | 90d | 7.776.000 |
1109
+
1110
+ ```ts
1111
+ await sock.groupToggleEphemeral(jid, 86400)
1112
+ ```
1113
+
1114
+ ### Change Add Mode
1115
+ ```ts
1116
+ await sock.groupMemberAddMode(
1117
+ jid,
1118
+ 'all_member_add' // or 'admin_add'
1119
+ )
1120
+ ```
1121
+
1122
+ ## Privacy
1123
+
1124
+ ### Block/Unblock User
1125
+ ```ts
1126
+ await sock.updateBlockStatus(jid, 'block') // Block user
1127
+ await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1128
+ ```
1129
+ ### Get Privacy Settings
1130
+ ```ts
1131
+ const privacySettings = await sock.fetchPrivacySettings(true)
1132
+ console.log('privacy settings: ' + privacySettings)
1133
+ ```
1134
+ ### Get BlockList
1135
+ ```ts
1136
+ const response = await sock.fetchBlocklist()
1137
+ console.log(response)
1138
+ ```
1139
+ ### Update LastSeen Privacy
1140
+ ```ts
1141
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1142
+ await sock.updateLastSeenPrivacy(value)
1143
+ ```
1144
+ ### Update Online Privacy
1145
+ ```ts
1146
+ const value = 'all' // 'match_last_seen'
1147
+ await sock.updateOnlinePrivacy(value)
1148
+ ```
1149
+ ### Update Profile Picture Privacy
1150
+ ```ts
1151
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1152
+ await sock.updateProfilePicturePrivacy(value)
1153
+ ```
1154
+ ### Update Status Privacy
1155
+ ```ts
1156
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1157
+ await sock.updateStatusPrivacy(value)
1158
+ ```
1159
+ ### Update Read Receipts Privacy
1160
+ ```ts
1161
+ const value = 'all' // 'none'
1162
+ await sock.updateReadReceiptsPrivacy(value)
1163
+ ```
1164
+ ### Update Groups Add Privacy
1165
+ ```ts
1166
+ const value = 'all' // 'contacts' | 'contact_blacklist'
1167
+ await sock.updateGroupsAddPrivacy(value)
1168
+ ```
1169
+ ### Update Default Disappearing Mode
1170
+
1171
+ - Like [this](#disappearing-messages), ephemeral can be:
1172
+
1173
+ | Time | Seconds |
1174
+ |-------|----------------|
1175
+ | Remove | 0 |
1176
+ | 24h | 86.400 |
1177
+ | 7d | 604.800 |
1178
+ | 90d | 7.776.000 |
1179
+
1180
+ ```ts
1181
+ const ephemeral = 86400
1182
+ await sock.updateDefaultDisappearingMode(ephemeral)
1183
+ ```
1184
+
1185
+ ## Broadcast Lists & Stories
1186
+
1187
+ ### Send Broadcast & Stories
1188
+ - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1189
+ ```ts
1190
+ await sock.sendMessage(
1191
+ jid,
1192
+ {
1193
+ image: {
1194
+ url: url
1195
+ },
1196
+ caption: caption
1197
+ },
1198
+ {
1199
+ backgroundColor: backgroundColor,
1200
+ font: font,
1201
+ statusJidList: statusJidList,
1202
+ broadcast: true
1203
+ }
1204
+ )
1205
+ ```
1206
+ - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
1207
+ - You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
1208
+ - `broadcast: true` enables broadcast mode
1209
+ - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1210
+
1211
+ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1212
+ - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1213
+ - Broadcast IDs are in the format `12345678@broadcast`
1214
+ ### Query a Broadcast List's Recipients & Name
1215
+ ```ts
1216
+ const bList = await sock.getBroadcastListInfo('1234@broadcast')
1217
+ console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1218
+ ```
1219
+
1220
+ ## Writing Custom Functionality
1221
+ Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1222
+
1223
+ ### Enabling Debug Level in Baileys Logs
1224
+ First, enable the logging of unhandled messages from WhatsApp by setting:
1225
+ ```ts
1226
+ const sock = makeWASocket({
1227
+ logger: P({ level: 'debug' }),
1228
+ })
1229
+ ```
1230
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
1231
+
1232
+ ### How Whatsapp Communicate With Us
1233
+
1234
+ > [!TIP]
1235
+ > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1236
+
1237
+ - **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:
1238
+ ```
1239
+ {
1240
+ "level": 10,
1241
+ "fromMe": false,
1242
+ "frame": {
1243
+ "tag": "ib",
1244
+ "attrs": {
1245
+ "from": "@s.whatsapp.net"
1246
+ },
1247
+ "content": [
1248
+ {
1249
+ "tag": "edge_routing",
1250
+ "attrs": {},
1251
+ "content": [
1252
+ {
1253
+ "tag": "routing_info",
1254
+ "attrs": {},
1255
+ "content": {
1256
+ "type": "Buffer",
1257
+ "data": [8,2,8,5]
1258
+ }
1259
+ }
1260
+ ]
1261
+ }
1262
+ ]
1263
+ },
1264
+ "msg":"communication"
1265
+ }
1266
+ ```
1267
+
1268
+ The `'frame'` is what the message received is, it has three components:
1269
+ - `tag` -- what this frame is about (eg. message will have 'message')
1270
+ - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1271
+ - `content` -- the actual data (eg. a message node will have the actual message content in it)
1272
+ - read more about this format [here](/src/WABinary/readme.md)
1273
+
1274
+ ### Register a Callback for Websocket Events
1275
+
1276
+ > [!TIP]
1277
+ > Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired
1278
+
1279
+ ```ts
1280
+ // for any message with tag 'edge_routing'
1281
+ sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1282
+
1283
+ // for any message with tag 'edge_routing' and id attribute = abcd
1284
+ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1285
+
1286
+ // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
1287
+ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
1288
+ ```
1289
+
1290
+ # License
1291
+ Copyright (c) 2025 Rajeh Taher/WhiskeySockets
1292
+
1293
+ Licensed under the MIT License:
1294
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1295
+ of this software and associated documentation files (the "Software"), to deal
1296
+ in the Software without restriction, including without limitation the rights
1297
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1298
+ copies of the Software, and to permit persons to whom the Software is
1299
+ furnished to do so, subject to the following conditions:
1300
+
1301
+ The above copyright notice and this permission notice shall be included in all
1302
+ copies or substantial portions of the Software.
1303
+
1304
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1305
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1306
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1307
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1308
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1309
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1310
+ SOFTWARE.
1311
+
1312
+ Thus, the maintainers of the project can't be held liable for any potential misuse of this project.