@kelvdra/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 +1478 -0
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +4633 -0
  5. package/WAProto/fix-imports.js +29 -0
  6. package/WAProto/index.d.ts +37016 -0
  7. package/WAProto/index.js +169659 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/index.d.ts +62 -0
  10. package/lib/Defaults/index.d.ts.map +1 -0
  11. package/lib/Defaults/index.js +115 -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 +342 -0
  64. package/lib/Signal/libsignal.js.map +1 -0
  65. package/lib/Signal/lid-mapping.d.ts +23 -0
  66. package/lib/Signal/lid-mapping.d.ts.map +1 -0
  67. package/lib/Signal/lid-mapping.js +171 -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 +50 -0
  80. package/lib/Socket/Client/websocket.js.map +1 -0
  81. package/lib/Socket/business.d.ts +188 -0
  82. package/lib/Socket/business.d.ts.map +1 -0
  83. package/lib/Socket/business.js +376 -0
  84. package/lib/Socket/business.js.map +1 -0
  85. package/lib/Socket/chats.d.ts +98 -0
  86. package/lib/Socket/chats.d.ts.map +1 -0
  87. package/lib/Socket/chats.js +962 -0
  88. package/lib/Socket/chats.js.map +1 -0
  89. package/lib/Socket/communities.d.ts +244 -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 +137 -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/hydra.d.ts +174 -0
  98. package/lib/Socket/hydra.js +715 -0
  99. package/lib/Socket/index.d.ts +231 -0
  100. package/lib/Socket/index.d.ts.map +1 -0
  101. package/lib/Socket/index.js +18 -0
  102. package/lib/Socket/index.js.map +1 -0
  103. package/lib/Socket/messages-recv.d.ts +173 -0
  104. package/lib/Socket/messages-recv.d.ts.map +1 -0
  105. package/lib/Socket/messages-recv.js +1228 -0
  106. package/lib/Socket/messages-recv.js.map +1 -0
  107. package/lib/Socket/messages-send.d.ts +169 -0
  108. package/lib/Socket/messages-send.d.ts.map +1 -0
  109. package/lib/Socket/messages-send.js +1367 -0
  110. package/lib/Socket/messages-send.js.map +1 -0
  111. package/lib/Socket/mex.d.ts +3 -0
  112. package/lib/Socket/mex.d.ts.map +1 -0
  113. package/lib/Socket/mex.js +42 -0
  114. package/lib/Socket/mex.js.map +1 -0
  115. package/lib/Socket/newsletter.d.ts +147 -0
  116. package/lib/Socket/newsletter.d.ts.map +1 -0
  117. package/lib/Socket/newsletter.js +181 -0
  118. package/lib/Socket/newsletter.js.map +1 -0
  119. package/lib/Socket/socket.d.ts +51 -0
  120. package/lib/Socket/socket.d.ts.map +1 -0
  121. package/lib/Socket/socket.js +841 -0
  122. package/lib/Socket/socket.js.map +1 -0
  123. package/lib/Store/index.d.ts +4 -0
  124. package/lib/Store/index.js +4 -0
  125. package/lib/Store/make-cache-manager-store.d.ts +14 -0
  126. package/lib/Store/make-cache-manager-store.js +81 -0
  127. package/lib/Store/make-in-memory-store.d.ts +123 -0
  128. package/lib/Store/make-in-memory-store.js +416 -0
  129. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  130. package/lib/Store/make-ordered-dictionary.js +82 -0
  131. package/lib/Store/object-repository.d.ts +10 -0
  132. package/lib/Store/object-repository.js +31 -0
  133. package/lib/Types/Auth.d.ts +111 -0
  134. package/lib/Types/Auth.d.ts.map +1 -0
  135. package/lib/Types/Auth.js +2 -0
  136. package/lib/Types/Auth.js.map +1 -0
  137. package/lib/Types/Bussines.d.ts +25 -0
  138. package/lib/Types/Bussines.d.ts.map +1 -0
  139. package/lib/Types/Bussines.js +2 -0
  140. package/lib/Types/Bussines.js.map +1 -0
  141. package/lib/Types/Call.d.ts +14 -0
  142. package/lib/Types/Call.d.ts.map +1 -0
  143. package/lib/Types/Call.js +2 -0
  144. package/lib/Types/Call.js.map +1 -0
  145. package/lib/Types/Chat.d.ts +123 -0
  146. package/lib/Types/Chat.d.ts.map +1 -0
  147. package/lib/Types/Chat.js +8 -0
  148. package/lib/Types/Chat.js.map +1 -0
  149. package/lib/Types/Contact.d.ts +24 -0
  150. package/lib/Types/Contact.d.ts.map +1 -0
  151. package/lib/Types/Contact.js +2 -0
  152. package/lib/Types/Contact.js.map +1 -0
  153. package/lib/Types/Events.d.ts +202 -0
  154. package/lib/Types/Events.d.ts.map +1 -0
  155. package/lib/Types/Events.js +2 -0
  156. package/lib/Types/Events.js.map +1 -0
  157. package/lib/Types/GroupMetadata.d.ts +67 -0
  158. package/lib/Types/GroupMetadata.d.ts.map +1 -0
  159. package/lib/Types/GroupMetadata.js +2 -0
  160. package/lib/Types/GroupMetadata.js.map +1 -0
  161. package/lib/Types/Label.d.ts +47 -0
  162. package/lib/Types/Label.d.ts.map +1 -0
  163. package/lib/Types/Label.js +25 -0
  164. package/lib/Types/Label.js.map +1 -0
  165. package/lib/Types/LabelAssociation.d.ts +30 -0
  166. package/lib/Types/LabelAssociation.d.ts.map +1 -0
  167. package/lib/Types/LabelAssociation.js +7 -0
  168. package/lib/Types/LabelAssociation.js.map +1 -0
  169. package/lib/Types/Message.d.ts +303 -0
  170. package/lib/Types/Message.d.ts.map +1 -0
  171. package/lib/Types/Message.js +11 -0
  172. package/lib/Types/Message.js.map +1 -0
  173. package/lib/Types/Newsletter.d.ts +135 -0
  174. package/lib/Types/Newsletter.d.ts.map +1 -0
  175. package/lib/Types/Newsletter.js +31 -0
  176. package/lib/Types/Newsletter.js.map +1 -0
  177. package/lib/Types/Product.d.ts +79 -0
  178. package/lib/Types/Product.d.ts.map +1 -0
  179. package/lib/Types/Product.js +2 -0
  180. package/lib/Types/Product.js.map +1 -0
  181. package/lib/Types/Signal.d.ts +76 -0
  182. package/lib/Types/Signal.d.ts.map +1 -0
  183. package/lib/Types/Signal.js +2 -0
  184. package/lib/Types/Signal.js.map +1 -0
  185. package/lib/Types/Socket.d.ts +133 -0
  186. package/lib/Types/Socket.d.ts.map +1 -0
  187. package/lib/Types/Socket.js +3 -0
  188. package/lib/Types/Socket.js.map +1 -0
  189. package/lib/Types/State.d.ts +39 -0
  190. package/lib/Types/State.d.ts.map +1 -0
  191. package/lib/Types/State.js +13 -0
  192. package/lib/Types/State.js.map +1 -0
  193. package/lib/Types/USync.d.ts +26 -0
  194. package/lib/Types/USync.d.ts.map +1 -0
  195. package/lib/Types/USync.js +2 -0
  196. package/lib/Types/USync.js.map +1 -0
  197. package/lib/Types/index.d.ts +65 -0
  198. package/lib/Types/index.d.ts.map +1 -0
  199. package/lib/Types/index.js +26 -0
  200. package/lib/Types/index.js.map +1 -0
  201. package/lib/Utils/auth-utils.d.ts +19 -0
  202. package/lib/Utils/auth-utils.d.ts.map +1 -0
  203. package/lib/Utils/auth-utils.js +257 -0
  204. package/lib/Utils/auth-utils.js.map +1 -0
  205. package/lib/Utils/baileys-event-stream.d.ts +17 -0
  206. package/lib/Utils/baileys-event-stream.d.ts.map +1 -0
  207. package/lib/Utils/baileys-event-stream.js +56 -0
  208. package/lib/Utils/baileys-event-stream.js.map +1 -0
  209. package/lib/Utils/browser-utils.d.ts +4 -0
  210. package/lib/Utils/browser-utils.d.ts.map +1 -0
  211. package/lib/Utils/browser-utils.js +28 -0
  212. package/lib/Utils/browser-utils.js.map +1 -0
  213. package/lib/Utils/business.d.ts +23 -0
  214. package/lib/Utils/business.d.ts.map +1 -0
  215. package/lib/Utils/business.js +231 -0
  216. package/lib/Utils/business.js.map +1 -0
  217. package/lib/Utils/chat-utils.d.ts +70 -0
  218. package/lib/Utils/chat-utils.d.ts.map +1 -0
  219. package/lib/Utils/chat-utils.js +763 -0
  220. package/lib/Utils/chat-utils.js.map +1 -0
  221. package/lib/Utils/crypto.d.ts +41 -0
  222. package/lib/Utils/crypto.d.ts.map +1 -0
  223. package/lib/Utils/crypto.js +142 -0
  224. package/lib/Utils/crypto.js.map +1 -0
  225. package/lib/Utils/decode-wa-message.d.ts +48 -0
  226. package/lib/Utils/decode-wa-message.d.ts.map +1 -0
  227. package/lib/Utils/decode-wa-message.js +279 -0
  228. package/lib/Utils/decode-wa-message.js.map +1 -0
  229. package/lib/Utils/event-buffer.d.ts +34 -0
  230. package/lib/Utils/event-buffer.d.ts.map +1 -0
  231. package/lib/Utils/event-buffer.js +548 -0
  232. package/lib/Utils/event-buffer.js.map +1 -0
  233. package/lib/Utils/generics.d.ts +90 -0
  234. package/lib/Utils/generics.d.ts.map +1 -0
  235. package/lib/Utils/generics.js +381 -0
  236. package/lib/Utils/generics.js.map +1 -0
  237. package/lib/Utils/history.d.ts +19 -0
  238. package/lib/Utils/history.d.ts.map +1 -0
  239. package/lib/Utils/history.js +84 -0
  240. package/lib/Utils/history.js.map +1 -0
  241. package/lib/Utils/index.d.ts +20 -0
  242. package/lib/Utils/index.d.ts.map +1 -0
  243. package/lib/Utils/index.js +20 -0
  244. package/lib/Utils/index.js.map +1 -0
  245. package/lib/Utils/link-preview.d.ts +21 -0
  246. package/lib/Utils/link-preview.d.ts.map +1 -0
  247. package/lib/Utils/link-preview.js +85 -0
  248. package/lib/Utils/link-preview.js.map +1 -0
  249. package/lib/Utils/logger.d.ts +12 -0
  250. package/lib/Utils/logger.d.ts.map +1 -0
  251. package/lib/Utils/logger.js +3 -0
  252. package/lib/Utils/logger.js.map +1 -0
  253. package/lib/Utils/lt-hash.d.ts +13 -0
  254. package/lib/Utils/lt-hash.d.ts.map +1 -0
  255. package/lib/Utils/lt-hash.js +48 -0
  256. package/lib/Utils/lt-hash.js.map +1 -0
  257. package/lib/Utils/make-mutex.d.ts +8 -0
  258. package/lib/Utils/make-mutex.d.ts.map +1 -0
  259. package/lib/Utils/make-mutex.js +40 -0
  260. package/lib/Utils/make-mutex.js.map +1 -0
  261. package/lib/Utils/message-retry-manager.d.ts +82 -0
  262. package/lib/Utils/message-retry-manager.d.ts.map +1 -0
  263. package/lib/Utils/message-retry-manager.js +149 -0
  264. package/lib/Utils/message-retry-manager.js.map +1 -0
  265. package/lib/Utils/messages-media.d.ts +114 -0
  266. package/lib/Utils/messages-media.d.ts.map +1 -0
  267. package/lib/Utils/messages-media.js +684 -0
  268. package/lib/Utils/messages-media.js.map +1 -0
  269. package/lib/Utils/messages.d.ts +76 -0
  270. package/lib/Utils/messages.d.ts.map +1 -0
  271. package/lib/Utils/messages.js +820 -0
  272. package/lib/Utils/messages.js.map +1 -0
  273. package/lib/Utils/noise-handler.d.ts +20 -0
  274. package/lib/Utils/noise-handler.d.ts.map +1 -0
  275. package/lib/Utils/noise-handler.js +147 -0
  276. package/lib/Utils/noise-handler.js.map +1 -0
  277. package/lib/Utils/pre-key-manager.d.ts +28 -0
  278. package/lib/Utils/pre-key-manager.d.ts.map +1 -0
  279. package/lib/Utils/pre-key-manager.js +106 -0
  280. package/lib/Utils/pre-key-manager.js.map +1 -0
  281. package/lib/Utils/process-message.d.ts +42 -0
  282. package/lib/Utils/process-message.d.ts.map +1 -0
  283. package/lib/Utils/process-message.js +413 -0
  284. package/lib/Utils/process-message.js.map +1 -0
  285. package/lib/Utils/signal.d.ts +34 -0
  286. package/lib/Utils/signal.d.ts.map +1 -0
  287. package/lib/Utils/signal.js +159 -0
  288. package/lib/Utils/signal.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 +195 -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 +238 -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 +216 -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 +111 -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 +13 -0
  382. package/lib/index.d.ts.map +1 -0
  383. package/lib/index.js +12 -0
  384. package/lib/index.js.map +1 -0
  385. package/package.json +104 -0
