@queenanya/baileys 7.3.7 → 7.4.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 (395) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +941 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +3344 -0
  5. package/WAProto/index.d.ts +37016 -0
  6. package/WAProto/index.js +101044 -0
  7. package/WASignalGroup/GroupProtocol.js +1697 -0
  8. package/WASignalGroup/ciphertext_message.js +16 -0
  9. package/WASignalGroup/group_cipher.js +120 -0
  10. package/WASignalGroup/group_session_builder.js +46 -0
  11. package/WASignalGroup/index.js +5 -0
  12. package/WASignalGroup/keyhelper.js +21 -0
  13. package/WASignalGroup/protobufs.js +3 -0
  14. package/WASignalGroup/queue_job.js +69 -0
  15. package/WASignalGroup/sender_chain_key.js +50 -0
  16. package/WASignalGroup/sender_key_distribution_message.js +78 -0
  17. package/WASignalGroup/sender_key_message.js +92 -0
  18. package/WASignalGroup/sender_key_name.js +70 -0
  19. package/WASignalGroup/sender_key_record.js +56 -0
  20. package/WASignalGroup/sender_key_state.js +129 -0
  21. package/WASignalGroup/sender_message_key.js +39 -0
  22. package/lib/Defaults/baileys-version.json +3 -0
  23. package/lib/Defaults/index.d.ts +284 -0
  24. package/lib/Defaults/index.js +122 -0
  25. package/lib/Defaults/phonenumber-mcc.json +223 -0
  26. package/lib/Signal/libsignal.d.ts +3 -0
  27. package/lib/Signal/libsignal.js +152 -0
  28. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  29. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  30. package/lib/Socket/Client/index.d.ts +3 -0
  31. package/lib/Socket/Client/index.js +19 -0
  32. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  33. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  34. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  35. package/lib/Socket/Client/web-socket-client.js +62 -0
  36. package/lib/Socket/business.d.ts +177 -0
  37. package/lib/Socket/business.js +260 -0
  38. package/lib/Socket/chats.d.ts +91 -0
  39. package/lib/Socket/chats.js +950 -0
  40. package/lib/Socket/groups.d.ts +137 -0
  41. package/lib/Socket/groups.js +314 -0
  42. package/lib/Socket/index.d.ts +179 -0
  43. package/lib/Socket/index.js +10 -0
  44. package/lib/Socket/messages-recv.d.ts +164 -0
  45. package/lib/Socket/messages-recv.js +921 -0
  46. package/lib/Socket/messages-send.d.ts +157 -0
  47. package/lib/Socket/messages-send.js +779 -0
  48. package/lib/Socket/newsletter.d.ts +143 -0
  49. package/lib/Socket/newsletter.js +249 -0
  50. package/lib/Socket/registration.d.ts +271 -0
  51. package/lib/Socket/registration.js +166 -0
  52. package/lib/Socket/socket.d.ts +44 -0
  53. package/lib/Socket/socket.js +620 -0
  54. package/lib/Store/index.d.ts +3 -0
  55. package/lib/Store/index.js +10 -0
  56. package/lib/Store/make-cache-manager-store.d.ts +14 -0
  57. package/lib/Store/make-cache-manager-store.js +83 -0
  58. package/lib/Store/make-in-memory-store.d.ts +118 -0
  59. package/lib/Store/make-in-memory-store.js +422 -0
  60. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  61. package/lib/Store/make-ordered-dictionary.js +81 -0
  62. package/lib/Store/object-repository.d.ts +10 -0
  63. package/lib/Store/object-repository.js +27 -0
  64. package/lib/Types/Auth.d.ts +111 -0
  65. package/lib/Types/Auth.js +2 -0
  66. package/lib/Types/Call.d.ts +13 -0
  67. package/lib/Types/Call.js +2 -0
  68. package/lib/Types/Chat.d.ts +107 -0
  69. package/lib/Types/Chat.js +4 -0
  70. package/lib/Types/Contact.d.ts +19 -0
  71. package/lib/Types/Contact.js +2 -0
  72. package/lib/Types/Events.d.ts +199 -0
  73. package/lib/Types/Events.js +2 -0
  74. package/lib/Types/GroupMetadata.d.ts +56 -0
  75. package/lib/Types/GroupMetadata.js +2 -0
  76. package/lib/Types/Label.d.ts +46 -0
  77. package/lib/Types/Label.js +27 -0
  78. package/lib/Types/LabelAssociation.d.ts +29 -0
  79. package/lib/Types/LabelAssociation.js +9 -0
  80. package/lib/Types/Message.d.ts +278 -0
  81. package/lib/Types/Message.js +9 -0
  82. package/lib/Types/Newsletter.d.ts +79 -0
  83. package/lib/Types/Newsletter.js +18 -0
  84. package/lib/Types/Product.d.ts +78 -0
  85. package/lib/Types/Product.js +2 -0
  86. package/lib/Types/Signal.d.ts +57 -0
  87. package/lib/Types/Signal.js +2 -0
  88. package/lib/Types/Socket.d.ts +118 -0
  89. package/lib/Types/Socket.js +2 -0
  90. package/lib/Types/State.d.ts +27 -0
  91. package/lib/Types/State.js +2 -0
  92. package/lib/Types/index.d.ts +65 -0
  93. package/lib/Types/index.js +42 -0
  94. package/lib/Utils/auth-utils.d.ts +18 -0
  95. package/lib/Utils/auth-utils.js +206 -0
  96. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  97. package/lib/Utils/baileys-event-stream.js +63 -0
  98. package/lib/Utils/business.d.ts +22 -0
  99. package/lib/Utils/business.js +234 -0
  100. package/lib/Utils/chat-utils.d.ts +72 -0
  101. package/lib/Utils/chat-utils.js +740 -0
  102. package/lib/Utils/crypto.d.ts +42 -0
  103. package/lib/Utils/crypto.js +153 -0
  104. package/lib/Utils/decode-wa-message.d.ts +20 -0
  105. package/lib/Utils/decode-wa-message.js +207 -0
  106. package/lib/Utils/event-buffer.d.ts +35 -0
  107. package/lib/Utils/event-buffer.js +520 -0
  108. package/lib/Utils/generics.d.ts +115 -0
  109. package/lib/Utils/generics.js +440 -0
  110. package/lib/Utils/history.d.ts +19 -0
  111. package/lib/Utils/history.js +94 -0
  112. package/lib/Utils/index.d.ts +17 -0
  113. package/lib/Utils/index.js +33 -0
  114. package/lib/Utils/link-preview.d.ts +21 -0
  115. package/lib/Utils/link-preview.js +93 -0
  116. package/lib/Utils/logger.d.ts +2 -0
  117. package/lib/Utils/logger.js +7 -0
  118. package/lib/Utils/lt-hash.d.ts +12 -0
  119. package/lib/Utils/lt-hash.js +51 -0
  120. package/lib/Utils/make-mutex.d.ts +7 -0
  121. package/lib/Utils/make-mutex.js +43 -0
  122. package/lib/Utils/messages-media.d.ts +131 -0
  123. package/lib/Utils/messages-media.js +793 -0
  124. package/lib/Utils/messages.d.ts +78 -0
  125. package/lib/Utils/messages.js +771 -0
  126. package/lib/Utils/noise-handler.d.ts +22 -0
  127. package/lib/Utils/noise-handler.js +155 -0
  128. package/lib/Utils/process-message.d.ts +42 -0
  129. package/lib/Utils/process-message.js +354 -0
  130. package/lib/Utils/signal.d.ts +32 -0
  131. package/lib/Utils/signal.js +156 -0
  132. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  133. package/lib/Utils/use-multi-file-auth-state.js +93 -0
  134. package/lib/Utils/validate-connection.d.ts +11 -0
  135. package/lib/Utils/validate-connection.js +205 -0
  136. package/lib/WABinary/constants.d.ts +27 -0
  137. package/lib/WABinary/constants.js +40 -0
  138. package/lib/WABinary/decode.d.ts +8 -0
  139. package/lib/WABinary/decode.js +254 -0
  140. package/lib/WABinary/encode.d.ts +2 -0
  141. package/lib/WABinary/encode.js +228 -0
  142. package/lib/WABinary/generic-utils.d.ts +16 -0
  143. package/lib/WABinary/generic-utils.js +110 -0
  144. package/lib/WABinary/index.d.ts +5 -0
  145. package/lib/WABinary/index.js +21 -0
  146. package/lib/WABinary/jid-utils.d.ts +31 -0
  147. package/lib/WABinary/jid-utils.js +62 -0
  148. package/lib/WABinary/types.d.ts +18 -0
  149. package/lib/WABinary/types.js +2 -0
  150. package/lib/WAM/BinaryInfo.d.ts +18 -0
  151. package/lib/WAM/BinaryInfo.js +13 -0
  152. package/lib/WAM/constants.d.ts +38 -0
  153. package/lib/WAM/constants.js +15350 -0
  154. package/lib/WAM/encode.d.ts +4 -0
  155. package/lib/WAM/encode.js +155 -0
  156. package/lib/WAM/index.d.ts +3 -0
  157. package/lib/WAM/index.js +19 -0
  158. package/lib/index.d.ts +11 -0
  159. package/lib/index.js +30 -0
  160. package/package.json +102 -2
  161. package/.anya-md/.replit +0 -2
  162. package/.anya-md/.temp/.temp +0 -1
  163. package/.anya-md/Dockerfile +0 -16
  164. package/.anya-md/LICENCE +0 -674
  165. package/.anya-md/README.md +0 -301
  166. package/.anya-md/app.json +0 -81
  167. package/.anya-md/config.js +0 -74
  168. package/.anya-md/heroku.yml +0 -5
  169. package/.anya-md/index.js +0 -47
  170. package/.anya-md/koyeb.yaml +0 -14
  171. package/.anya-md/lib/.dev.js +0 -47
  172. package/.anya-md/lib/Assets/aliveMedia.mp4 +0 -0
  173. package/.anya-md/lib/Assets/goodbyeBG.jpg +0 -0
  174. package/.anya-md/lib/Assets/image_1.jpg +0 -0
  175. package/.anya-md/lib/Assets/image_2.jpg +0 -0
  176. package/.anya-md/lib/Assets/menuMedia.mp4 +0 -0
  177. package/.anya-md/lib/Assets/ownerMentionMp3.mp3 +0 -0
  178. package/.anya-md/lib/Assets/port.html +0 -36
  179. package/.anya-md/lib/Assets/reaction/angry/angry108202410.jpeg +0 -0
  180. package/.anya-md/lib/Assets/reaction/angry/angry108202412.jpeg +0 -0
  181. package/.anya-md/lib/Assets/reaction/angry/angry108202413.jpeg +0 -0
  182. package/.anya-md/lib/Assets/reaction/angry/angry108202414.jpeg +0 -0
  183. package/.anya-md/lib/Assets/reaction/angry/angry108202415.jpeg +0 -0
  184. package/.anya-md/lib/Assets/reaction/angry/angry108202416.jpeg +0 -0
  185. package/.anya-md/lib/Assets/reaction/angry/angry108202417.jpeg +0 -0
  186. package/.anya-md/lib/Assets/reaction/angry/angry108202418.jpeg +0 -0
  187. package/.anya-md/lib/Assets/reaction/angry/angry108202419.jpeg +0 -0
  188. package/.anya-md/lib/Assets/reaction/angry/angry108202420.jpeg +0 -0
  189. package/.anya-md/lib/Assets/reaction/angry/angry108202421.jpeg +0 -0
  190. package/.anya-md/lib/Assets/reaction/angry/angry108202423.jpeg +0 -0
  191. package/.anya-md/lib/Assets/reaction/angry/angry108202425.jpeg +0 -0
  192. package/.anya-md/lib/Assets/reaction/angry/angry108202426.jpeg +0 -0
  193. package/.anya-md/lib/Assets/reaction/angry/angry108202427.jpeg +0 -0
  194. package/.anya-md/lib/Assets/reaction/angry/angry108202428.jpeg +0 -0
  195. package/.anya-md/lib/Assets/reaction/angry/angry108202429.jpeg +0 -0
  196. package/.anya-md/lib/Assets/reaction/angry/angry108202430.jpeg +0 -0
  197. package/.anya-md/lib/Assets/reaction/angry/angry108202431.jpeg +0 -0
  198. package/.anya-md/lib/Assets/reaction/angry/angry108202469.jpeg +0 -0
  199. package/.anya-md/lib/Assets/reaction/angry/angry10820249.jpeg +0 -0
  200. package/.anya-md/lib/Assets/reaction/angry/angry11.mp4 +0 -0
  201. package/.anya-md/lib/Assets/reaction/angry/angry12.mp4 +0 -0
  202. package/.anya-md/lib/Assets/reaction/angry/angry14.jpg +0 -0
  203. package/.anya-md/lib/Assets/reaction/angry/angry2.mp4 +0 -0
  204. package/.anya-md/lib/Assets/reaction/angry/angry3.mp4 +0 -0
  205. package/.anya-md/lib/Assets/reaction/angry/angry5.jpg +0 -0
  206. package/.anya-md/lib/Assets/reaction/angry/angry6.png +0 -0
  207. package/.anya-md/lib/Assets/reaction/angry/angry8.png +0 -0
  208. package/.anya-md/lib/Assets/reaction/angry/angry9.jpg +0 -0
  209. package/.anya-md/lib/Assets/reaction/confused/confused1.png +0 -0
  210. package/.anya-md/lib/Assets/reaction/confused/confused2.jpg +0 -0
  211. package/.anya-md/lib/Assets/reaction/confused/confused3.jpg +0 -0
  212. package/.anya-md/lib/Assets/reaction/confused/confused4.mp4 +0 -0
  213. package/.anya-md/lib/Assets/reaction/confused/confused5.jpg +0 -0
  214. package/.anya-md/lib/Assets/reaction/confused/confused6.webp +0 -0
  215. package/.anya-md/lib/Assets/reaction/confused/confused7.png +0 -0
  216. package/.anya-md/lib/Assets/reaction/confused/confused8.jpg +0 -0
  217. package/.anya-md/lib/Assets/reaction/cry/cry1.jpeg +0 -0
  218. package/.anya-md/lib/Assets/reaction/cry/cry12.jpeg +0 -0
  219. package/.anya-md/lib/Assets/reaction/cry/cry13.jpeg +0 -0
  220. package/.anya-md/lib/Assets/reaction/cry/cry14.jpeg +0 -0
  221. package/.anya-md/lib/Assets/reaction/cry/cry15.jpeg +0 -0
  222. package/.anya-md/lib/Assets/reaction/cry/cry16.jpeg +0 -0
  223. package/.anya-md/lib/Assets/reaction/cry/cry17.jpeg +0 -0
  224. package/.anya-md/lib/Assets/reaction/cry/cry18.jpeg +0 -0
  225. package/.anya-md/lib/Assets/reaction/cry/cry19.jpeg +0 -0
  226. package/.anya-md/lib/Assets/reaction/cry/cry22.jpeg +0 -0
  227. package/.anya-md/lib/Assets/reaction/cry/cry23.jpeg +0 -0
  228. package/.anya-md/lib/Assets/reaction/cry/cry5.jpeg +0 -0
  229. package/.anya-md/lib/Assets/reaction/cry/cry9.jpeg +0 -0
  230. package/.anya-md/lib/Assets/reaction/happy/happyrect1.jpeg +0 -0
  231. package/.anya-md/lib/Assets/reaction/no/_pika +0 -1
  232. package/.anya-md/lib/Assets/reaction/no/no1.jpg +0 -0
  233. package/.anya-md/lib/Assets/reaction/no/no2.png +0 -0
  234. package/.anya-md/lib/Assets/reaction/no/no3.jpg +0 -0
  235. package/.anya-md/lib/Assets/reaction/no/no4.png +0 -0
  236. package/.anya-md/lib/Assets/reaction/no/no5.png +0 -0
  237. package/.anya-md/lib/Assets/reaction/no/no6.jpg +0 -0
  238. package/.anya-md/lib/Assets/reaction/no/no7.jpg +0 -0
  239. package/.anya-md/lib/Assets/reaction/no/no8.jpg +0 -0
  240. package/.anya-md/lib/Assets/reaction/no/no9.mp4 +0 -0
  241. package/.anya-md/lib/Assets/reaction/smug/059e1bdc-e62a-4943-b85e-ea372709f6a7.jpeg +0 -0
  242. package/.anya-md/lib/Assets/reaction/smug/8fda90b3-bc98-4d24-ac10-4402c4e7be93.jpeg +0 -0
  243. package/.anya-md/lib/Assets/reaction/smug/Aqua.jpeg +0 -0
  244. package/.anya-md/lib/Assets/reaction/smug/Karasuma Chitose.jpeg +0 -0
  245. package/.anya-md/lib/Assets/reaction/smug/Smug Face - Fibel Sistine.jpeg +0 -0
  246. package/.anya-md/lib/Assets/reaction/smug/bf8d78ec-4fcc-4ff7-b3c3-91a0c5f22567.jpeg +0 -0
  247. package/.anya-md/lib/Assets/reaction/smug//330/247/330/255/331/204/330/247/331/213 /330/247/330/250/330/252/330/263/330/247/331/205/331/207 /330/264/330/261/331/212/330/261/331/207/360/237/230/255/360/237/230/255/360/237/230/255.jpeg +0 -0
  248. package/.anya-md/lib/Assets/verifyIMG.jpg +0 -0
  249. package/.anya-md/lib/Assets/welcomeGIF.mp4 +0 -0
  250. package/.anya-md/lib/database/categories.json +0 -77
  251. package/.anya-md/lib/database/cooldown.json +0 -1
  252. package/.anya-md/lib/database/disk/main.js +0 -43
  253. package/.anya-md/lib/database/emoji.js +0 -23
  254. package/.anya-md/lib/database/games/quiz/Questions.js +0 -44
  255. package/.anya-md/lib/database/games/quiz/Quiz.js +0 -169
  256. package/.anya-md/lib/database/games/quiz/database.json +0 -1
  257. package/.anya-md/lib/database/games/quiz/index.js +0 -7
  258. package/.anya-md/lib/database/json/.pika.js +0 -3
  259. package/.anya-md/lib/database/json/animeQuotes.json +0 -51062
  260. package/.anya-md/lib/database/json/bioQuotes.json +0 -5744
  261. package/.anya-md/lib/database/json/cogan.json +0 -102
  262. package/.anya-md/lib/database/json/countries.json +0 -21210
  263. package/.anya-md/lib/database/json/countries2.json +0 -1
  264. package/.anya-md/lib/database/json/couplepp.json +0 -725
  265. package/.anya-md/lib/database/json/flaming.json +0 -7
  266. package/.anya-md/lib/database/json/ganpati.json +0 -102
  267. package/.anya-md/lib/database/json/husbu.json +0 -1967
  268. package/.anya-md/lib/database/json/islamicWall.json +0 -501
  269. package/.anya-md/lib/database/json/pickupLines.json +0 -118
  270. package/.anya-md/lib/database/json/shreeram.json +0 -49
  271. package/.anya-md/lib/database/json/truthDare.json +0 -643
  272. package/.anya-md/lib/database/mongodb/README.md +0 -142
  273. package/.anya-md/lib/database/mongodb/bot.js +0 -12
  274. package/.anya-md/lib/database/mongodb/cmd.js +0 -17
  275. package/.anya-md/lib/database/mongodb/group.js +0 -22
  276. package/.anya-md/lib/database/mongodb/index.js +0 -24
  277. package/.anya-md/lib/database/mongodb/plugins.js +0 -124
  278. package/.anya-md/lib/database/mongodb/system.js +0 -34
  279. package/.anya-md/lib/database/mongodb/ui.js +0 -15
  280. package/.anya-md/lib/database/mongodb/user.js +0 -17
  281. package/.anya-md/lib/database/mongodb/warn.js +0 -136
  282. package/.anya-md/lib/database/sessions/.pika.js +0 -3
  283. package/.anya-md/lib/frameworks/index.js +0 -5
  284. package/.anya-md/lib/frameworks/reactionMedia.js +0 -91
  285. package/.anya-md/lib/lib/README.md +0 -29
  286. package/.anya-md/lib/lib/ai/README.md +0 -35
  287. package/.anya-md/lib/lib/ai/aiArt.js +0 -47
  288. package/.anya-md/lib/lib/ai/index.js +0 -7
  289. package/.anya-md/lib/lib/buttons.js +0 -530
  290. package/.anya-md/lib/lib/connectionMsg.js +0 -72
  291. package/.anya-md/lib/lib/converter.js +0 -355
  292. package/.anya-md/lib/lib/cooldown.js +0 -46
  293. package/.anya-md/lib/lib/events.js +0 -47
  294. package/.anya-md/lib/lib/functions.js +0 -47
  295. package/.anya-md/lib/lib/greeting.js +0 -115
  296. package/.anya-md/lib/lib/index.js +0 -381
  297. package/.anya-md/lib/lib/logger.js +0 -7
  298. package/.anya-md/lib/lib/maker/remini.js +0 -35
  299. package/.anya-md/lib/lib/mongoUrlFix.js +0 -46
  300. package/.anya-md/lib/lib/myfunc.js +0 -47
  301. package/.anya-md/lib/lib/plugins.js +0 -20
  302. package/.anya-md/lib/lib/prefix.js +0 -47
  303. package/.anya-md/lib/lib/scraper/README.md +0 -35
  304. package/.anya-md/lib/lib/scraper/SoundCloud.js +0 -47
  305. package/.anya-md/lib/lib/scraper/WebToons.js +0 -47
  306. package/.anya-md/lib/lib/scraper/android1.js +0 -47
  307. package/.anya-md/lib/lib/scraper/happymodSearch.js +0 -47
  308. package/.anya-md/lib/lib/scraper/index.js +0 -27
  309. package/.anya-md/lib/lib/scraper/konaChanSearch.js +0 -47
  310. package/.anya-md/lib/lib/scraper/pinterest.js +0 -47
  311. package/.anya-md/lib/lib/scraper/playstore.js +0 -47
  312. package/.anya-md/lib/lib/scraper/ringtone.js +0 -47
  313. package/.anya-md/lib/lib/scraper/steam.js +0 -47
  314. package/.anya-md/lib/lib/scraper/trendingTwitter.js +0 -51
  315. package/.anya-md/lib/lib/scraper/wattpad.js +0 -61
  316. package/.anya-md/lib/lib/scraper/wikipediaSearch.js +0 -42
  317. package/.anya-md/lib/lib/scraper.js +0 -47
  318. package/.anya-md/lib/lib/session.js +0 -47
  319. package/.anya-md/lib/lib/session2.js +0 -47
  320. package/.anya-md/lib/lib/similar.js +0 -47
  321. package/.anya-md/lib/lib/stylish-font.js +0 -2302
  322. package/.anya-md/lib/lib/unicode.js +0 -877
  323. package/.anya-md/lib/lib/upload/index.js +0 -3
  324. package/.anya-md/lib/lib/upload/webp2mp4File.js +0 -56
  325. package/.anya-md/lib/lib/ytdl-core.js +0 -47
  326. package/.anya-md/lib/plugins/README.md +0 -83
  327. package/.anya-md/lib/plugins/_menu.js +0 -810
  328. package/.anya-md/lib/plugins/_plugins.js +0 -239
  329. package/.anya-md/lib/plugins/admins.js +0 -689
  330. package/.anya-md/lib/plugins/ai.js +0 -160
  331. package/.anya-md/lib/plugins/autoreply.js +0 -101
  332. package/.anya-md/lib/plugins/broadcast.js +0 -204
  333. package/.anya-md/lib/plugins/convert.js +0 -293
  334. package/.anya-md/lib/plugins/core.js +0 -941
  335. package/.anya-md/lib/plugins/download.js +0 -373
  336. package/.anya-md/lib/plugins/fun.js +0 -75
  337. package/.anya-md/lib/plugins/games.js +0 -33
  338. package/.anya-md/lib/plugins/gcswitches.js +0 -204
  339. package/.anya-md/lib/plugins/general.js +0 -456
  340. package/.anya-md/lib/plugins/maker.js +0 -41
  341. package/.anya-md/lib/plugins/owner.js +0 -1049
  342. package/.anya-md/lib/plugins/religious.js +0 -81
  343. package/.anya-md/lib/plugins/search.js +0 -902
  344. package/.anya-md/lib/plugins/stalker.js +0 -187
  345. package/.anya-md/lib/plugins/sticker.js +0 -125
  346. package/.anya-md/lib/plugins/tools.js +0 -193
  347. package/.anya-md/lib/plugins/youtube.js +0 -204
  348. package/.anya-md/package.json +0 -75
  349. package/.anya-md/railway.json +0 -12
  350. package/.anya-md/render.yaml +0 -48
  351. package/.anya-md/replit.nix +0 -18
  352. package/.bash_history +0 -500
  353. package/.config/gh/config.yml +0 -19
  354. package/.config/gh/hosts.yml +0 -11
  355. package/.config/ngrok/ngrok.yml +0 -3
  356. package/.config/yarn/global/package.json +0 -5
  357. package/.gitconfig +0 -772
  358. package/.node_repl_history +0 -0
  359. package/.npm/_cacache/content-v2/sha512/02/b3/d1abf5af06222f7de440ab1b057deb21f9dfb0ce0a8f5064b2ba00595933bbcbbaa040b4616f951d9f8ba48d67491df1198a4831fbd8ee26eb27dde36511 +0 -0
  360. package/.npm/_cacache/content-v2/sha512/49/7b/0cdbb4861f7c9358a7367ca478498371b269efb8143d75de901ed1169a267f56a68e60f008952f3ebcc727dbb60bb401011af3514a1dd33cdbed8d981fa8 +0 -0
  361. package/.npm/_cacache/content-v2/sha512/54/3a/647bceb49b7632e6e700cb9f1b66f0f528d4ca71f4f73e76a1e7c8c50b563a2d0bb7734c18f93e6c03b7ea93167db35db0e1999ab13b08ed6b250eed2d2a +0 -1
  362. package/.npm/_cacache/content-v2/sha512/56/7c/4d5820233a7278225351642f7355d9889af42e7efbbfe27d6b201727efad972a59fa32063c7e1159d01dbf27ba014095ca1349ec0d0767746c39441178fa +0 -1
  363. package/.npm/_cacache/content-v2/sha512/89/88/d295c7e4f4d0f4621676d4c499bea2a1c72b0c31a84ff78a8bb8f83042da2bcf596e664c021d21025b296cdd4aecb57a036ea366e39466df5a129fa471df +0 -0
  364. package/.npm/_cacache/content-v2/sha512/8b/46/42882ebb46a975b0ce6b9cdea357190c41b51bb59a21df41c575418850b28115921e130709846d8ff9cabeae72544ec37a48ee7ccb074fe94da925250e55 +0 -1
  365. package/.npm/_cacache/content-v2/sha512/dd/0d/f856b793da0619d18260556498dfff13391593abb6d6a582bf052f03ba35a03a1444bf5c2d40b7515d268ec2cb3e67a17a42f09f5e668c3bb9b743e3b8a7 +0 -1
  366. package/.npm/_cacache/content-v2/sha512/dd/15/702501c36ce653a003d2b101034a0cb9c0fd262fa77797f1a286a161a0b2dce51ef13199e9a3fa58008bdbbf4646a33b6f1a24a2807691093cb89beefb00 +0 -1
  367. package/.npm/_cacache/index-v5/35/f9/e8cc076ef93c1bc40804d3fe05171053366095c922f515b1fab2b580116f +0 -4
  368. package/.npm/_cacache/index-v5/6a/a2/780c77f928115d4dad58a9dc4fa241de8d914abfff994e44602cc93a697c +0 -2
  369. package/.npm/_cacache/index-v5/71/ba/d0bb16fddeb617bbbb3713f46750d1bf5b57742abb6feb6dee4d16c68da4 +0 -4
  370. package/.npm/_cacache/index-v5/72/ae/c69532318093b3bd13618450ca5c26adc018a4afc0e020786207068593cf +0 -2
  371. package/.npm/_cacache/index-v5/7e/5e/9683ad4854f4201d7e53bf9beb2aefafa7b1efbb2c6ac7b36b78d0b218c8 +0 -2
  372. package/.npm/_cacache/index-v5/eb/a0/19e529094c594367a9e1aa68096a313d3dc5509d410761bf50122826a6d2 +0 -4
  373. package/.npm/_cacache/index-v5/f1/fa/2d2f12de549683d1275ec0f2ff15610b408fd89d1b7a755ddb7b77c00371 +0 -2
  374. package/.npm/_logs/2024-10-03T05_52_01_853Z-debug-0.log +0 -52
  375. package/.npm/_logs/2024-10-03T05_52_08_135Z-debug-0.log +0 -52
  376. package/.npm/_logs/2024-10-03T05_52_14_087Z-debug-0.log +0 -52
  377. package/.npm/_logs/2024-10-03T05_52_22_730Z-debug-0.log +0 -52
  378. package/.npm/_logs/2024-10-03T05_52_29_410Z-debug-0.log +0 -52
  379. package/.npm/_logs/2024-10-03T05_52_35_375Z-debug-0.log +0 -52
  380. package/.npm/_logs/2024-10-03T15_32_57_465Z-debug-0.log +0 -20
  381. package/.npm/_logs/2024-10-10T05_40_23_847Z-debug-0.log +0 -254
  382. package/.npm/_logs/2024-10-10T05_40_50_397Z-debug-0.log +0 -73
  383. package/.npm/_logs/2024-10-10T05_40_59_931Z-debug-0.log +0 -52
  384. package/.npm/_logs/2024-10-10T05_42_07_969Z-debug-0.log +0 -52
  385. package/.pm2/logs/anya-error.log +0 -0
  386. package/.pm2/logs/anya-out.log +0 -59
  387. package/.pm2/logs/anya-v2-error.log +0 -2184
  388. package/.pm2/logs/anya-v2-out.log +0 -362
  389. package/.pm2/module_conf.json +0 -1
  390. package/.pm2/pm2.log +0 -919
  391. package/.pm2/pm2.pid +0 -1
  392. package/.pm2/touch +0 -1
  393. package/.ssh/authorized_keys +0 -0
  394. package/.termux/termux.properties +0 -180
  395. package/.wget-hsts +0 -5
