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