package/README.md ADDED
@@ -0,0 +1,1478 @@
1
+ <!-- PROJECT HEADER -->
2
+ <div align="center">
3
+ <img src="https://files.catbox.moe/68wa8k.jpg" alt="WhatsApp Web API" width="600"/>
4
+
5
+ # WhatsApp Web API
6
+ **Advanced Baileys WhatsApp API Wrapper**
7
+
8
+ [![NPM Version](https://img.shields.io/npm/v/@kelvdra/baileys?color=brightgreen&label=NPM)](https://www.npmjs.com/package/@kelvdra/bails)
9
+ [![Downloads](https://img.shields.io/npm/dw/@kelvdra/baileys?color=blue&label=Downloads)](https://www.npmjs.com/package/@kelvdra/bails)
10
+ [![License](https://img.shields.io/github/license/kelvdra/baileys?color=yellow)](./LICENSE)
11
+
12
+ ---
13
+ A modern and feature-rich WhatsApp Web API built on top of **Baileys** —
14
+ designed for automation, chatbots, and integration with any Node.js project.
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## 📑 Table of Contents
20
+ - [⚡ Quick Start](#-quick-start)
21
+ - [📦 Installation](#-installation)
22
+ - [🔌 Connecting Account](#-connecting-account)
23
+ - [💡 Important Notes](#-important-notes-about-socket-config)
24
+ - [💾 Saving & Restoring Sessions](#-saving--restoring-sessions)
25
+ - [📡 Handling Events](#-handling-events)
26
+ - [🛠 Implementing a Data Store](#-implementing-a-data-store)
27
+ - [🔑 WhatsApp IDs](#-whatsapp-ids-explain)
28
+ - [✉️ Sending Messages](#-sending-messages)
29
+ - [Non-Media Messages](#non-media-messages)
30
+ - [Text Message](#text-message)
31
+ - [Quote Message](#quote-message-works-with-all-types)
32
+ - [Mention User](#mention-user-works-with-most-types)
33
+ - [Mention Status](#mention-status)
34
+ - [Result Poll From Newsletter](#result-poll-from-newsletter)
35
+ - [SendAlbumMessage](#send-album-message)
36
+ - [SendMessage Product Simple](#SendMessage-Product-Simple)
37
+ - [SendMessage Carousel](#sendMessage-Carousel)
38
+ - [Request Payment](#request-payment)
39
+ - [Event Message](#event-message)
40
+ - [Interactive](#interactive)
41
+ - [Forward Messages](#forward-messages)
42
+ - [Location Message](#location-message)
43
+ - [Contact Message](#contact-message)
44
+ - [Reaction Message](#reaction-message)
45
+ - [Pin Message](#pin-message)
46
+ - [Keep Message](#keep-message)
47
+ - [Poll Message](#poll-message)
48
+ - [Sending with Link Preview](#sending-messages-with-link-previews)
49
+ - [🖼 Media Messages](#-media-messages)
50
+ - [Gif Message](#gif-message)
51
+ - [Video Message](#video-message)
52
+ - [Audio Message](#audio-message)
53
+ - [Image Message](#image-message)
54
+ - [ViewOnce Message](#view-once-message)
55
+ - [✏️ Modify Messages](#-modify-messages)
56
+ - [📥 Downloading & Re-uploading Media](#-manipulating-media-messages)
57
+ - [📞 Call & Presence Handling](#-reject-call)
58
+ - [💬 Chat Modifications](#-modifying-chats)
59
+ - [🔍 User Queries](#-user-querys)
60
+ - [👤 Profile Management](#-change-profile)
61
+ - [👥 Group Management](#-groups)
62
+ - [🔒 Privacy Controls](#-privacy)
63
+ - [📢 Broadcast & Stories](#-broadcast-lists--stories)
64
+ - [🧩 Custom Functionality](#-writing-custom-functionality)
65
+
66
+ ---
67
+
68
+ ## ⚡ Quick Start
69
+
70
+ Example usage:
71
+
72
+ ```bash
73
+ cd path/to/Baileys
74
+ npm install
75
+ node example.js
76
+ ```
77
+
78
+ Or check the **[example.ts](Example/example.ts)** for a TypeScript version.
79
+
80
+ ---
81
+
82
+ ## 📦 Installation
83
+
84
+ **Stable version**
85
+ ```bash
86
+ npm install @kelvdra/baileys
87
+ ```
88
+
89
+ **Edge version** (latest features, may be unstable)
90
+ ```bash
91
+ yarn add @kelvdra/baileys@latest
92
+ ```
93
+
94
+ **Import into your code**
95
+ ```javascript
96
+ const { default: makeWASocket } = require("@kelvdra/baileys")
97
+ ```
98
+
99
+ > ⚠️ **Tip:** Use the stable version for production environments.
100
+
101
+ ---
102
+
103
+ ## 🔌 Connecting Account
104
+
105
+ WhatsApp supports **multi-device API**, allowing Baileys to act as a secondary WhatsApp Web client.
106
+ You can connect via **QR Code** or **Pairing Code**.
107
+
108
+ ### 📷 QR Code Login
109
+ ```javascript
110
+ const { default: makeWASocket, Browsers } = require("@kelvdra/baileys");
111
+
112
+ const sock = makeWASocket({
113
+ browser: Browsers.ubuntu('My App'),
114
+ printQRInTerminal: true
115
+ });
116
+ ```
117
+ > 💡 Scan the QR code with WhatsApp on your phone to log in.
118
+
119
+ ### 🔑 Pairing Code Login
120
+ ```javascript
121
+ const { default: makeWASocket } = require("@kelvdra/baileys");
122
+
123
+ const sock = makeWASocket({
124
+ printQRInTerminal: false
125
+ });
126
+
127
+ if (!sock.authState.creds.registered) {
128
+ const number = '6281234567890'; // no symbols, only numbers
129
+ const code = await sock.requestPairingCode(number);
130
+ console.log(code);
131
+ }
132
+ ```
133
+ > ⚠️ **Note:** Pairing code works only with one device at a time.
134
+
135
+ ---
136
+
137
+ ## 💡 Important Notes About Socket Config
138
+
139
+ ### 📌 Cache Group Metadata
140
+ ```javascript
141
+ const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false });
142
+
143
+ const sock = makeWASocket({
144
+ cachedGroupMetadata: async (jid) => groupCache.get(jid)
145
+ });
146
+ ```
147
+
148
+ ### 🔄 Improve Retry & Poll Decryption
149
+ ```javascript
150
+ const sock = makeWASocket({
151
+ getMessage: async (key) => await getMessageFromStore(key)
152
+ });
153
+ ```
154
+
155
+ ### 📱 Receive Notifications in WhatsApp App
156
+ ```javascript
157
+ const sock = makeWASocket({
158
+ markOnlineOnConnect: false
159
+ });
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 💾 Saving & Restoring Sessions
165
+
166
+ Avoid scanning QR every time:
167
+ ```javascript
168
+ const makeWASocket = require("@kelvdra/baileys").default;
169
+ const { useMultiFileAuthState } = require("@kelvdra/baileys");
170
+
171
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys');
172
+ const sock = makeWASocket({ auth: state });
173
+
174
+ sock.ev.on('creds.update', saveCreds);
175
+ ```
176
+ > 💡 Recommended to store auth in a database for production.
177
+
178
+ ---
179
+
180
+ ## 📡 Handling Events
181
+
182
+ Listen to events using:
183
+ ```javascript
184
+ sock.ev.on('messages.upsert', ({ messages }) => {
185
+ console.log('got messages', messages);
186
+ });
187
+ ```
188
+
189
+ ### Example to Start
190
+
191
+ > [!NOTE]
192
+ > This example includes basic auth storage too
193
+
194
+ ```javascript
195
+ const makeWASocket = require("@kelvdra/baileys").default;
196
+ const { DisconnectReason, useMultiFileAuthState } = require("@kelvdra/baileys");
197
+ const Boom = require('@hapi/boom');
198
+
199
+ async function connectToWhatsApp () {
200
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
201
+ const sock = makeWASocket({
202
+ // can provide additional config here
203
+ auth: state,
204
+ printQRInTerminal: true
205
+ })
206
+ sock.ev.on('connection.update', (update) => {
207
+ const { connection, lastDisconnect } = update
208
+ if(connection === 'close') {
209
+ const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
210
+ console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
211
+ // reconnect if not logged out
212
+ if(shouldReconnect) {
213
+ connectToWhatsApp()
214
+ }
215
+ } else if(connection === 'open') {
216
+ console.log('opened connection')
217
+ }
218
+ })
219
+ sock.ev.on('messages.upsert', event => {
220
+ for (const m of event.messages) {
221
+ console.log(JSON.stringify(m, undefined, 2))
222
+
223
+ console.log('replying to', m.key.remoteJid)
224
+ await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
225
+ }
226
+ })
227
+
228
+ // to storage creds (session info) when it updates
229
+ sock.ev.on('creds.update', saveCreds)
230
+ }
231
+ // run in main file
232
+ connectToWhatsApp()
233
+ ```
234
+
235
+ > [!IMPORTANT]
236
+ > In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
237
+
238
+ ### Decrypt Poll Votes
239
+
240
+ - By default poll votes are encrypted and handled in `messages.update`
241
+ - That's a simple example
242
+ ```javascript
243
+ sock.ev.on('messages.update', event => {
244
+ for(const { key, update } of event) {
245
+ if(update.pollUpdates) {
246
+ const pollCreation = await getMessage(key)
247
+ if(pollCreation) {
248
+ console.log(
249
+ 'got poll update, aggregation: ',
250
+ getAggregateVotesInPollMessage({
251
+ message: pollCreation,
252
+ pollUpdates: update.pollUpdates,
253
+ })
254
+ )
255
+ }
256
+ }
257
+ }
258
+ })
259
+ ```
260
+
261
+ - `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
262
+
263
+ ### Summary of Events on First Connection
264
+
265
+ 1. When you connect first time, `connection.update` will be fired requesting you to restart sock
266
+ 2. Then, history messages will be received in `messaging.history-set`
267
+
268
+ ## Implementing a Data Store
269
+
270
+ - 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.
271
+
272
+ > [!IMPORTANT]
273
+ > I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
274
+
275
+ It can be used as follows:
276
+
277
+ ```javascript
278
+ const makeWASocket = require("@kelvdra/baileys").default;
279
+ const { makeInMemoryStore } = require("@kelvdra/baileys");
280
+ // the store maintains the data of the WA connection in memory
281
+ // can be written out to a file & read from it
282
+ const store = makeInMemoryStore({ })
283
+ // can be read from a file
284
+ store.readFromFile('./baileys_store.json')
285
+ // saves the state to a file every 10s
286
+ setInterval(() => {
287
+ store.writeToFile('./baileys_store.json')
288
+ }, 10_000)
289
+
290
+ const sock = makeWASocket({ })
291
+ // will listen from this socket
292
+ // the store can listen from a new socket once the current socket outlives its lifetime
293
+ store.bind(sock.ev)
294
+
295
+ sock.ev.on('chats.upsert', () => {
296
+ // can use 'store.chats' however you want, even after the socket dies out
297
+ // 'chats' => a KeyedDB instance
298
+ console.log('got chats', store.chats.all())
299
+ })
300
+
301
+ sock.ev.on('contacts.upsert', () => {
302
+ console.log('got contacts', Object.values(store.contacts))
303
+ })
304
+
305
+ ```
306
+
307
+ The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
308
+
309
+ ## Whatsapp IDs Explain
310
+
311
+ - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
312
+ - It must be in the format ```[country code][phone number]@s.whatsapp.net```
313
+ - Example for people: ```+19999999999@s.whatsapp.net```.
314
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
315
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
316
+ - For stories, the ID is `status@broadcast`.
317
+
318
+ ## Utility Functions
319
+
320
+ - `getContentType`, returns the content type for any message
321
+ - `getDevice`, returns the device from message
322
+ - `makeCacheableSignalKeyStore`, make auth store more fast
323
+ - `downloadContentFromMessage`, download content from any message
324
+
325
+ ## Sending Messages
326
+
327
+ - Send all types of messages with a single function
328
+ - **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
329
+ - **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
330
+
331
+ ```javascript
332
+ const jid: string
333
+ const content: AnyMessageContent
334
+ const options: MiscMessageGenerationOptions
335
+
336
+ sock.sendMessage(jid, content, options)
337
+ ```
338
+
339
+ ### Non-Media Messages
340
+
341
+
342
+ #### Text Message
343
+ ```javascript
344
+ await sock.sendMessage(jid, { text: 'hello word' })
345
+ ```
346
+
347
+ #### Quote Message (works with all types)
348
+ ```javascript
349
+ await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
350
+ ```
351
+
352
+ #### Mention User (works with most types)
353
+ - @number is to mention in text, it's optional
354
+ ```javascript
355
+ await sock.sendMessage(
356
+ jid,
357
+ {
358
+ text: '@12345678901',
359
+ mentions: ['12345678901@s.whatsapp.net']
360
+ }
361
+ )
362
+ ```
363
+
364
+ #### Mention Status
365
+ - [ jid ] If the Jid Group and Jid Private Chat are included in the JID list, try to make the JID group first starting from the Jid Private Chat or Jid Private Chat in the middle between the group Jid
366
+ ```javascript
367
+ await sock.sendStatusMentions(
368
+ {
369
+ text: "Hello", // or image / video / audio ( url or buffer )
370
+ },
371
+ [
372
+ "123456789123456789@g.us",
373
+ "123456789@s.whatsapp.net",
374
+ // Enter jid chat here
375
+ ]
376
+ )
377
+ ```
378
+
379
+ #### Result Poll From Newsletter
380
+ ```javascript
381
+ await sock.sendMessage(
382
+ jid,
383
+ {
384
+ pollResult: {
385
+ name: "Text poll",
386
+ votes: [["Options 1", 10], ["Options 2", 10]], // 10 For Fake Polling Count Results
387
+ }
388
+ }, { quoted : message }
389
+ )
390
+ ```
391
+
392
+ #### Send Album Message
393
+ - url or buffer ( image or video )
394
+ ```javascript
395
+ await sock.sendAlbumMessage(
396
+ jid,
397
+ [
398
+ {
399
+ image: { url: "https://example.jpg" }, // or buffer
400
+ caption: "Hello World",
401
+ },
402
+ {
403
+ video: { url: "https://example.mp4" }, // or buffer
404
+ caption: "Hello World",
405
+ },
406
+ ],
407
+ {
408
+ quoted : message,
409
+ delay : 2000 // number in seconds
410
+ }
411
+ )
412
+
413
+ ```
414
+
415
+ #### Request Payment
416
+ ```javascript
417
+ - Example non media sticker
418
+ await sock.sendMessage(
419
+ jid,
420
+ {
421
+ requestPayment: {
422
+ currency: "IDR",
423
+ amount: "10000000",
424
+ from: "123456@s.whatsapp.net",
425
+ note: "Hai Guys",
426
+ background: { ...background of the message }
427
+ }
428
+ },
429
+ { quoted : message }
430
+ )
431
+
432
+ - with media sticker buffer
433
+ await sock.sendMessage(
434
+ jid,
435
+ {
436
+ requestPayment: {
437
+ currency: "IDR",
438
+ amount: "10000000",
439
+ from: "123456@s.whatsapp.net",
440
+ sticker: Buffer,
441
+ background: { ...background of the message }
442
+ }
443
+ },
444
+ { quoted : message }
445
+ )
446
+
447
+ - with media sticker url
448
+ await sock.sendMessage(
449
+ jid,
450
+ {
451
+ requestPayment: {
452
+ currency: "IDR",
453
+ amount: "10000000",
454
+ from: "123456@s.whatsapp.net",
455
+ sticker: { url: Sticker Url },
456
+ background: { ...background of the message }
457
+ }
458
+ },
459
+ { quoted : message }
460
+ )
461
+ ```
462
+
463
+ #### Event Message
464
+ ```javascript
465
+ await sock.sendMessage(
466
+ jid,
467
+ {
468
+ event: {
469
+ isCanceled: false, // or true for cancel event
470
+ name: "Name Event",
471
+ description: "Description Event",
472
+ location: {
473
+ degressLatitude: -0,
474
+ degressLongitude: - 0
475
+ },
476
+ link: Call Link,
477
+ startTime: m.messageTimestamp.low,
478
+ endTime: m.messageTimestamp.low + 86400, // 86400 is day in seconds
479
+ extraGuestsAllowed: true // or false
480
+ }
481
+ },
482
+ { quoted : message }
483
+ )
484
+ ```
485
+
486
+ ### SendMessage Product Simple
487
+ ```javascript
488
+ conn.sendMessage(m.chat, {
489
+ productMessage: {
490
+ title: "tes",
491
+ description: "penis",
492
+ thumbnail: "https://example.png",
493
+ productId: "123456789",
494
+ retailerId: "TOKOKU",
495
+ url: "https://example.png",
496
+ body: "penis",
497
+ footer: "wabot",
498
+ buttons: [
499
+ {
500
+ name: "cta_url",
501
+ buttonParamsJson: JSON.stringify({
502
+ display_text: "K",
503
+ url: "google.com"
504
+ })
505
+ }
506
+ ]
507
+ }
508
+ }, { quoted: m });
509
+ ```
510
+ ### SendMessage Carousel
511
+ ```javascript
512
+ func nya kyk gini, nanti ku taro ke readme
513
+ await conn.sendMessage(
514
+ m.chat,
515
+ {
516
+ carouselMessage: {
517
+ caption: "Klik Url",
518
+ footer: "Powered By Hydra",
519
+ cards: [
520
+ // ✅ Card Mode Product
521
+ {
522
+ headerTitle: "`</> Owner Bot </>`",
523
+ imageUrl: logo.thumb,
524
+ productTitle: "Premium Bot",
525
+ productDescription: "Dapatkan akses premium",
526
+ bodyText: "[Hydra]\n- Chat yang penting aja\n- Jangan telpon owner",
527
+ buttons: [
528
+ {
529
+ name: "cta_call",
530
+ params: { display_text: "Contact Owner", phone_number: "+6287784901856" }
531
+ }
532
+ ]
533
+ },
534
+ // ✅ Card Mode Gambar Biasa
535
+ {
536
+ headerTitle: "`</> Bot Elaina </>`",
537
+ imageUrl: logo.thumb,
538
+ bodyText: "[Elaina AI]\n- Jangan spam bot\n- Jangan telpon bot",
539
+ buttons: [
540
+ {
541
+ name: "cta_url",
542
+ params: {
543
+ display_text: "Chat Bot",
544
+ url: "https://wa.me/6281918402014",
545
+ merchant_url: "https://wa.me/6281918402014"
546
+ }
547
+ }
548
+ ]
549
+ }
550
+ ]
551
+ }
552
+ },
553
+ { quoted: m },
554
+ conn
555
+ );
556
+ ```
557
+
558
+ #### Interactive
559
+ ```javascript
560
+ - Example non header media
561
+ await sock.sendMessage(
562
+ jid,
563
+ {
564
+ text: "Description Of Messages", //Additional information
565
+ title: "Title Of Messages",
566
+ subtitle: "Subtitle Message",
567
+ footer: "Footer Messages",
568
+ interactiveButtons: [
569
+ {
570
+ name: "quick_reply",
571
+ buttonParamsJson: JSON.stringify({
572
+ display_text: "Display Button",
573
+ id: "ID"
574
+ })
575
+ },
576
+ {
577
+ name: "cta_url",
578
+ buttonParamsJson: JSON.stringify({
579
+ display_text: "Display Button",
580
+ url: "https://www.example.com"
581
+ })
582
+ }
583
+ ]
584
+ },
585
+ { quoted : message }
586
+ )
587
+
588
+ - Example with media
589
+ await sock.sendMessage(
590
+ jid,
591
+ {
592
+ image: { url : "https://example.jpg" }, // Can buffer
593
+ caption: "Description Of Messages", //Additional information
594
+ title: "Title Of Messages",
595
+ subtitle: "Subtile Message",
596
+ footer: "Footer Messages",
597
+ media: true,
598
+ interactiveButtons: [
599
+ {
600
+ name: "quick_reply",
601
+ buttonParamsJson: JSON.stringify({
602
+ display_text: "Display Button",
603
+ id: "ID"
604
+ })
605
+ },
606
+ {
607
+ name: "cta_url",
608
+ buttonParamsJson: JSON.stringify({
609
+ display_text: "Display Button",
610
+ url: "https://www.example.com"
611
+ })
612
+ }
613
+ ]
614
+ },
615
+ { quoted : message }
616
+ )
617
+
618
+ - Example with header product
619
+ await sock.sendMessage(
620
+ jid,
621
+ {
622
+ product: {
623
+ productImage: { url: "https://example.jpg }, //or buffer
624
+ productImageCount: 1,
625
+ title: "Title Product",
626
+ description: "Description Product",
627
+ priceAmount1000: 20000 * 1000,
628
+ currencyCode: "IDR",
629
+ retailerId: "Retail",
630
+ url: "https://example.com",
631
+ },
632
+ businessOwnerJid: "1234@s.whatsapp.net",
633
+ caption: "Description Of Messages", //Additional information
634
+ title: "Title Of Messages",
635
+ footer: "Footer Messages",
636
+ media: true,
637
+ interactiveButtons: [
638
+ {
639
+ name: "quick_reply",
640
+ buttonParamsJson: JSON.stringify({
641
+ display_text: "Display Button",
642
+ id: "ID"
643
+ })
644
+ },
645
+ {
646
+ name: "cta_url",
647
+ buttonParamsJson: JSON.stringify({
648
+ display_text: "Display Button",
649
+ url: "https://www.example.com"
650
+ })
651
+ }
652
+ ]
653
+ },
654
+ { quoted : message }
655
+ )
656
+ ```
657
+
658
+ #### Forward Messages
659
+ - 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
660
+ ```javascript
661
+ const msg = getMessageFromStore() // implement this on your end
662
+ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
663
+ ```
664
+
665
+ #### Location Message
666
+ ```javascript
667
+ await sock.sendMessage(
668
+ jid,
669
+ {
670
+ location: {
671
+ degreesLatitude: 24.121231,
672
+ degreesLongitude: 55.1121221
673
+ }
674
+ }
675
+ )
676
+ ```
677
+ #### Contact Message
678
+ ```javascript
679
+ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
680
+ + 'VERSION:3.0\n'
681
+ + 'FN:Jeff Singh\n' // full name
682
+ + 'ORG:Ashoka Uni;\n' // the organization of the contact
683
+ + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
684
+ + 'END:VCARD'
685
+
686
+ await sock.sendMessage(
687
+ id,
688
+ {
689
+ contacts: {
690
+ displayName: 'Jeff',
691
+ contacts: [{ vcard }]
692
+ }
693
+ }
694
+ )
695
+ ```
696
+
697
+ #### Reaction Message
698
+ - 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
699
+ ```javascript
700
+ await sock.sendMessage(
701
+ jid,
702
+ {
703
+ react: {
704
+ text: '💖', // use an empty string to remove the reaction
705
+ key: message.key
706
+ }
707
+ }
708
+ )
709
+ ```
710
+
711
+ #### Pin Message
712
+ - 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
713
+
714
+ - Time can be:
715
+
716
+ | Time | Seconds |
717
+ |-------|----------------|
718
+ | 24h | 86.400 |
719
+ | 7d | 604.800 |
720
+ | 30d | 2.592.000 |
721
+
722
+ ```javascript
723
+ await sock.sendMessage(
724
+ jid,
725
+ {
726
+ pin: {
727
+ type: 1, // 0 to remove
728
+ time: 86400
729
+ key: message.key
730
+ }
731
+ }
732
+ )
733
+ ```
734
+
735
+ #### Keep Message
736
+ - 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
737
+
738
+ - Time can be:
739
+
740
+ | Time | Seconds |
741
+ |-------|----------------|
742
+ | 24h | 86.400 |
743
+ | 7d | 604.800 |
744
+ | 30d | 2.592.000 |
745
+
746
+ ```javascript
747
+ await sock.sendMessage(
748
+ jid,
749
+ {
750
+ keep: message.key,
751
+ type: 1, // 2 to unpin
752
+ time: 86400
753
+ }
754
+ )
755
+ ```
756
+
757
+ #### Poll Message
758
+ ```javascript
759
+ await sock.sendMessage(
760
+ jid,
761
+ {
762
+ poll: {
763
+ name: 'My Poll',
764
+ values: ['Option 1', 'Option 2', ...],
765
+ selectableCount: 1,
766
+ toAnnouncementGroup: false // or true
767
+ }
768
+ }
769
+ )
770
+ ```
771
+
772
+ ### Sending Messages with Link Previews
773
+
774
+ 1. By default, wa does not have link generation when sent from the web
775
+ 2. Baileys has a function to generate the content for these link previews
776
+ 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
777
+ 4. Send a link:
778
+ ```javascript
779
+ await sock.sendMessage(
780
+ jid,
781
+ {
782
+ text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
783
+ }
784
+ )
785
+ ```
786
+
787
+ ### Media Messages
788
+
789
+ Sending media (video, stickers, images) is easier & more efficient than ever.
790
+
791
+ > [!NOTE]
792
+ > 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)
793
+
794
+ - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
795
+
796
+ > [!TIP]
797
+ > It's recommended to use Stream or Url to save memory
798
+
799
+ #### Gif Message
800
+ - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
801
+ ```javascript
802
+ await sock.sendMessage(
803
+ jid,
804
+ {
805
+ video: fs.readFileSync('Media/ma_gif.mp4'),
806
+ caption: 'hello word',
807
+ gifPlayback: true
808
+ }
809
+ )
810
+ ```
811
+
812
+ #### Video Message
813
+ ```javascript
814
+ await sock.sendMessage(
815
+ id,
816
+ {
817
+ video: {
818
+ url: './Media/ma_gif.mp4'
819
+ },
820
+ caption: 'hello word',
821
+ ptv: false // if set to true, will send as a `video note`
822
+ }
823
+ )
824
+ ```
825
+
826
+ #### Audio Message
827
+ - To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
828
+ ```bash
829
+ codec: libopus //ogg file
830
+ ac: 1 //one channel
831
+ avoid_negative_ts
832
+ make_zero
833
+ ```
834
+ - Example:
835
+ ```bash
836
+ ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
837
+ ```
838
+ ```javascript
839
+ await sock.sendMessage(
840
+ jid,
841
+ {
842
+ audio: {
843
+ url: './Media/audio.mp3'
844
+ },
845
+ mimetype: 'audio/mp4'
846
+ }
847
+ )
848
+ ```
849
+
850
+ #### Image Message
851
+ ```javascript
852
+ await sock.sendMessage(
853
+ id,
854
+ {
855
+ image: {
856
+ url: './Media/ma_img.png'
857
+ },
858
+ caption: 'hello word'
859
+ }
860
+ )
861
+ ```
862
+
863
+ #### View Once Message
864
+
865
+ - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
866
+
867
+ ```javascript
868
+ await sock.sendMessage(
869
+ id,
870
+ {
871
+ image: {
872
+ url: './Media/ma_img.png'
873
+ },
874
+ viewOnce: true, //works with video, audio too
875
+ caption: 'hello word'
876
+ }
877
+ )
878
+ ```
879
+
880
+ ## Modify Messages
881
+
882
+ ### Deleting Messages (for everyone)
883
+
884
+ ```javascript
885
+ const msg = await sock.sendMessage(jid, { text: 'hello word' })
886
+ await sock.sendMessage(jid, { delete: msg.key })
887
+ ```
888
+
889
+ **Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
890
+
891
+ ### Editing Messages
892
+
893
+ - You can pass all editable contents here
894
+ ```javascript
895
+ await sock.sendMessage(jid, {
896
+ text: 'updated text goes here',
897
+ edit: response.key,
898
+ });
899
+ ```
900
+
901
+ ## Manipulating Media Messages
902
+
903
+ ### Thumbnail in Media Messages
904
+ - 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`.
905
+ - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
906
+
907
+ ### Downloading Media Messages
908
+
909
+ If you want to save the media you received
910
+ ```javascript
911
+ const { createWriteStream } = require('fs');
912
+ const { downloadMediaMessage, getContentType } = require("@kelvdra/baileys");
913
+
914
+ sock.ev.on('messages.upsert', async ({ [m] }) => {
915
+ if (!m.message) return // if there is no text or media message
916
+ const messageType = getContentType(m) // get what type of message it is (text, image, video...)
917
+
918
+ // if the message is an image
919
+ if (messageType === 'imageMessage') {
920
+ // download the message
921
+ const stream = await downloadMediaMessage(
922
+ m,
923
+ 'stream', // can be 'buffer' too
924
+ { },
925
+ {
926
+ logger,
927
+ // pass this so that baileys can request a reupload of media
928
+ // that has been deleted
929
+ reuploadRequest: sock.updateMediaMessage
930
+ }
931
+ )
932
+ // save to file
933
+ const writeStream = createWriteStream('./my-download.jpeg')
934
+ stream.pipe(writeStream)
935
+ }
936
+ }
937
+ ```
938
+
939
+ ### Re-upload Media Message to Whatsapp
940
+
941
+ - 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:
942
+ ```javascript
943
+ await sock.updateMediaMessage(msg)
944
+ ```
945
+
946
+ ## Reject Call
947
+
948
+ - You can obtain `callId` and `callFrom` from `call` event
949
+
950
+ ```javascript
951
+ await sock.rejectCall(callId, callFrom)
952
+ ```
953
+
954
+ ## Send States in Chat
955
+
956
+ ### Reading Messages
957
+ - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
958
+ - You cannot mark an entire 'chat' read as it were with Baileys Web.
959
+ This means you have to keep track of unread messages.
960
+
961
+ ```javascript
962
+ const key: WAMessageKey
963
+ // can pass multiple keys to read multiple messages as well
964
+ await sock.readMessages([key])
965
+ ```
966
+
967
+ The message ID is the unique identifier of the message that you are marking as read.
968
+ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
969
+
970
+ ### Update Presence
971
+
972
+ - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
973
+ - The presence expires after about 10 seconds.
974
+ - This lets the person/group with `jid` know whether you're online, offline, typing etc.
975
+
976
+ ```javascript
977
+ await sock.sendPresenceUpdate('available', jid)
978
+ ```
979
+
980
+ > [!NOTE]
981
+ > 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')`
982
+
983
+ ## Modifying Chats
984
+
985
+ WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
986
+
987
+ > [!IMPORTANT]
988
+ > 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.
989
+
990
+ ### Archive a Chat
991
+ ```javascript
992
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
993
+ await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
994
+ ```
995
+ ### Mute/Unmute a Chat
996
+
997
+ - Supported times:
998
+
999
+ | Time | Miliseconds |
1000
+ |-------|-----------------|
1001
+ | Remove | null |
1002
+ | 8h | 86.400.000 |
1003
+ | 7d | 604.800.000 |
1004
+
1005
+ ```javascript
1006
+ // mute for 8 hours
1007
+ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
1008
+ // unmute
1009
+ await sock.chatModify({ mute: null }, jid)
1010
+ ```
1011
+ ### Mark a Chat Read/Unread
1012
+ ```javascript
1013
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1014
+ // mark it unread
1015
+ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
1016
+ ```
1017
+
1018
+ ### Delete a Message for Me
1019
+ ```javascript
1020
+ await sock.chatModify(
1021
+ {
1022
+ clear: {
1023
+ messages: [
1024
+ {
1025
+ id: 'ATWYHDNNWU81732J',
1026
+ fromMe: true,
1027
+ timestamp: '1654823909'
1028
+ }
1029
+ ]
1030
+ }
1031
+ },
1032
+ jid
1033
+ )
1034
+
1035
+ ```
1036
+ ### Delete a Chat
1037
+ ```javascript
1038
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1039
+ await sock.chatModify({
1040
+ delete: true,
1041
+ lastMessages: [
1042
+ {
1043
+ key: lastMsgInChat.key,
1044
+ messageTimestamp: lastMsgInChat.messageTimestamp
1045
+ }
1046
+ ]
1047
+ },
1048
+ jid
1049
+ )
1050
+ ```
1051
+ ### Pin/Unpin a Chat
1052
+ ```javascript
1053
+ await sock.chatModify({
1054
+ pin: true // or `false` to unpin
1055
+ },
1056
+ jid
1057
+ )
1058
+ ```
1059
+ ### Star/Unstar a Message
1060
+ ```javascript
1061
+ await sock.chatModify({
1062
+ star: {
1063
+ messages: [
1064
+ {
1065
+ id: 'messageID',
1066
+ fromMe: true // or `false`
1067
+ }
1068
+ ],
1069
+ star: true // - true: Star Message; false: Unstar Message
1070
+ }
1071
+ },
1072
+ jid
1073
+ )
1074
+ ```
1075
+
1076
+ ### Disappearing Messages
1077
+
1078
+ - Ephemeral can be:
1079
+
1080
+ | Time | Seconds |
1081
+ |-------|----------------|
1082
+ | Remove | 0 |
1083
+ | 24h | 86.400 |
1084
+ | 7d | 604.800 |
1085
+ | 90d | 7.776.000 |
1086
+
1087
+ - You need to pass in **Seconds**, default is 7 days
1088
+
1089
+ ```javascript
1090
+ // turn on disappearing messages
1091
+ await sock.sendMessage(
1092
+ jid,
1093
+ // this is 1 week in seconds -- how long you want messages to appear for
1094
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
1095
+ )
1096
+
1097
+ // will send as a disappearing message
1098
+ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
1099
+
1100
+ // turn off disappearing messages
1101
+ await sock.sendMessage(
1102
+ jid,
1103
+ { disappearingMessagesInChat: false }
1104
+ )
1105
+ ```
1106
+
1107
+ ## User Querys
1108
+
1109
+ ### Check If ID Exists in Whatsapp
1110
+ ```javascript
1111
+ const [result] = await sock.onWhatsApp(jid)
1112
+ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
1113
+ ```
1114
+
1115
+ ### Query Chat History (groups too)
1116
+
1117
+ - You need to have oldest message in chat
1118
+ ```javascript
1119
+ const msg = await getOldestMessageInChat(jid)
1120
+ await sock.fetchMessageHistory(
1121
+ 50, //quantity (max: 50 per query)
1122
+ msg.key,
1123
+ msg.messageTimestamp
1124
+ )
1125
+ ```
1126
+ - Messages will be received in `messaging.history-set` event
1127
+
1128
+ ### Fetch User Lid
1129
+ ```javascript
1130
+ const jid = "123456789@s.whatsapp.net"
1131
+ const lid = await sock.fetchUserLid(jid)
1132
+ console.log('user lid: ' + lid)
1133
+ ```
1134
+
1135
+ ### Fetch Status
1136
+ ```javascript
1137
+ const status = await sock.fetchStatus(jid)
1138
+ console.log('status: ' + status)
1139
+ ```
1140
+
1141
+ ### Fetch Profile Picture (groups too)
1142
+ - To get the display picture of some person/group/newsletter
1143
+ ```javascript
1144
+ // for low res picture
1145
+ const ppUrl = await sock.profilePictureUrl(jid)
1146
+ console.log(ppUrl)
1147
+
1148
+ // for high res picture
1149
+ const ppUrl = await sock.profilePictureUrl(jid, 'image')
1150
+ ```
1151
+
1152
+ ### Fetch Bussines Profile (such as description or category)
1153
+ ```javascript
1154
+ const profile = await sock.getBusinessProfile(jid)
1155
+ console.log('business description: ' + profile.description + ', category: ' + profile.category)
1156
+ ```
1157
+
1158
+ ### Fetch Someone's Presence (if they're typing or online)
1159
+ ```javascript
1160
+ // the presence update is fetched and called here
1161
+ sock.ev.on('presence.update', console.log)
1162
+
1163
+ // request updates for a chat
1164
+ await sock.presenceSubscribe(jid)
1165
+ ```
1166
+
1167
+ ## Change Profile
1168
+
1169
+ ### Change Profile Status
1170
+ ```javascript
1171
+ await sock.updateProfileStatus('Hello World!')
1172
+ ```
1173
+ ### Change Profile Name
1174
+ ```javascript
1175
+ await sock.updateProfileName('My name')
1176
+ ```
1177
+ ### Change Display Picture (groups too)
1178
+ - To change your display picture or a group's
1179
+
1180
+ > [!NOTE]
1181
+ > 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)
1182
+
1183
+ ```javascript
1184
+ await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
1185
+ ```
1186
+ ### Remove display picture (groups too)
1187
+ ```javascript
1188
+ await sock.removeProfilePicture(jid)
1189
+ ```
1190
+
1191
+ ## Groups
1192
+
1193
+ - To change group properties you need to be admin
1194
+
1195
+ ### Create a Group
1196
+ ```javascript
1197
+ // title & participants
1198
+ const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1199
+ console.log('created group with id: ' + group.gid)
1200
+ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1201
+ ```
1202
+ ### Add/Remove or Demote/Promote
1203
+ ```javascript
1204
+ // id & people to add to the group (will throw error if it fails)
1205
+ await sock.groupParticipantsUpdate(
1206
+ jid,
1207
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1208
+ 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1209
+ )
1210
+ ```
1211
+ ### Change Subject (name)
1212
+ ```javascript
1213
+ await sock.groupUpdateSubject(jid, 'New Subject!')
1214
+ ```
1215
+ ### Change Description
1216
+ ```javascript
1217
+ await sock.groupUpdateDescription(jid, 'New Description!')
1218
+ ```
1219
+ ### Change Settings
1220
+ ```javascript
1221
+ // only allow admins to send messages
1222
+ await sock.groupSettingUpdate(jid, 'announcement')
1223
+ // allow everyone to send messages
1224
+ await sock.groupSettingUpdate(jid, 'not_announcement')
1225
+ // allow everyone to modify the group's settings -- like display picture etc.
1226
+ await sock.groupSettingUpdate(jid, 'unlocked')
1227
+ // only allow admins to modify the group's settings
1228
+ await sock.groupSettingUpdate(jid, 'locked')
1229
+ ```
1230
+ ### Leave a Group
1231
+ ```javascript
1232
+ // will throw error if it fails
1233
+ await sock.groupLeave(jid)
1234
+ ```
1235
+ ### Get Invite Code
1236
+ - To create link with code use `'https://chat.whatsapp.com/' + code`
1237
+ ```javascript
1238
+ const code = await sock.groupInviteCode(jid)
1239
+ console.log('group code: ' + code)
1240
+ ```
1241
+ ### Revoke Invite Code
1242
+ ```javascript
1243
+ const code = await sock.groupRevokeInvite(jid)
1244
+ console.log('New group code: ' + code)
1245
+ ```
1246
+ ### Join Using Invitation Code
1247
+ - Code can't have `https://chat.whatsapp.com/`, only code
1248
+ ```javascript
1249
+ const response = await sock.groupAcceptInvite(code)
1250
+ console.log('joined to: ' + response)
1251
+ ```
1252
+ ### Get Group Info by Invite Code
1253
+ ```javascript
1254
+ const response = await sock.groupGetInviteInfo(code)
1255
+ console.log('group information: ' + response)
1256
+ ```
1257
+ ### Query Metadata (participants, name, description...)
1258
+ ```javascript
1259
+ const metadata = await sock.groupMetadata(jid)
1260
+ console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1261
+ ```
1262
+ ### Join using `groupInviteMessage`
1263
+ ```javascript
1264
+ const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1265
+ console.log('joined to: ' + response)
1266
+ ```
1267
+ ### Get Request Join List
1268
+ ```javascript
1269
+ const response = await sock.groupRequestParticipantsList(jid)
1270
+ console.log(response)
1271
+ ```
1272
+ ### Approve/Reject Request Join
1273
+ ```javascript
1274
+ const response = await sock.groupRequestParticipantsUpdate(
1275
+ jid, // group id
1276
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1277
+ 'approve' // or 'reject'
1278
+ )
1279
+ console.log(response)
1280
+ ```
1281
+ ### Get All Participating Groups Metadata
1282
+ ```javascript
1283
+ const response = await sock.groupFetchAllParticipating()
1284
+ console.log(response)
1285
+ ```
1286
+ ### Toggle Ephemeral
1287
+
1288
+ - Ephemeral can be:
1289
+
1290
+ | Time | Seconds |
1291
+ |-------|----------------|
1292
+ | Remove | 0 |
1293
+ | 24h | 86.400 |
1294
+ | 7d | 604.800 |
1295
+ | 90d | 7.776.000 |
1296
+
1297
+ ```javascript
1298
+ await sock.groupToggleEphemeral(jid, 86400)
1299
+ ```
1300
+
1301
+ ### Change Add Mode
1302
+ ```javascript
1303
+ await sock.groupMemberAddMode(
1304
+ jid,
1305
+ 'all_member_add' // or 'admin_add'
1306
+ )
1307
+ ```
1308
+
1309
+ ## Privacy
1310
+
1311
+ ### Block/Unblock User
1312
+ ```javascript
1313
+ await sock.updateBlockStatus(jid, 'block') // Block user
1314
+ await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1315
+ ```
1316
+ ### Get Privacy Settings
1317
+ ```javascript
1318
+ const privacySettings = await sock.fetchPrivacySettings(true)
1319
+ console.log('privacy settings: ' + privacySettings)
1320
+ ```
1321
+ ### Get BlockList
1322
+ ```javascript
1323
+ const response = await sock.fetchBlocklist()
1324
+ console.log(response)
1325
+ ```
1326
+ ### Update LastSeen Privacy
1327
+ ```javascript
1328
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1329
+ await sock.updateLastSeenPrivacy(value)
1330
+ ```
1331
+ ### Update Online Privacy
1332
+ ```javascript
1333
+ const value = 'all' // 'match_last_seen'
1334
+ await sock.updateOnlinePrivacy(value)
1335
+ ```
1336
+ ### Update Profile Picture Privacy
1337
+ ```javascript
1338
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1339
+ await sock.updateProfilePicturePrivacy(value)
1340
+ ```
1341
+ ### Update Status Privacy
1342
+ ```javascript
1343
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1344
+ await sock.updateStatusPrivacy(value)
1345
+ ```
1346
+ ### Update Read Receipts Privacy
1347
+ ```javascript
1348
+ const value = 'all' // 'none'
1349
+ await sock.updateReadReceiptsPrivacy(value)
1350
+ ```
1351
+ ### Update Groups Add Privacy
1352
+ ```javascript
1353
+ const value = 'all' // 'contacts' | 'contact_blacklist'
1354
+ await sock.updateGroupsAddPrivacy(value)
1355
+ ```
1356
+ ### Update Default Disappearing Mode
1357
+
1358
+ - Like [this](#disappearing-messages), ephemeral can be:
1359
+
1360
+ | Time | Seconds |
1361
+ |-------|----------------|
1362
+ | Remove | 0 |
1363
+ | 24h | 86.400 |
1364
+ | 7d | 604.800 |
1365
+ | 90d | 7.776.000 |
1366
+
1367
+ ```javascript
1368
+ const ephemeral = 86400
1369
+ await sock.updateDefaultDisappearingMode(ephemeral)
1370
+ ```
1371
+
1372
+ ## Broadcast Lists & Stories
1373
+
1374
+ ### Send Broadcast & Stories
1375
+ - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1376
+ ```javascript
1377
+ await sock.sendMessage(
1378
+ jid,
1379
+ {
1380
+ image: {
1381
+ url: url
1382
+ },
1383
+ caption: caption
1384
+ },
1385
+ {
1386
+ backgroundColor: backgroundColor,
1387
+ font: font,
1388
+ statusJidList: statusJidList,
1389
+ broadcast: true
1390
+ }
1391
+ )
1392
+ ```
1393
+ - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
1394
+ - You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
1395
+ - `broadcast: true` enables broadcast mode
1396
+ - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1397
+
1398
+ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1399
+ - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1400
+ - Broadcast IDs are in the format `12345678@broadcast`
1401
+ ### Query a Broadcast List's Recipients & Name
1402
+ ```javascript
1403
+ const bList = await sock.getBroadcastListInfo('1234@broadcast')
1404
+ console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1405
+ ```
1406
+
1407
+ ## Writing Custom Functionality
1408
+ Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1409
+
1410
+ ### Enabling Debug Level in Baileys Logs
1411
+ First, enable the logging of unhandled messages from WhatsApp by setting:
1412
+ ```javascript
1413
+ const sock = makeWASocket({
1414
+ logger: P({ level: 'debug' }),
1415
+ })
1416
+ ```
1417
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
1418
+
1419
+ ### How Whatsapp Communicate With Us
1420
+
1421
+ > [!TIP]
1422
+ > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1423
+
1424
+ - **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:
1425
+ ```
1426
+ {
1427
+ "level": 10,
1428
+ "fromMe": false,
1429
+ "frame": {
1430
+ "tag": "ib",
1431
+ "attrs": {
1432
+ "from": "@s.whatsapp.net"
1433
+ },
1434
+ "content": [
1435
+ {
1436
+ "tag": "edge_routing",
1437
+ "attrs": {},
1438
+ "content": [
1439
+ {
1440
+ "tag": "routing_info",
1441
+ "attrs": {},
1442
+ "content": {
1443
+ "type": "Buffer",
1444
+ "data": [8,2,8,5]
1445
+ }
1446
+ }
1447
+ ]
1448
+ }
1449
+ ]
1450
+ },
1451
+ "msg":"communication"
1452
+ }
1453
+ ```
1454
+
1455
+ The `'frame'` is what the message received is, it has three components:
1456
+ - `tag` -- what this frame is about (eg. message will have 'message')
1457
+ - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1458
+ - `content` -- the actual data (eg. a message node will have the actual message content in it)
1459
+ - read more about this format [here](/src/WABinary/readme.md)
1460
+
1461
+ ### Register a Callback for Websocket Events
1462
+
1463
+ > [!TIP]
1464
+ > Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired
1465
+
1466
+ ```javascript
1467
+ // for any message with tag 'edge_routing'
1468
+ sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1469
+
1470
+ // for any message with tag 'edge_routing' and id attribute = abcd
1471
+ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1472
+
1473
+ // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
1474
+ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
1475
+ ```
1476
+
1477
+ > [!NOTE]
1478
+ > Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1)