package/README.md ADDED
@@ -0,0 +1,941 @@
1
+ # Note:
2
+ **@queenanya/baileys is another version of Baileys that was originally created by Adhiraj Singh. @queenanya/baileys is Maintained and Up-to-dated with all lestest feature [Thanks for Visiting Here If You Any Questions/Query Please Open A Issue In GitHub Repository]**
3
+
4
+ ## Maintainer Of @queenanya/baileys
5
+ ** •Team PikaBotz. **
6
+
7
+ # QueenAnya/Baileys - Typescript/Javascript WhatsApp Web API
8
+
9
+ ### Important Note
10
+
11
+ This library was originally a project for **CS-2362 at Ashoka University** and is in no way affiliated with or endorsed by WhatsApp. Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
12
+
13
+ #### Liability and License Notice
14
+ Baileys and its maintainers cannot be held liable for misuse of this application, as stated in the [MIT license](https://github.com/queenanya/Baileys/blob/master/LICENSE).
15
+ 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.
16
+ ##
17
+
18
+ Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
19
+ Not running Selenium or Chromimum saves you like **half a gig** of ram :/
20
+ Baileys supports interacting with the multi-device & web versions of WhatsApp.
21
+ 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.
22
+
23
+ ## Please Read
24
+
25
+ The original repository had to be removed by the original author - we now continue development in this repository here.
26
+ This is the only official repository and is maintained by the community.
27
+ **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
28
+
29
+ ## Example
30
+
31
+ Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
32
+ The script covers most common use cases.
33
+ To run the example script, download or clone the repo and then type the following in a terminal:
34
+ 1. ``` cd path/to/Baileys ```
35
+ 2. ``` yarn ```
36
+ 3. ``` yarn example ```
37
+
38
+ ## Install
39
+
40
+ Use the stable version:
41
+ ```
42
+ yarn add @queenanya/baileys
43
+ ```
44
+
45
+ Use the edge version (no guarantee of stability, but latest fixes + features)
46
+ ```
47
+ yarn add github:QueenAnya/Baileys
48
+ ```
49
+
50
+ Then import your code using:
51
+ ``` ts
52
+ import makeWASocket from '@queenanya/baileys'
53
+ ```
54
+
55
+ ## Unit Tests
56
+
57
+ TODO
58
+
59
+ ## Connecting multi device (recommended)
60
+
61
+ WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a QR code with WhatsApp on your phone.
62
+
63
+ ``` ts
64
+ import makeWASocket, { DisconnectReason } from '@queenanya/baileys'
65
+ import { Boom } from '@hapi/boom'
66
+
67
+ async function connectToWhatsApp () {
68
+ const sock = makeWASocket({
69
+ // can provide additional config here
70
+ printQRInTerminal: true
71
+ })
72
+ sock.ev.on('connection.update', (update) => {
73
+ const { connection, lastDisconnect } = update
74
+ if(connection === 'close') {
75
+ const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
76
+ console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
77
+ // reconnect if not logged out
78
+ if(shouldReconnect) {
79
+ connectToWhatsApp()
80
+ }
81
+ } else if(connection === 'open') {
82
+ console.log('opened connection')
83
+ }
84
+ })
85
+ sock.ev.on('messages.upsert', m => {
86
+ console.log(JSON.stringify(m, undefined, 2))
87
+
88
+ console.log('replying to', m.messages[0].key.remoteJid)
89
+ await sock.sendMessage(m.messages[0].key.remoteJid!, { text: 'Hello there!' })
90
+ })
91
+ }
92
+ // run in main file
93
+ connectToWhatsApp()
94
+ ```
95
+
96
+ 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!
97
+
98
+ **Note:** install `qrcode-terminal` using `yarn add qrcode-terminal` to auto-print the QR to the terminal.
99
+
100
+ **Note:** the code to support the legacy version of WA Web (pre multi-device) has been removed in v5. Only the standard multi-device connection is now supported. This is done as WA seems to have completely dropped support for the legacy version.
101
+
102
+ ## Connecting native mobile api
103
+
104
+ Baileys also supports the native mobile API, which allows users to authenticate as a standalone WhatsApp client using their phone number.
105
+
106
+ Run the [example](Example/example.ts) file with ``--mobile`` cli flag to use the native mobile API.
107
+
108
+ ## Configuring the Connection
109
+
110
+ You can configure the connection by passing a `SocketConfig` object.
111
+
112
+ The entire `SocketConfig` structure is mentioned here with default values:
113
+ ``` ts
114
+ type SocketConfig = {
115
+ /** the WS url to connect to WA */
116
+ waWebSocketUrl: string | URL
117
+ /** Fails the connection if the socket times out in this interval */
118
+ connectTimeoutMs: number
119
+ /** Default timeout for queries, undefined for no timeout */
120
+ defaultQueryTimeoutMs: number | undefined
121
+ /** ping-pong interval for WS connection */
122
+ keepAliveIntervalMs: number
123
+ /** proxy agent */
124
+ agent?: Agent
125
+ /** pino logger */
126
+ logger: Logger
127
+ /** version to connect with */
128
+ version: WAVersion
129
+ /** override browser config */
130
+ browser: WABrowserDescription
131
+ /** agent used for fetch requests -- uploading/downloading media */
132
+ fetchAgent?: Agent
133
+ /** should the QR be printed in the terminal */
134
+ printQRInTerminal: boolean
135
+ /** should events be emitted for actions done by this socket connection */
136
+ emitOwnEvents: boolean
137
+ /** provide a cache to store media, so does not have to be re-uploaded */
138
+ mediaCache?: NodeCache
139
+ /** custom upload hosts to upload media to */
140
+ customUploadHosts: MediaConnInfo['hosts']
141
+ /** time to wait between sending new retry requests */
142
+ retryRequestDelayMs: number
143
+ /** max msg retry count */
144
+ maxMsgRetryCount: number
145
+ /** time to wait for the generation of the next QR in ms */
146
+ qrTimeout?: number;
147
+ /** provide an auth state object to maintain the auth state */
148
+ auth: AuthenticationState
149
+ /** manage history processing with this control; by default will sync up everything */
150
+ shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean
151
+ /** transaction capability options for SignalKeyStore */
152
+ transactionOpts: TransactionCapabilityOptions
153
+ /** provide a cache to store a user's device list */
154
+ userDevicesCache?: NodeCache
155
+ /** marks the client as online whenever the socket successfully connects */
156
+ markOnlineOnConnect: boolean
157
+ /**
158
+ * map to store the retry counts for failed messages;
159
+ * used to determine whether to retry a message or not */
160
+ msgRetryCounterMap?: MessageRetryMap
161
+ /** width for link preview images */
162
+ linkPreviewImageThumbnailWidth: number
163
+ /** Should Baileys ask the phone for full history, will be received async */
164
+ syncFullHistory: boolean
165
+ /** Should baileys fire init queries automatically, default true */
166
+ fireInitQueries: boolean
167
+ /**
168
+ * generate a high quality link preview,
169
+ * entails uploading the jpegThumbnail to WA
170
+ * */
171
+ generateHighQualityLinkPreview: boolean
172
+
173
+ /** options for axios */
174
+ options: AxiosRequestConfig<any>
175
+ /**
176
+ * fetch a message from your store
177
+ * implement this so that messages failed to send (solves the "this message can take a while" issue) can be retried
178
+ * */
179
+ getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
180
+ }
181
+ ```
182
+
183
+ ### Emulating the Desktop app instead of the web
184
+
185
+ 1. Baileys, by default, emulates a chrome web session
186
+ 2. If you'd like to emulate a desktop connection (and receive more message history), add this to your Socket config:
187
+ ``` ts
188
+ const conn = makeWASocket({
189
+ ...otherOpts,
190
+ // can use Windows, Ubuntu here too
191
+ browser: Browsers.macOS('Desktop'),
192
+ syncFullHistory: true
193
+ })
194
+ ```
195
+
196
+ ## Saving & Restoring Sessions
197
+
198
+ You obviously don't want to keep scanning the QR code every time you want to connect.
199
+
200
+ So, you can load the credentials to log back in:
201
+ ``` ts
202
+ import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@queenanya/baileys'
203
+ import * as fs from 'fs'
204
+
205
+ // utility function to help save the auth state in a single folder
206
+ // 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
207
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
208
+ // will use the given state to connect
209
+ // so if valid credentials are available -- it'll connect without QR
210
+ const conn = makeWASocket({ auth: state })
211
+ // this will be called as soon as the credentials are updated
212
+ conn.ev.on ('creds.update', saveCreds)
213
+ ```
214
+
215
+ **Note:** 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.
216
+
217
+ ## Listening to Connection Updates
218
+
219
+ Baileys now fires the `connection.update` event to let you know something has updated in the connection. This data has the following structure:
220
+ ``` ts
221
+ type ConnectionState = {
222
+ /** connection is now open, connecting or closed */
223
+ connection: WAConnectionState
224
+ /** the error that caused the connection to close */
225
+ lastDisconnect?: {
226
+ error: Error
227
+ date: Date
228
+ }
229
+ /** is this a new login */
230
+ isNewLogin?: boolean
231
+ /** the current QR code */
232
+ qr?: string
233
+ /** has the device received all pending notifications while it was offline */
234
+ receivedPendingNotifications?: boolean
235
+ }
236
+ ```
237
+
238
+ **Note:** this also offers any updates to the QR
239
+
240
+ ## Handling Events
241
+
242
+ Baileys uses the EventEmitter syntax for events.
243
+ They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
244
+
245
+ The events are typed as mentioned here:
246
+
247
+ ``` ts
248
+
249
+ export type BaileysEventMap = {
250
+ /** connection state has been updated -- WS closed, opened, connecting etc. */
251
+ 'connection.update': Partial<ConnectionState>
252
+ /** credentials updated -- some metadata, keys or something */
253
+ 'creds.update': Partial<AuthenticationCreds>
254
+ /** history sync, everything is reverse chronologically sorted */
255
+ 'messaging-history.set': {
256
+ chats: Chat[]
257
+ contacts: Contact[]
258
+ messages: WAMessage[]
259
+ isLatest: boolean
260
+ }
261
+ /** upsert chats */
262
+ 'chats.upsert': Chat[]
263
+ /** update the given chats */
264
+ 'chats.update': Partial<Chat>[]
265
+ /** delete chats with given ID */
266
+ 'chats.delete': string[]
267
+ 'labels.association': LabelAssociation
268
+ 'labels.edit': Label
269
+ /** presence of contact in a chat updated */
270
+ 'presence.update': { id: string, presences: { [participant: string]: PresenceData } }
271
+
272
+ 'contacts.upsert': Contact[]
273
+ 'contacts.update': Partial<Contact>[]
274
+
275
+ 'messages.delete': { keys: WAMessageKey[] } | { jid: string, all: true }
276
+ 'messages.update': WAMessageUpdate[]
277
+ 'messages.media-update': { key: WAMessageKey, media?: { ciphertext: Uint8Array, iv: Uint8Array }, error?: Boom }[]
278
+ /**
279
+ * add/update the given messages. If they were received while the connection was online,
280
+ * the update will have type: "notify"
281
+ * */
282
+ 'messages.upsert': { messages: WAMessage[], type: MessageUpsertType }
283
+ /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
284
+ 'messages.reaction': { key: WAMessageKey, reaction: proto.IReaction }[]
285
+
286
+ 'message-receipt.update': MessageUserReceiptUpdate[]
287
+
288
+ 'groups.upsert': GroupMetadata[]
289
+ 'groups.update': Partial<GroupMetadata>[]
290
+ /** apply an action to participants in a group */
291
+ 'group-participants.update': { id: string, participants: string[], action: ParticipantAction }
292
+
293
+ 'blocklist.set': { blocklist: string[] }
294
+ 'blocklist.update': { blocklist: string[], type: 'add' | 'remove' }
295
+ /** Receive an update on a call, including when the call was received, rejected, accepted */
296
+ 'call': WACallEvent[]
297
+ }
298
+ ```
299
+
300
+ You can listen to these events like this:
301
+ ``` ts
302
+
303
+ const sock = makeWASocket()
304
+ sock.ev.on('messages.upsert', ({ messages }) => {
305
+ console.log('got messages', messages)
306
+ })
307
+
308
+ ```
309
+
310
+ ## Implementing a Data Store
311
+
312
+ 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.
313
+
314
+ It can be used as follows:
315
+
316
+ ``` ts
317
+ import makeWASocket, { makeInMemoryStore } from '@queenanya/baileys'
318
+ // the store maintains the data of the WA connection in memory
319
+ // can be written out to a file & read from it
320
+ const store = makeInMemoryStore({ })
321
+ // can be read from a file
322
+ store.readFromFile('./baileys_store.json')
323
+ // saves the state to a file every 10s
324
+ setInterval(() => {
325
+ store.writeToFile('./baileys_store.json')
326
+ }, 10_000)
327
+
328
+ const sock = makeWASocket({ })
329
+ // will listen from this socket
330
+ // the store can listen from a new socket once the current socket outlives its lifetime
331
+ store.bind(sock.ev)
332
+
333
+ sock.ev.on('chats.set', () => {
334
+ // can use "store.chats" however you want, even after the socket dies out
335
+ // "chats" => a KeyedDB instance
336
+ console.log('got chats', store.chats.all())
337
+ })
338
+
339
+ sock.ev.on('contacts.set', () => {
340
+ console.log('got contacts', Object.values(store.contacts))
341
+ })
342
+
343
+ ```
344
+
345
+ The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
346
+
347
+ **Note:** I highly recommend building your own data store especially for MD connections, as storing someone's entire chat history in memory is a terrible waste of RAM.
348
+
349
+ ## Sending Messages
350
+
351
+ **Send all types of messages with a single function:**
352
+
353
+ ### Non-Media Messages
354
+
355
+ ``` ts
356
+ import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
357
+
358
+ const id = 'abcd@s.whatsapp.net' // the WhatsApp ID
359
+ // send a simple text!
360
+ const sentMsg = await sock.sendMessage(id, { text: 'oh hello there' })
361
+ // send a reply messagge
362
+ const sentMsg = await sock.sendMessage(id, { text: 'oh hello there' }, { quoted: message })
363
+ // send a mentions message
364
+ const sentMsg = await sock.sendMessage(id, { text: '@12345678901', mentions: ['12345678901@s.whatsapp.net'] })
365
+ // send a location!
366
+ const sentMsg = await sock.sendMessage(
367
+ id,
368
+ { location: { degreesLatitude: 24.121231, degreesLongitude: 55.1121221 } }
369
+ )
370
+ // send a contact!
371
+ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
372
+ + 'VERSION:3.0\n'
373
+ + 'FN:Jeff Singh\n' // full name
374
+ + 'ORG:Ashoka Uni;\n' // the organization of the contact
375
+ + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
376
+ + 'END:VCARD'
377
+ const sentMsg = await sock.sendMessage(
378
+ id,
379
+ {
380
+ contacts: {
381
+ displayName: 'Jeff',
382
+ contacts: [{ vcard }]
383
+ }
384
+ }
385
+ )
386
+
387
+ const reactionMessage = {
388
+ react: {
389
+ text: "💖", // use an empty string to remove the reaction
390
+ key: message.key
391
+ }
392
+ }
393
+
394
+ const sendMsg = await sock.sendMessage(id, reactionMessage)
395
+ ```
396
+
397
+ ### Sending messages with link previews
398
+
399
+ 1. By default, WA MD does not have link generation when sent from the web
400
+ 2. Baileys has a function to generate the content for these link previews
401
+ 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
402
+ 4. Send a link:
403
+ ``` ts
404
+ // send a link
405
+ const sentMsg = await sock.sendMessage(id, { text: 'Hi, this was sent using https://github.com/adiwajshing/baileys' })
406
+ ```
407
+
408
+ ### Media Messages
409
+
410
+ Sending media (video, stickers, images) is easier & more efficient than ever.
411
+ - You can specify a buffer, a local url or even a remote url.
412
+ - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
413
+
414
+ ``` ts
415
+ import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
416
+ // Sending gifs
417
+ await sock.sendMessage(
418
+ id,
419
+ {
420
+ video: fs.readFileSync("Media/ma_gif.mp4"),
421
+ caption: "hello!",
422
+ gifPlayback: true
423
+ }
424
+ )
425
+
426
+ await sock.sendMessage(
427
+ id,
428
+ {
429
+ video: "./Media/ma_gif.mp4",
430
+ caption: "hello!",
431
+ gifPlayback: true,
432
+ ptv: false // if set to true, will send as a `video note`
433
+ }
434
+ )
435
+
436
+ // send an audio file
437
+ await sock.sendMessage(
438
+ id,
439
+ { audio: { url: "./Media/audio.mp3" }, mimetype: 'audio/mp4' }
440
+ { url: "Media/audio.mp3" }, // can send mp3, mp4, & ogg
441
+ )
442
+ ```
443
+
444
+ ### Notes
445
+
446
+ - `id` is the WhatsApp ID of the person or group you're sending the message to.
447
+ - It must be in the format ```[country code][phone number]@s.whatsapp.net```
448
+ - Example for people: ```+19999999999@s.whatsapp.net```.
449
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
450
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
451
+ - For stories, the ID is `status@broadcast`.
452
+ - 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`. Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
453
+ - **MiscGenerationOptions**: some extra info about the message. It can have the following __optional__ values:
454
+ ``` ts
455
+ const info: MessageOptions = {
456
+ quoted: quotedMessage, // the message you want to quote
457
+ contextInfo: { forwardingScore: 2, isForwarded: true }, // some random context info (can show a forwarded message with this too)
458
+ timestamp: Date(), // optional, if you want to manually set the timestamp of the message
459
+ caption: "hello there!", // (for media messages) the caption to send with the media (cannot be sent with stickers though)
460
+ jpegThumbnail: "23GD#4/==", /* (for location & media messages) has to be a base 64 encoded JPEG if you want to send a custom thumb,
461
+ or set to null if you don't want to send a thumbnail.
462
+ Do not enter this field if you want to automatically generate a thumb
463
+ */
464
+ mimetype: Mimetype.pdf, /* (for media messages) specify the type of media (optional for all media types except documents),
465
+ import {Mimetype} from '@queenanya/baileys'
466
+ */
467
+ fileName: 'somefile.pdf', // (for media messages) file name for the media
468
+ /* will send audio messages as voice notes, if set to true */
469
+ ptt: true,
470
+ /** Should it send as a disappearing messages.
471
+ * By default 'chat' -- which follows the setting of the chat */
472
+ ephemeralExpiration: WA_DEFAULT_EPHEMERAL
473
+ }
474
+ ```
475
+ ## Forwarding Messages
476
+
477
+ ``` ts
478
+ const msg = getMessageFromStore('455@s.whatsapp.net', 'HSJHJWH7323HSJSJ') // implement this on your end
479
+ await sock.sendMessage('1234@s.whatsapp.net', { forward: msg }) // WA forward the message!
480
+ ```
481
+
482
+ ## Reading Messages
483
+
484
+ A set of message keys must be explicitly marked read now.
485
+ In multi-device, you cannot mark an entire "chat" read as it were with Baileys Web.
486
+ This means you have to keep track of unread messages.
487
+
488
+ ``` ts
489
+ const key = {
490
+ remoteJid: '1234-123@g.us',
491
+ id: 'AHASHH123123AHGA', // id of the message you want to read
492
+ participant: '912121232@s.whatsapp.net' // the ID of the user that sent the message (undefined for individual chats)
493
+ }
494
+ // pass to readMessages function
495
+ // can pass multiple keys to read multiple messages as well
496
+ await sock.readMessages([key])
497
+ ```
498
+
499
+ The message ID is the unique identifier of the message that you are marking as read.
500
+ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
501
+
502
+ ## Update Presence
503
+
504
+ ``` ts
505
+ await sock.sendPresenceUpdate('available', id)
506
+
507
+ ```
508
+ This lets the person/group with ``` id ``` know whether you're online, offline, typing etc.
509
+
510
+ ``` presence ``` can be one of the following:
511
+ ``` ts
512
+ type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
513
+ ```
514
+
515
+ The presence expires after about 10 seconds.
516
+
517
+ **Note:** In the multi-device version of WhatsApp -- 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')`
518
+
519
+ ## Downloading Media Messages
520
+
521
+ If you want to save the media you received
522
+ ``` ts
523
+ import { writeFile } from 'fs/promises'
524
+ import { downloadMediaMessage } from '@queenanya/baileys'
525
+
526
+ sock.ev.on('messages.upsert', async ({ messages }) => {
527
+ const m = messages[0]
528
+
529
+ if (!m.message) return // if there is no text or media message
530
+ const messageType = Object.keys (m.message)[0]// get what type of message it is -- text, image, video
531
+ // if the message is an image
532
+ if (messageType === 'imageMessage') {
533
+ // download the message
534
+ const buffer = await downloadMediaMessage(
535
+ m,
536
+ 'buffer',
537
+ { },
538
+ {
539
+ logger,
540
+ // pass this so that baileys can request a reupload of media
541
+ // that has been deleted
542
+ reuploadRequest: sock.updateMediaMessage
543
+ }
544
+ )
545
+ // save to file
546
+ await writeFile('./my-download.jpeg', buffer)
547
+ }
548
+ }
549
+ ```
550
+
551
+ **Note:** 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:
552
+ ``` ts
553
+ const updatedMediaMsg = await sock.updateMediaMessage(msg)
554
+ ```
555
+
556
+ ## Deleting Messages
557
+
558
+ ``` ts
559
+ const jid = '1234@s.whatsapp.net' // can also be a group
560
+ const response = await sock.sendMessage(jid, { text: 'hello!' }) // send a message
561
+ // sends a message to delete the given message
562
+ // this deletes the message for everyone
563
+ await sock.sendMessage(jid, { delete: response.key })
564
+ ```
565
+
566
+ **Note:** deleting for oneself is supported via `chatModify` (next section)
567
+
568
+ ## Updating Messages
569
+
570
+ ``` ts
571
+ const jid = '1234@s.whatsapp.net'
572
+
573
+ await sock.sendMessage(jid, {
574
+ text: 'updated text goes here',
575
+ edit: response.key,
576
+ });
577
+ ```
578
+
579
+ ## Modifying Chats
580
+
581
+ WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
582
+
583
+ - Archive a chat
584
+ ``` ts
585
+ const lastMsgInChat = await getLastMessageInChat('123456@s.whatsapp.net') // implement this on your end
586
+ await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, '123456@s.whatsapp.net')
587
+ ```
588
+ - Mute/unmute a chat
589
+ ``` ts
590
+ // mute for 8 hours
591
+ await sock.chatModify({ mute: 8*60*60*1000 }, '123456@s.whatsapp.net', [])
592
+ // unmute
593
+ await sock.chatModify({ mute: null }, '123456@s.whatsapp.net', [])
594
+ ```
595
+ - Mark a chat read/unread
596
+ ``` ts
597
+ const lastMsgInChat = await getLastMessageInChat('123456@s.whatsapp.net') // implement this on your end
598
+ // mark it unread
599
+ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, '123456@s.whatsapp.net')
600
+ ```
601
+
602
+ - Delete a message for me
603
+ ``` ts
604
+ await sock.chatModify(
605
+ { clear: { messages: [{ id: 'ATWYHDNNWU81732J', fromMe: true, timestamp: "1654823909" }] } },
606
+ '123456@s.whatsapp.net',
607
+ []
608
+ )
609
+
610
+ ```
611
+
612
+ - Delete a chat
613
+ ``` ts
614
+ const lastMsgInChat = await getLastMessageInChat('123456@s.whatsapp.net') // implement this on your end
615
+ await sock.chatModify({
616
+ delete: true,
617
+ lastMessages: [{ key: lastMsgInChat.key, messageTimestamp: lastMsgInChat.messageTimestamp }]
618
+ },
619
+ '123456@s.whatsapp.net')
620
+ ```
621
+
622
+ - Pin/unpin a chat
623
+ ``` ts
624
+ await sock.chatModify({
625
+ pin: true // or `false` to unpin
626
+ },
627
+ '123456@s.whatsapp.net')
628
+ ```
629
+
630
+ - Star/unstar a message
631
+ ``` ts
632
+ await sock.chatModify({
633
+ star: {
634
+ messages: [{ id: 'messageID', fromMe: true // or `false` }],
635
+ star: true // - true: Star Message; false: Unstar Message
636
+ }},'123456@s.whatsapp.net');
637
+ ```
638
+
639
+ **Note:** 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.
640
+
641
+ ## Disappearing Messages
642
+
643
+ ``` ts
644
+ const jid = '1234@s.whatsapp.net' // can also be a group
645
+ // turn on disappearing messages
646
+ await sock.sendMessage(
647
+ jid,
648
+ // this is 1 week in seconds -- how long you want messages to appear for
649
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
650
+ )
651
+ // will send as a disappearing message
652
+ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
653
+ // turn off disappearing messages
654
+ await sock.sendMessage(
655
+ jid,
656
+ { disappearingMessagesInChat: false }
657
+ )
658
+
659
+ ```
660
+
661
+ ## Misc
662
+
663
+ - To check if a given ID is on WhatsApp
664
+ ``` ts
665
+ const id = '123456'
666
+ const [result] = await sock.onWhatsApp(id)
667
+ if (result.exists) console.log (`${id} exists on WhatsApp, as jid: ${result.jid}`)
668
+ ```
669
+ - To query chat history on a group or with someone
670
+ TODO, if possible
671
+ - To get the status of some person
672
+ ``` ts
673
+ const status = await sock.fetchStatus("xyz@s.whatsapp.net")
674
+ console.log("status: " + status)
675
+ ```
676
+ - To change your profile status
677
+ ``` ts
678
+ const status = 'Hello World!'
679
+ await sock.updateProfileStatus(status)
680
+ ```
681
+ - To change your profile name
682
+ ``` ts
683
+ const name = 'My name'
684
+ await sock.updateProfileName(name)
685
+ ```
686
+ - To get the display picture of some person/group
687
+ ``` ts
688
+ // for low res picture
689
+ const ppUrl = await sock.profilePictureUrl("xyz@g.us")
690
+ console.log("download profile picture from: " + ppUrl)
691
+ // for high res picture
692
+ const ppUrl = await sock.profilePictureUrl("xyz@g.us", 'image')
693
+ ```
694
+ - To change your display picture or a group's
695
+ ``` ts
696
+ const jid = '111234567890-1594482450@g.us' // can be your own too
697
+ await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
698
+ ```
699
+ - To remove your display picture or a group's
700
+ ``` ts
701
+ const jid = '111234567890-1594482450@g.us' // can be your own too
702
+ await sock.removeProfilePicture(jid)
703
+ ```
704
+ - To get someone's presence (if they're typing or online)
705
+ ``` ts
706
+ // the presence update is fetched and called here
707
+ sock.ev.on('presence.update', json => console.log(json))
708
+ // request updates for a chat
709
+ await sock.presenceSubscribe("xyz@s.whatsapp.net")
710
+ ```
711
+ - To block or unblock user
712
+ ``` ts
713
+ await sock.updateBlockStatus("xyz@s.whatsapp.net", "block") // Block user
714
+ await sock.updateBlockStatus("xyz@s.whatsapp.net", "unblock") // Unblock user
715
+ ```
716
+ - To get a business profile, such as description or category
717
+ ```ts
718
+ const profile = await sock.getBusinessProfile("xyz@s.whatsapp.net")
719
+ console.log("business description: " + profile.description + ", category: " + profile.category)
720
+ ```
721
+ Of course, replace ``` xyz ``` with an actual ID.
722
+
723
+ ## Groups
724
+ - To create a group
725
+ ``` ts
726
+ // title & participants
727
+ const group = await sock.groupCreate("My Fab Group", ["1234@s.whatsapp.net", "4564@s.whatsapp.net"])
728
+ console.log ("created group with id: " + group.gid)
729
+ sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
730
+ ```
731
+ - To add/remove people to a group or demote/promote people
732
+ ``` ts
733
+ // id & people to add to the group (will throw error if it fails)
734
+ const response = await sock.groupParticipantsUpdate(
735
+ "abcd-xyz@g.us",
736
+ ["abcd@s.whatsapp.net", "efgh@s.whatsapp.net"],
737
+ "add" // replace this parameter with "remove", "demote" or "promote"
738
+ )
739
+ ```
740
+ - To change the group's subject
741
+ ``` ts
742
+ await sock.groupUpdateSubject("abcd-xyz@g.us", "New Subject!")
743
+ ```
744
+ - To change the group's description
745
+ ``` ts
746
+ await sock.groupUpdateDescription("abcd-xyz@g.us", "New Description!")
747
+ ```
748
+ - To change group settings
749
+ ``` ts
750
+ // only allow admins to send messages
751
+ await sock.groupSettingUpdate("abcd-xyz@g.us", 'announcement')
752
+ // allow everyone to send messages
753
+ await sock.groupSettingUpdate("abcd-xyz@g.us", 'not_announcement')
754
+ // allow everyone to modify the group's settings -- like display picture etc.
755
+ await sock.groupSettingUpdate("abcd-xyz@g.us", 'unlocked')
756
+ // only allow admins to modify the group's settings
757
+ await sock.groupSettingUpdate("abcd-xyz@g.us", 'locked')
758
+ ```
759
+ - To leave a group
760
+ ``` ts
761
+ await sock.groupLeave("abcd-xyz@g.us") // (will throw error if it fails)
762
+ ```
763
+ - To get the invite code for a group
764
+ ``` ts
765
+ const code = await sock.groupInviteCode("abcd-xyz@g.us")
766
+ console.log("group code: " + code)
767
+ ```
768
+ - To revoke the invite code in a group
769
+ ```ts
770
+ const code = await sock.groupRevokeInvite("abcd-xyz@g.us")
771
+ console.log("New group code: " + code)
772
+ ```
773
+ - To query the metadata of a group
774
+ ``` ts
775
+ const metadata = await sock.groupMetadata("abcd-xyz@g.us")
776
+ console.log(metadata.id + ", title: " + metadata.subject + ", description: " + metadata.desc)
777
+ ```
778
+ - To join the group using the invitation code
779
+ ``` ts
780
+ const response = await sock.groupAcceptInvite("xxx")
781
+ console.log("joined to: " + response)
782
+ ```
783
+ Of course, replace ``` xxx ``` with invitation code.
784
+ - To get group info by invite code
785
+ ```ts
786
+ const response = await sock.groupGetInviteInfo("xxx")
787
+ console.log("group information: " + response)
788
+ ```
789
+ - To join the group using groupInviteMessage
790
+ ``` ts
791
+ const response = await sock.groupAcceptInviteV4("abcd@s.whatsapp.net", groupInviteMessage)
792
+ console.log("joined to: " + response)
793
+ ```
794
+ Of course, replace ``` xxx ``` with invitation code.
795
+
796
+ - To get list request join
797
+ ``` ts
798
+ const response = await sock.groupRequestParticipantsList("abcd-xyz@g.us")
799
+ console.log(response)
800
+ ```
801
+ - To approve/reject request join
802
+ ``` ts
803
+ const response = await sock.groupRequestParticipantsUpdate(
804
+ "abcd-xyz@g.us", // id group,
805
+ ["abcd@s.whatsapp.net", "efgh@s.whatsapp.net"],
806
+ "approve" // replace this parameter with "reject"
807
+ )
808
+ console.log(response)
809
+ ```
810
+
811
+
812
+ ## Channel
813
+ - To get newsletter info from code
814
+ ```ts
815
+ // https://whatsapp.com/channel/key
816
+ const key = '123wedss972279'
817
+ const result = await sock.getNewsletterInfo(key)
818
+ console.log(result)
819
+ ```
820
+ - To create newsletter
821
+ ```ts
822
+ const result = await sock.createNewsLetter('Name newsletter', 'Description news letter', { url: 'url profile pictur' })
823
+ console.log(result)
824
+ ```
825
+ - To get subscribed newsletters
826
+ ```ts
827
+
828
+ const result = await sock.getSubscribedNewsletters()
829
+ console.log(result)
830
+ ```
831
+ - To toggle mute newsletters
832
+ ```ts
833
+ const result = await sock.toggleMuteNewsletter(jid, true) // true to mute, false to unmute
834
+ console.log(result)
835
+ ```
836
+ - To follow newsletter
837
+ ```ts
838
+ const result = await sock.followNewsletter(jid)
839
+ console.log(result)
840
+ ```
841
+ - To unfollow newsletter
842
+ ```ts
843
+ const result = await sock.unFollowNewsletter(jid)
844
+ console.log(result)
845
+ ```
846
+
847
+ ## Privacy
848
+ - To get the privacy settings
849
+ ``` ts
850
+ const privacySettings = await sock.fetchPrivacySettings(true)
851
+ console.log("privacy settings: " + privacySettings)
852
+ ```
853
+ - To update the LastSeen privacy
854
+ ``` ts
855
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
856
+ await sock.updateLastSeenPrivacy(value)
857
+ ```
858
+ - To update the Online privacy
859
+ ``` ts
860
+ const value = 'all' // 'match_last_seen'
861
+ await sock.updateOnlinePrivacy(value)
862
+ ```
863
+ - To update the Profile Picture privacy
864
+ ``` ts
865
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
866
+ await sock.updateProfilePicturePrivacy(value)
867
+ ```
868
+ - To update the Status privacy
869
+ ``` ts
870
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
871
+ await sock.updateStatusPrivacy(value)
872
+ ```
873
+ - To update the Read Receipts privacy
874
+ ``` ts
875
+ const value = 'all' // 'none'
876
+ await sock.updateReadReceiptsPrivacy(value)
877
+ ```
878
+ - To update the Groups Add privacy
879
+ ``` ts
880
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
881
+ await sock.updateGroupsAddPrivacy(value)
882
+ ```
883
+ - To update the Default Disappearing Mode
884
+ ``` ts
885
+ const duration = 86400 // 604800 | 7776000 | 0
886
+ await sock.updateDefaultDisappearingMode(duration)
887
+ ```
888
+ ## Broadcast Lists & Stories
889
+
890
+ Messages can be sent to broadcasts & stories.
891
+ you need to add the following message options in sendMessage, like this:
892
+ ```ts
893
+ sock.sendMessage(jid, {image: {url: url}, caption: caption}, {backgroundColor : backgroundColor, font : font, statusJidList: statusJidList, broadcast : true})
894
+ ```
895
+ - the message body can be a extendedTextMessage or imageMessage or videoMessage or voiceMessage
896
+ - You can add backgroundColor and other options in the message options
897
+ - broadcast: true enables broadcast mode
898
+ - statusJidList: a list of people that you can get which you need to provide, which are the people who will get this status message.
899
+
900
+ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
901
+ - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
902
+ - Broadcast IDs are in the format `12345678@broadcast`
903
+ - To query a broadcast list's recipients & name:
904
+ ``` ts
905
+ const bList = await sock.getBroadcastListInfo("1234@broadcast")
906
+ console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
907
+ ```
908
+
909
+ ## Writing Custom Functionality
910
+ Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
911
+
912
+ First, enable the logging of unhandled messages from WhatsApp by setting:
913
+ ``` ts
914
+ const sock = makeWASocket({
915
+ logger: P({ level: 'debug' }),
916
+ })
917
+ ```
918
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
919
+
920
+ Some examples:
921
+
922
+ 1. Functionality to track the battery percentage of your phone.
923
+ You enable logging and you'll see a message about your battery pop up in the console:
924
+ ```{"level":10,"fromMe":false,"frame":{"tag":"ib","attrs":{"from":"@s.whatsapp.net"},"content":[{"tag":"edge_routing","attrs":{},"content":[{"tag":"routing_info","attrs":{},"content":{"type":"Buffer","data":[8,2,8,5]}}]}]},"msg":"communication"} ```
925
+
926
+ The "frame" is what the message received is, it has three components:
927
+ - `tag` -- what this frame is about (eg. message will have "message")
928
+ - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
929
+ - `content` -- the actual data (eg. a message node will have the actual message content in it)
930
+ - read more about this format [here](/src/WABinary/readme.md)
931
+
932
+ You can register a callback for an event using the following:
933
+ ``` ts
934
+ // for any message with tag 'edge_routing'
935
+ sock.ws.on(`CB:edge_routing`, (node: BinaryNode) => { })
936
+ // for any message with tag 'edge_routing' and id attribute = abcd
937
+ sock.ws.on(`CB:edge_routing,id:abcd`, (node: BinaryNode) => { })
938
+ // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
939
+ sock.ws.on(`CB:edge_routing,id:abcd,routing_info`, (node: BinaryNode) => { })
940
+ ```
941
+ Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1)