violetics 7.0.7-alpha → 7.0.9-alpha
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.
- package/LICENSE +1 -2
- package/README.md +493 -980
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +5479 -0
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +14017 -0
- package/WAProto/index.js +2670 -9199
- package/engine-requirements.js +7 -10
- package/index.cjs +196 -0
- package/index.d.ts +30 -0
- package/lib/Defaults/index.d.ts +74 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +14 -22
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +2 -1
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +2 -1
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +2 -1
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +2 -1
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +2 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +2 -1
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +2 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +2 -1
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +2 -1
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +2 -1
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +2 -1
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-message-key.js +2 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +44 -8
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +19 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +2 -1
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +2 -1
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +2 -1
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +2 -1
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +202 -0
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +2 -1
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +111 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +154 -69
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +258 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +2 -1
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/community.js +361 -0
- package/lib/Socket/groups.d.ts +150 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +140 -9
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +245 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +2 -1
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +187 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +471 -253
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +183 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +620 -226
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +2 -1
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +160 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +109 -62
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +55 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +12 -3
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Socket/usync.js +76 -0
- package/lib/Store/index.js +2 -1
- package/lib/Store/make-cache-manager-store.js +77 -0
- package/lib/Store/make-in-memory-store.js +44 -65
- package/lib/Store/make-ordered-dictionary.js +1 -1
- package/lib/Store/object-repository.js +1 -1
- package/lib/Types/Auth.d.ts +116 -0
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -1
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -1
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -1
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +123 -0
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +2 -1
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +24 -0
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -1
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +237 -0
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -1
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +67 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -1
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +2 -1
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +2 -1
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +305 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +2 -8
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/MexUpdates.js +9 -0
- package/lib/Types/Newsletter.d.ts +135 -0
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +14 -4
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -1
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +76 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -1
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +133 -0
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +2 -1
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +39 -0
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +2 -1
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -1
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +65 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +3 -1
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/audioToBuffer.js +31 -0
- package/lib/Utils/auth-utils.d.ts +19 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +2 -1
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/baileys-event-stream.js +54 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +35 -22
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +2 -1
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +2 -1
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +2 -1
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +48 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +2 -1
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +34 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +2 -1
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +91 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +34 -6
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +22 -0
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +2 -1
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +37 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +2 -1
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +22 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +7 -1
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +2 -1
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +13 -0
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +2 -1
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +8 -0
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +2 -1
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +9 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +2 -1
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +110 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +2 -1
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +130 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +185 -185
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages-newsletter.d.ts +84 -0
- package/lib/Utils/messages-newsletter.js +316 -0
- package/lib/Utils/messages.d.ts +92 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +932 -1120
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +2 -1
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +2 -1
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +2 -1
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +2 -1
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/resolve-jid.d.ts +43 -0
- package/lib/Utils/resolve-jid.js +101 -0
- package/lib/Utils/signal.d.ts +34 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +2 -1
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/streamToBuffer.js +17 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +2 -1
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +12 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +2 -1
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-mongo-file-auth-state.js +77 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +2 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/use-single-file-auth-state.js +55 -77
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +4 -10
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +2 -1
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +2 -1
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +2 -1
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +14 -113
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +3 -1
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +5 -2
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -1
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +2 -1
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +2 -1
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +2 -1
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +2 -1
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +3 -1
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +2 -1
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +13 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +2 -1
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +2 -1
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -2
- package/lib/index.js.map +1 -0
- package/package.json +75 -53
- package/.github/workflows/publish.yml +0 -75
- package/.pnp.cjs +0 -8572
- package/.pnp.loader.mjs +0 -2126
- package/.yarn/install-state.gz +0 -0
- package/lib/Utils/offline-node-processor.js +0 -39
- package/lib/Utils/stanza-ack.js +0 -37
package/README.md
CHANGED
|
@@ -1,1087 +1,600 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align='center'><img alt="Baileys logo" src="https://raw.githubusercontent.com/WhiskeySockets/Baileys/refs/heads/master/Media/logo.png" height="75"/></h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with WhatsApp Web.</div>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### ⚙️ Changes
|
|
8
|
-
|
|
9
|
-
#### 🛠️ Internal Adjustments
|
|
10
|
-
- 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
|
|
11
|
-
- 📁 Reintroduced [`makeInMemoryStore`](#%EF%B8%8F-implementing-a-data-store) with a minimal ESM adaptation and small adjustments for Baileys v7.
|
|
12
|
-
- 📦 Switched FFmpeg execution from `exec` to `spawn` for safer process handling.
|
|
13
|
-
- 🗃️ Added `@napi-rs/image` as a supported image processing backend in `getImageProcessingLibrary()`, offering a balance between performance and compatibility.
|
|
14
|
-
|
|
15
|
-
#### 📨 Message Handling & Compatibility
|
|
16
|
-
- 👉🏻 Added support for sending [interactive message](#-sending-interactive-messages) types (button, list, interactive, template, carousel).
|
|
17
|
-
- 📩 Added support for [album messages](#%EF%B8%8F-album-image--video), [group status messages](#4%EF%B8%8F⃣-group-status), [status mention messages](#%EF%B8%8F-status-mention), [sticker pack messages](#-sticker-pack), and several [payment-related messages](#-sending-payment-messages) (request payment, payment invite, order, invoice).
|
|
18
|
-
- 📰 Simplified sending messages with ad thumbnails via [`externalAdReply`](#3%EF%B8%8F⃣-external-ad-reply) without requiring manual `contextInfo`.
|
|
19
|
-
|
|
20
|
-
#### 🧩 Additional Message Options
|
|
21
|
-
- 👁️ Added optional boolean flags for message handling:
|
|
22
|
-
- [`ai`](#1%EF%B8%8F⃣-ai-label) - AI label on message
|
|
23
|
-
- [`mentionAll`](#-mention) - Mentions all group participants without requiring their JIDs in `mentions` or `mentionedJid`
|
|
24
|
-
- [`ephemeral`](#2%EF%B8%8F⃣-ephemeral), [`groupStatus`](#4%EF%B8%8F⃣-group-status), [`viewOnceV2`](#7%EF%B8%8F⃣-view-once-v2), [`viewOnceV2Extension`](#8%EF%B8%8F⃣-view-once-v2-extension), [`interactiveAsTemplate`](#3%EF%B8%8F⃣-interactive) - Message wrappers
|
|
25
|
-
- [`raw`](#5%EF%B8%8F⃣-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
|
|
26
|
-
|
|
27
|
-
> [!NOTE]
|
|
28
|
-
📄 This project is maintained with limited scope and is not intended to replace upstream Baileys.
|
|
5
|
+
> [!CAUTION]
|
|
6
|
+
> NOTICE OF BREAKING CHANGE.
|
|
29
7
|
>
|
|
30
|
-
>
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
> As of 1.0.0, multiple breaking changes were introduced into the library.
|
|
9
|
+
>
|
|
10
|
+
> Please check out https://whiskey.so/migrate-latest for more information.
|
|
33
11
|
|
|
34
|
-
|
|
12
|
+
# Important Note
|
|
35
13
|
|
|
36
|
-
|
|
37
|
-
# NPM
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"violetics": "latest"
|
|
40
|
-
}
|
|
14
|
+
This is a temporary README.md, the new guide is in development and will this file will be replaced with .github/README.md (already a default on GitHub).
|
|
41
15
|
|
|
42
|
-
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"violetics": "github:cv3inx/violetics"
|
|
45
|
-
}
|
|
46
|
-
```
|
|
16
|
+
New guide link: https://baileys.wiki
|
|
47
17
|
|
|
48
|
-
|
|
18
|
+
# Get Support
|
|
49
19
|
|
|
50
|
-
|
|
51
|
-
# NPM
|
|
52
|
-
npm i violetics@latest
|
|
20
|
+
If you'd like business to enterprise-level support from Rajeh, the current maintainer of Baileys, you can book a video chat. Book a 1 hour time slot by contacting him on Discord or pre-ordering [here](https://purpshell.dev/book). The earlier you pre-order the better, as his time slots usually fill up very quickly. He offers immense value per hour and will answer all your questions before the time runs out.
|
|
53
21
|
|
|
54
|
-
|
|
55
|
-
npm i github:cv3inx/violetics
|
|
56
|
-
```
|
|
22
|
+
If you are a business, we encourage you to contribute back to the high development costs of the project and to feed the maintainers who dump tens of hours a week on this. You can do so by booking meetings or sponsoring below. All support, even in bona fide / contribution hours, is welcome by businesses of all sizes. This is not condoning or endorsing businesses to use the library. See the Disclaimer below.
|
|
57
23
|
|
|
58
|
-
|
|
24
|
+
# Sponsor
|
|
59
25
|
|
|
60
|
-
|
|
61
|
-
// --- ESM
|
|
62
|
-
import { makeWASocket } from 'violetics'
|
|
26
|
+
If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
|
|
63
27
|
|
|
64
|
-
|
|
65
|
-
const { makeWASocket } = require('violetics')
|
|
66
|
-
```
|
|
28
|
+
# Disclaimer
|
|
67
29
|
|
|
68
|
-
|
|
30
|
+
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates.
|
|
31
|
+
The official WhatsApp website can be found at whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
|
|
69
32
|
|
|
70
|
-
|
|
33
|
+
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.
|
|
34
|
+
Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
|
|
71
35
|
|
|
72
|
-
|
|
73
|
-
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from 'violetics'
|
|
74
|
-
import { Boom } from '@hapi/boom'
|
|
75
|
-
import pino from 'pino'
|
|
36
|
+
##
|
|
76
37
|
|
|
77
|
-
|
|
78
|
-
|
|
38
|
+
- Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
|
|
39
|
+
- Not running Selenium or Chromium saves you like **half a gig** of ram :/
|
|
40
|
+
- Baileys supports interacting with the multi-device & web versions of WhatsApp.
|
|
41
|
+
- 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.
|
|
79
42
|
|
|
80
|
-
|
|
43
|
+
> [!IMPORTANT]
|
|
44
|
+
> The original repository had to be removed by the original author - we now continue development in this repository here.
|
|
45
|
+
> This is the only official repository and is maintained by the community.
|
|
46
|
+
> **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
|
|
81
47
|
|
|
82
|
-
|
|
83
|
-
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
84
|
-
|
|
85
|
-
const sock = makeWASocket({
|
|
86
|
-
logger,
|
|
87
|
-
auth: state
|
|
88
|
-
})
|
|
48
|
+
## Example
|
|
89
49
|
|
|
90
|
-
|
|
50
|
+
Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
|
|
51
|
+
The script covers most common use cases.
|
|
52
|
+
To run the example script, download or clone the repo and then type the following in a terminal:
|
|
91
53
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await delay(1500)
|
|
96
|
-
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
97
|
-
console.log('🔗 Pairing code', ':', code)
|
|
98
|
-
}
|
|
99
|
-
else if (connection === 'close') {
|
|
100
|
-
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
101
|
-
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
102
|
-
if (shouldReconnect) {
|
|
103
|
-
connectToWhatsApp()
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else if (connection === 'open') {
|
|
107
|
-
console.log('✅ Successfully connected to WhatsApp')
|
|
108
|
-
}
|
|
109
|
-
})
|
|
54
|
+
1. `cd path/to/Baileys`
|
|
55
|
+
2. `yarn`
|
|
56
|
+
3. `yarn example`
|
|
110
57
|
|
|
111
|
-
|
|
112
|
-
for (const message of messages) {
|
|
113
|
-
if (!message.message) continue
|
|
58
|
+
## Install
|
|
114
59
|
|
|
115
|
-
|
|
116
|
-
await sock.sendMessage(message.key.remoteJid, {
|
|
117
|
-
text: '👋🏻 Hello world'
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
}
|
|
60
|
+
Install dari file `.tgz` lokal (versi modified blckrose):
|
|
122
61
|
|
|
123
|
-
|
|
62
|
+
```
|
|
63
|
+
npm install ./blckrose-baileys-1.2.9.tgz
|
|
124
64
|
```
|
|
125
65
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
> [!CAUTION]
|
|
129
|
-
I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
|
|
130
|
-
|
|
131
|
-
```javascript
|
|
132
|
-
import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from 'violetics'
|
|
133
|
-
import { Boom } from '@hapi/boom'
|
|
134
|
-
import pino from 'pino'
|
|
135
|
-
|
|
136
|
-
const myPhoneNumber = '6288888888888'
|
|
137
|
-
|
|
138
|
-
// --- Create your store path
|
|
139
|
-
const storePath = './store.json'
|
|
140
|
-
|
|
141
|
-
const logger = pino({ level: 'silent' })
|
|
142
|
-
|
|
143
|
-
const connectToWhatsApp = async () => {
|
|
144
|
-
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
145
|
-
|
|
146
|
-
const sock = makeWASocket({
|
|
147
|
-
logger,
|
|
148
|
-
auth: state
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
const store = makeInMemoryStore({
|
|
152
|
-
logger,
|
|
153
|
-
socket: sock
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
store.bind(sock.ev)
|
|
157
|
-
|
|
158
|
-
sock.ev.on('creds.update', saveCreds)
|
|
159
|
-
|
|
160
|
-
sock.ev.on('connection.update', (update) => {
|
|
161
|
-
const { connection, lastDisconnect } = update
|
|
162
|
-
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
163
|
-
await delay(1500)
|
|
164
|
-
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
165
|
-
console.log('🔗 Pairing code', ':', code)
|
|
166
|
-
}
|
|
167
|
-
else if (connection === 'close') {
|
|
168
|
-
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
169
|
-
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
170
|
-
if (shouldReconnect) {
|
|
171
|
-
connectToWhatsApp()
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
else if (connection === 'open') {
|
|
175
|
-
console.log('✅ Successfully connected to WhatsApp')
|
|
176
|
-
}
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
sock.ev.on('chats.upsert', () => {
|
|
180
|
-
console.log('✉️ Got chats', store.chats.all())
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
sock.ev.on('contacts.upsert', () => {
|
|
184
|
-
console.log('👥 Got contacts', Object.values(store.contacts))
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
// --- Read store from file
|
|
188
|
-
store.readFromFile(storePath)
|
|
66
|
+
Atau tambahkan ke `package.json`:
|
|
189
67
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"violetics": ""
|
|
72
|
+
}
|
|
194
73
|
}
|
|
195
|
-
|
|
196
|
-
connectToWhatsApp()
|
|
197
74
|
```
|
|
198
75
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
76
|
+
Kemudian jalankan:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
npm install
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**ESM:**
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import makeWASocket from "violetics";
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**CJS (destructure langsung, tanpa top-level await):**
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
const {
|
|
92
|
+
makeWASocket,
|
|
93
|
+
useMultiFileAuthState,
|
|
94
|
+
Browsers,
|
|
95
|
+
DisconnectReason,
|
|
96
|
+
} = require("violetics");
|
|
97
|
+
// global apocalypse otomatis tersedia setelah baris di atas
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
# Links
|
|
101
|
+
|
|
102
|
+
- [Discord](https://discord.gg/WeJM5FP9GG)
|
|
103
|
+
- [Docs](https://guide.whiskeysockets.io/)
|
|
104
|
+
|
|
105
|
+
# Index
|
|
106
|
+
|
|
107
|
+
- [Connecting Account](#connecting-account)
|
|
108
|
+
- [Connect with QR-CODE](#starting-socket-with-qr-code)
|
|
109
|
+
- [Connect with Pairing Code](#starting-socket-with-pairing-code)
|
|
110
|
+
- [Receive Full History](#receive-full-history)
|
|
111
|
+
- [Important Notes About Socket Config](#important-notes-about-socket-config)
|
|
112
|
+
- [Caching Group Metadata (Recommended)](#caching-group-metadata-recommended)
|
|
113
|
+
- [Improve Retry System & Decrypt Poll Votes](#improve-retry-system--decrypt-poll-votes)
|
|
114
|
+
- [Receive Notifications in Whatsapp App](#receive-notifications-in-whatsapp-app)
|
|
115
|
+
|
|
116
|
+
- [Save Auth Info](#saving--restoring-sessions)
|
|
117
|
+
- [Handling Events](#handling-events)
|
|
118
|
+
- [Example to Start](#example-to-start)
|
|
119
|
+
- [Decrypt Poll Votes](#decrypt-poll-votes)
|
|
120
|
+
- [Summary of Events on First Connection](#summary-of-events-on-first-connection)
|
|
121
|
+
- [Implementing a Data Store](#implementing-a-data-store)
|
|
122
|
+
- [Whatsapp IDs Explain](#whatsapp-ids-explain)
|
|
123
|
+
- [Utility Functions](#utility-functions)
|
|
124
|
+
- [Newsletter / Channel](#newsletter--channel)
|
|
125
|
+
- [Kirim Media ke Channel](#kirim-media-ke-channel)
|
|
126
|
+
- [Button di Channel](#button-di-channel)
|
|
127
|
+
- [Edit & Hapus Pesan Channel](#edit--hapus-pesan-channel)
|
|
128
|
+
- [Resolve JID (LID → Phone)](#resolve-jid)
|
|
129
|
+
- [Sending Messages](#sending-messages)
|
|
130
|
+
- [Non-Media Messages](#non-media-messages)
|
|
131
|
+
- [Text Message](#text-message)
|
|
132
|
+
- [Quote Message](#quote-message-works-with-all-types)
|
|
133
|
+
- [Mention User](#mention-user-works-with-most-types)
|
|
134
|
+
- [Forward Messages](#forward-messages)
|
|
135
|
+
- [Location Message](#location-message)
|
|
136
|
+
- [Live Location Message](#live-location-message)
|
|
137
|
+
- [Contact Message](#contact-message)
|
|
138
|
+
- [Reaction Message](#reaction-message)
|
|
139
|
+
- [Pin Message](#pin-message)
|
|
140
|
+
- [Keep Message](#keep-message)
|
|
141
|
+
- [Poll Message](#poll-message)
|
|
142
|
+
- [Poll Result Message](#poll-result-message)
|
|
143
|
+
- [Call Message](#call-message)
|
|
144
|
+
- [Event Message](#event-message)
|
|
145
|
+
- [Order Message](#order-message)
|
|
146
|
+
- [Product Message](#product-message)
|
|
147
|
+
- [Payment Message](#payment-message)
|
|
148
|
+
- [Payment Invite Message](#payment-invite-message)
|
|
149
|
+
- [Admin Invite Message](#admin-invite-message)
|
|
150
|
+
- [Group Invite Message](#group-invite-message)
|
|
151
|
+
- [Sticker Pack Message](#sticker-pack-message)
|
|
152
|
+
- [Share Phone Number Message](#share-phone-number-message)
|
|
153
|
+
- [Request Phone Number Message](#request-phone-number-message)
|
|
154
|
+
- [Buttons Reply Message](#buttons-reply-message)
|
|
155
|
+
- [Buttons Message](#buttons-message)
|
|
156
|
+
- [Buttons List Message](#buttons-list-message)
|
|
157
|
+
- [Buttons Product List Message](#buttons-product-list-message)
|
|
158
|
+
- [Buttons Cards Message](#buttons-cards-message)
|
|
159
|
+
- [Buttons Template Message](#buttons-template-message)
|
|
160
|
+
- [Buttons Interactive Message](#buttons-interactive-message)
|
|
161
|
+
- [Buttons Interactive Message PIX](#buttons-interactive-message-pix)
|
|
162
|
+
- [Buttons Interactive Message PAY](#buttons-interactive-message-pay)
|
|
163
|
+
- [Status Mentions Message](#status-mentions-message)
|
|
164
|
+
- [Shop Message](#shop-message)
|
|
165
|
+
- [Collection Message](#collection-message)
|
|
166
|
+
- [AI Icon Feature](#ai-icon-feature)
|
|
167
|
+
- [Sending with Link Preview](#sending-messages-with-link-previews)
|
|
168
|
+
- [Media Messages](#media-messages)
|
|
169
|
+
- [Gif Message](#gif-message)
|
|
170
|
+
- [Video Message](#video-message)
|
|
171
|
+
- [Audio Message](#audio-message)
|
|
172
|
+
- [Image Message](#image-message)
|
|
173
|
+
- [Album Message](#album-message)
|
|
174
|
+
- [Ptv Video Message](#ptv-video-message)
|
|
175
|
+
- [View Once Message](#view-once-message)
|
|
176
|
+
- [Modify Messages](#modify-messages)
|
|
177
|
+
- [Delete Messages (for everyone)](#deleting-messages-for-everyone)
|
|
178
|
+
- [Edit Messages](#editing-messages)
|
|
179
|
+
- [Manipulating Media Messages](#manipulating-media-messages)
|
|
180
|
+
- [Thumbnail in Media Messages](#thumbnail-in-media-messages)
|
|
181
|
+
- [Downloading Media Messages](#downloading-media-messages)
|
|
182
|
+
- [Re-upload Media Message to Whatsapp](#re-upload-media-message-to-whatsapp)
|
|
183
|
+
- [Reject Call](#reject-call)
|
|
184
|
+
- [Send States in Chat](#send-states-in-chat)
|
|
185
|
+
- [Reading Messages](#reading-messages)
|
|
186
|
+
- [Update Presence](#update-presence)
|
|
187
|
+
- [Modifying Chats](#modifying-chats)
|
|
188
|
+
- [Archive a Chat](#archive-a-chat)
|
|
189
|
+
- [Mute/Unmute a Chat](#muteunmute-a-chat)
|
|
190
|
+
- [Mark a Chat Read/Unread](#mark-a-chat-readunread)
|
|
191
|
+
- [Delete a Message for Me](#delete-a-message-for-me)
|
|
192
|
+
- [Delete a Chat](#delete-a-chat)
|
|
193
|
+
- [Star/Unstar a Message](#starunstar-a-message)
|
|
194
|
+
- [Disappearing Messages](#disappearing-messages)
|
|
195
|
+
- [Clear Messages](#clear-messages)
|
|
196
|
+
- [User Querys](#user-querys)
|
|
197
|
+
- [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
|
|
198
|
+
- [Query Chat History (groups too)](#query-chat-history-groups-too)
|
|
199
|
+
- [Fetch Status](#fetch-status)
|
|
200
|
+
- [Fetch Profile Picture (groups too)](#fetch-profile-picture-groups-too)
|
|
201
|
+
- [Fetch Bussines Profile (such as description or category)](#fetch-bussines-profile-such-as-description-or-category)
|
|
202
|
+
- [Fetch Someone's Presence (if they're typing or online)](#fetch-someones-presence-if-theyre-typing-or-online)
|
|
203
|
+
- [Change Profile](#change-profile)
|
|
204
|
+
- [Change Profile Status](#change-profile-status)
|
|
205
|
+
- [Change Profile Name](#change-profile-name)
|
|
206
|
+
- [Change Display Picture (groups too)](#change-display-picture-groups-too)
|
|
207
|
+
- [Remove display picture (groups too)](#remove-display-picture-groups-too)
|
|
208
|
+
- [Groups](#groups)
|
|
209
|
+
- [Create a Group](#create-a-group)
|
|
210
|
+
- [Add/Remove or Demote/Promote](#addremove-or-demotepromote)
|
|
211
|
+
- [Change Subject (name)](#change-subject-name)
|
|
212
|
+
- [Change Description](#change-description)
|
|
213
|
+
- [Change Settings](#change-settings)
|
|
214
|
+
- [Leave a Group](#leave-a-group)
|
|
215
|
+
- [Get Invite Code](#get-invite-code)
|
|
216
|
+
- [Revoke Invite Code](#revoke-invite-code)
|
|
217
|
+
- [Join Using Invitation Code](#join-using-invitation-code)
|
|
218
|
+
- [Get Group Info by Invite Code](#get-group-info-by-invite-code)
|
|
219
|
+
- [Query Metadata (participants, name, description...)](#query-metadata-participants-name-description)
|
|
220
|
+
- [Join using groupInviteMessage](#join-using-groupinvitemessage)
|
|
221
|
+
- [Get Request Join List](#get-request-join-list)
|
|
222
|
+
- [Approve/Reject Request Join](#approvereject-request-join)
|
|
223
|
+
- [Get All Participating Groups Metadata](#get-all-participating-groups-metadata)
|
|
224
|
+
- [Toggle Ephemeral](#toggle-ephemeral)
|
|
225
|
+
- [Change Add Mode](#change-add-mode)
|
|
226
|
+
- [Privacy](#privacy)
|
|
227
|
+
- [Block/Unblock User](#blockunblock-user)
|
|
228
|
+
- [Get Privacy Settings](#get-privacy-settings)
|
|
229
|
+
- [Get BlockList](#get-blocklist)
|
|
230
|
+
- [Update LastSeen Privacy](#update-lastseen-privacy)
|
|
231
|
+
- [Update Online Privacy](#update-online-privacy)
|
|
232
|
+
- [Update Profile Picture Privacy](#update-profile-picture-privacy)
|
|
233
|
+
- [Update Status Privacy](#update-status-privacy)
|
|
234
|
+
- [Update Read Receipts Privacy](#update-read-receipts-privacy)
|
|
235
|
+
- [Update Groups Add Privacy](#update-groups-add-privacy)
|
|
236
|
+
- [Update Default Disappearing Mode](#update-default-disappearing-mode)
|
|
237
|
+
- [Broadcast Lists & Stories](#broadcast-lists--stories)
|
|
238
|
+
- [Send Broadcast & Stories](#send-broadcast--stories)
|
|
239
|
+
- [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
|
|
240
|
+
- [Writing Custom Functionality](#writing-custom-functionality)
|
|
241
|
+
- [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
|
|
242
|
+
- [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
|
|
243
|
+
- [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
|
|
244
|
+
|
|
245
|
+
## Connecting Account
|
|
246
|
+
|
|
247
|
+
WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a **QR code** or **Pairing Code** with WhatsApp on your phone.
|
|
210
248
|
|
|
211
249
|
> [!NOTE]
|
|
212
|
-
|
|
250
|
+
> **[Here](#example-to-start) is a simple example of event handling**
|
|
213
251
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
```javascript
|
|
217
|
-
sock.sendMessage(jid, {
|
|
218
|
-
text: '👋🏻 Hello'
|
|
219
|
-
}, {
|
|
220
|
-
quoted: message
|
|
221
|
-
})
|
|
222
|
-
```
|
|
252
|
+
> [!TIP]
|
|
253
|
+
> **You can see all supported socket configs [here](https://baileys.whiskeysockets.io/types/SocketConfig.html) (Recommended)**
|
|
223
254
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
```javascript
|
|
227
|
-
// --- Regular mention
|
|
228
|
-
sock.sendMessage(jid, {
|
|
229
|
-
text: '👋🏻 Hello @628123456789',
|
|
230
|
-
mentions: ['628123456789@s.whatsapp.net']
|
|
231
|
-
}, {
|
|
232
|
-
quoted: message
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
// --- Mention all
|
|
236
|
-
sock.sendMessage(jid, {
|
|
237
|
-
text: '👋🏻 Hello @all',
|
|
238
|
-
mentionAll: true
|
|
239
|
-
}, {
|
|
240
|
-
quoted: message
|
|
241
|
-
})
|
|
242
|
-
```
|
|
255
|
+
### Starting socket with **QR-CODE**
|
|
243
256
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
```javascript
|
|
247
|
-
sock.sendMessage(jid, {
|
|
248
|
-
react: {
|
|
249
|
-
key: message.key,
|
|
250
|
-
text: '✨'
|
|
251
|
-
}
|
|
252
|
-
}, {
|
|
253
|
-
quoted: message
|
|
254
|
-
})
|
|
255
|
-
```
|
|
257
|
+
> [!TIP]
|
|
258
|
+
> You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
|
|
256
259
|
|
|
257
|
-
|
|
260
|
+
```ts
|
|
261
|
+
import makeWASocket from "violetics";
|
|
258
262
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}, {
|
|
265
|
-
quoted: message
|
|
266
|
-
})
|
|
263
|
+
const sock = makeWASocket({
|
|
264
|
+
// can provide additional config here
|
|
265
|
+
browser: Browsers.ubuntu("My App"),
|
|
266
|
+
printQRInTerminal: true,
|
|
267
|
+
});
|
|
267
268
|
```
|
|
268
269
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
```javascript
|
|
272
|
-
const vcard = 'BEGIN:VCARD\n'
|
|
273
|
-
+ 'VERSION:3.0\n'
|
|
274
|
-
+ 'FN:Lia Wynn\n'
|
|
275
|
-
+ 'ORG:Waiters;\n'
|
|
276
|
-
+ 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
|
|
277
|
-
+ 'END:VCARD'
|
|
278
|
-
|
|
279
|
-
sock.sendMessage(jid, {
|
|
280
|
-
contacts: {
|
|
281
|
-
displayName: 'Lia',
|
|
282
|
-
contacts: [
|
|
283
|
-
{ vcard }
|
|
284
|
-
]
|
|
285
|
-
}
|
|
286
|
-
}, {
|
|
287
|
-
quoted: message
|
|
288
|
-
})
|
|
289
|
-
```
|
|
270
|
+
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!
|
|
290
271
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
```javascript
|
|
294
|
-
sock.sendMessage(jid, {
|
|
295
|
-
location: {
|
|
296
|
-
degreesLatitude: 24.121231,
|
|
297
|
-
degreesLongitude: 55.1121221,
|
|
298
|
-
name: '👋🏻 I am here'
|
|
299
|
-
}
|
|
300
|
-
}, {
|
|
301
|
-
quoted: message
|
|
302
|
-
})
|
|
303
|
-
```
|
|
272
|
+
### Starting socket with **Pairing Code**
|
|
304
273
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
```javascript
|
|
308
|
-
// --- Regular poll message
|
|
309
|
-
sock.sendMessage(jid, {
|
|
310
|
-
poll: {
|
|
311
|
-
name: '🔥 Voting time',
|
|
312
|
-
values: ['Yes', 'No'],
|
|
313
|
-
selectableCount: 1,
|
|
314
|
-
toAnnouncementGroup: false
|
|
315
|
-
}
|
|
316
|
-
}, {
|
|
317
|
-
quoted: message
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
// --- Quiz (only for newsletter)
|
|
321
|
-
sock.sendMessage('1211111111111@newsletter', {
|
|
322
|
-
poll: {
|
|
323
|
-
name: '🔥 Quiz',
|
|
324
|
-
values: ['Yes', 'No'],
|
|
325
|
-
correctAnswer: 'Yes',
|
|
326
|
-
pollType: 1
|
|
327
|
-
}
|
|
328
|
-
}, {
|
|
329
|
-
quoted: message
|
|
330
|
-
})
|
|
331
|
-
|
|
332
|
-
// --- Poll result
|
|
333
|
-
sock.sendMessage(jid, {
|
|
334
|
-
pollResult: {
|
|
335
|
-
name: '📝 Poll Result',
|
|
336
|
-
votes: [{
|
|
337
|
-
name: 'Nice',
|
|
338
|
-
voteCount: 10
|
|
339
|
-
}, {
|
|
340
|
-
name: 'Nah',
|
|
341
|
-
voteCount: 2
|
|
342
|
-
}],
|
|
343
|
-
pollType: 0 // Or 1 for quiz
|
|
344
|
-
}
|
|
345
|
-
}, {
|
|
346
|
-
quoted: message
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
// --- Poll update
|
|
350
|
-
sock.sendMessage(jid, {
|
|
351
|
-
pollUpdate: {
|
|
352
|
-
metadata: {},
|
|
353
|
-
key: message.key,
|
|
354
|
-
vote: {
|
|
355
|
-
enclv: /* <Buffer> */,
|
|
356
|
-
encPayload: /* <Buffer> */
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}, {
|
|
360
|
-
quoted: message
|
|
361
|
-
})
|
|
362
|
-
```
|
|
274
|
+
> [!IMPORTANT]
|
|
275
|
+
> Pairing Code isn't Mobile API, it's a method to connect Whatsapp Web without QR-CODE, you can connect only with one device, see [here](https://faq.whatsapp.com/1324084875126592/?cms_platform=web)
|
|
363
276
|
|
|
364
|
-
|
|
277
|
+
The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
|
|
365
278
|
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
text: 'Hello! 👋🏻'
|
|
369
|
-
})
|
|
370
|
-
```
|
|
279
|
+
```ts
|
|
280
|
+
import makeWASocket from "violetics";
|
|
371
281
|
|
|
372
|
-
|
|
282
|
+
const sock = makeWASocket({
|
|
283
|
+
// can provide additional config here
|
|
284
|
+
printQRInTerminal: false, //need to be false
|
|
285
|
+
});
|
|
373
286
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
```javascript
|
|
380
|
-
sock.sendMessage(jid, {
|
|
381
|
-
image: {
|
|
382
|
-
url: './path/to/image.jpg'
|
|
383
|
-
},
|
|
384
|
-
caption: '🔥 Superb'
|
|
385
|
-
}, {
|
|
386
|
-
quoted: message
|
|
387
|
-
})
|
|
287
|
+
if (!sock.authState.creds.registered) {
|
|
288
|
+
const number = "XXXXXXXXXXX";
|
|
289
|
+
const code = await sock.requestPairingCode(number);
|
|
290
|
+
console.log(code);
|
|
291
|
+
}
|
|
388
292
|
```
|
|
389
293
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
```javascript
|
|
393
|
-
sock.sendMessage(jid, {
|
|
394
|
-
video: {
|
|
395
|
-
url: './path/to/video.mp4'
|
|
396
|
-
},
|
|
397
|
-
gifPlayback: false, // --- Set true if you want to send video as GIF
|
|
398
|
-
ptv: false, // --- Set true if you want to send video as PTV
|
|
399
|
-
caption: '🔥 Superb'
|
|
400
|
-
}, {
|
|
401
|
-
quoted: message
|
|
402
|
-
})
|
|
403
|
-
```
|
|
294
|
+
### Receive Full History
|
|
404
295
|
|
|
405
|
-
|
|
296
|
+
1. Set `syncFullHistory` as `true`
|
|
297
|
+
2. Baileys, by default, use chrome browser config
|
|
298
|
+
- If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
|
|
406
299
|
|
|
407
|
-
```
|
|
408
|
-
sock
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
})
|
|
300
|
+
```ts
|
|
301
|
+
const sock = makeWASocket({
|
|
302
|
+
...otherOpts,
|
|
303
|
+
// can use Windows, Ubuntu here too
|
|
304
|
+
browser: Browsers.macOS("Desktop"),
|
|
305
|
+
syncFullHistory: true,
|
|
306
|
+
});
|
|
415
307
|
```
|
|
416
308
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
```javascript
|
|
420
|
-
sock.sendMessage(jid, {
|
|
421
|
-
audio: {
|
|
422
|
-
url: './path/to/audio.mp3'
|
|
423
|
-
},
|
|
424
|
-
ptt: false, // --- Set true if you want to send audio as Voice Note
|
|
425
|
-
}, {
|
|
426
|
-
quoted: message
|
|
427
|
-
})
|
|
428
|
-
```
|
|
309
|
+
## Important Notes About Socket Config
|
|
429
310
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
```javascript
|
|
433
|
-
sock.sendMessage(jid, {
|
|
434
|
-
album: [{
|
|
435
|
-
image: {
|
|
436
|
-
url: './path/to/image.jpg'
|
|
437
|
-
},
|
|
438
|
-
caption: '1st image'
|
|
439
|
-
}, {
|
|
440
|
-
video: {
|
|
441
|
-
url: './path/to/video.mp4'
|
|
442
|
-
},
|
|
443
|
-
caption: '1st video'
|
|
444
|
-
}, {
|
|
445
|
-
image: {
|
|
446
|
-
url: './path/to/image.jpg'
|
|
447
|
-
},
|
|
448
|
-
caption: '2nd image'
|
|
449
|
-
}, {
|
|
450
|
-
video: {
|
|
451
|
-
url: './path/to/video.mp4'
|
|
452
|
-
},
|
|
453
|
-
caption: '2nd video'
|
|
454
|
-
}]
|
|
455
|
-
}, {
|
|
456
|
-
quoted: message
|
|
457
|
-
})
|
|
458
|
-
```
|
|
311
|
+
### Caching Group Metadata (Recommended)
|
|
459
312
|
|
|
460
|
-
|
|
313
|
+
- If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
|
|
461
314
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
```javascript
|
|
466
|
-
sock.sendMessage(jid, {
|
|
467
|
-
cover: {
|
|
468
|
-
url: './path/to/image.webp'
|
|
469
|
-
},
|
|
470
|
-
stickers: [{
|
|
471
|
-
data: {
|
|
472
|
-
url: './path/to/image.webp'
|
|
473
|
-
}
|
|
474
|
-
}, {
|
|
475
|
-
data: {
|
|
476
|
-
url: './path/to/image.webp'
|
|
477
|
-
}
|
|
478
|
-
}, {
|
|
479
|
-
data: {
|
|
480
|
-
url: './path/to/image.webp'
|
|
481
|
-
}
|
|
482
|
-
}],
|
|
483
|
-
name: '📦 My Sticker Pack',
|
|
484
|
-
publisher: '🌟 Lia Wynn',
|
|
485
|
-
description: 'violetics'
|
|
486
|
-
}, {
|
|
487
|
-
quoted: message
|
|
488
|
-
})
|
|
489
|
-
```
|
|
315
|
+
```ts
|
|
316
|
+
const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false });
|
|
490
317
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
```javascript
|
|
496
|
-
// --- Regular buttons message
|
|
497
|
-
sock.sendMessage(jid, {
|
|
498
|
-
text: '👆🏻 Buttons!',
|
|
499
|
-
footer: 'violetics',
|
|
500
|
-
buttons: [{
|
|
501
|
-
text: '👋🏻 SignUp',
|
|
502
|
-
id: '#SignUp'
|
|
503
|
-
}]
|
|
504
|
-
}, {
|
|
505
|
-
quoted: message
|
|
506
|
-
})
|
|
507
|
-
|
|
508
|
-
// --- Buttons with Media & Native Flow
|
|
509
|
-
sock.sendMessage(jid, {
|
|
510
|
-
image: {
|
|
511
|
-
url: './path/to/image.jpg'
|
|
512
|
-
},
|
|
513
|
-
caption: '👆🏻 Buttons and Native Flow!',
|
|
514
|
-
footer: 'violetics',
|
|
515
|
-
buttons: [{
|
|
516
|
-
text: '👋🏻 Rating',
|
|
517
|
-
id: '#Rating'
|
|
518
|
-
}, {
|
|
519
|
-
text: '📋 Select',
|
|
520
|
-
sections: [{
|
|
521
|
-
title: '✨ Section 1',
|
|
522
|
-
rows: [{
|
|
523
|
-
header: '',
|
|
524
|
-
title: '💭 Secret Ingredient',
|
|
525
|
-
description: '',
|
|
526
|
-
id: '#SecretIngredient'
|
|
527
|
-
}]
|
|
528
|
-
}, {
|
|
529
|
-
title: '✨ Section 2',
|
|
530
|
-
highlight_label: '🔥 Popular',
|
|
531
|
-
rows: [{
|
|
532
|
-
header: '',
|
|
533
|
-
title: '🏷️ Coupon',
|
|
534
|
-
description: '',
|
|
535
|
-
id: '#CouponCode'
|
|
536
|
-
}]
|
|
537
|
-
}]
|
|
538
|
-
}]
|
|
539
|
-
}, {
|
|
540
|
-
quoted: message
|
|
541
|
-
})
|
|
542
|
-
```
|
|
318
|
+
const sock = makeWASocket({
|
|
319
|
+
cachedGroupMetadata: async (jid) => groupCache.get(jid),
|
|
320
|
+
});
|
|
543
321
|
|
|
544
|
-
|
|
322
|
+
sock.ev.on("groups.update", async ([event]) => {
|
|
323
|
+
const metadata = await sock.groupMetadata(event.id);
|
|
324
|
+
groupCache.set(event.id, metadata);
|
|
325
|
+
});
|
|
545
326
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
text: '📋 List!',
|
|
552
|
-
footer: 'violetics',
|
|
553
|
-
buttonText: '📋 Select',
|
|
554
|
-
title: '👋🏻 Hello',
|
|
555
|
-
sections: [{
|
|
556
|
-
title: '🚀 Menu 1',
|
|
557
|
-
rows: [{
|
|
558
|
-
title: '✨ AI',
|
|
559
|
-
description: '',
|
|
560
|
-
rowId: '#AI'
|
|
561
|
-
}]
|
|
562
|
-
}, {
|
|
563
|
-
title: '🌱 Menu 2',
|
|
564
|
-
rows: [{
|
|
565
|
-
title: '🔍 Search',
|
|
566
|
-
description: '',
|
|
567
|
-
rowId: '#Search'
|
|
568
|
-
}]
|
|
569
|
-
}]
|
|
570
|
-
}, {
|
|
571
|
-
quoted: message
|
|
572
|
-
})
|
|
573
|
-
```
|
|
327
|
+
sock.ev.on("group-participants.update", async (event) => {
|
|
328
|
+
const metadata = await sock.groupMetadata(event.id);
|
|
329
|
+
groupCache.set(event.id, metadata);
|
|
330
|
+
});
|
|
331
|
+
```
|
|
574
332
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
```javascript
|
|
578
|
-
// --- Native Flow
|
|
579
|
-
sock.sendMessage(jid, {
|
|
580
|
-
image: {
|
|
581
|
-
url: './path/to/image.jpg'
|
|
582
|
-
},
|
|
583
|
-
caption: '🗄️ Interactive!',
|
|
584
|
-
footer: 'violetics',
|
|
585
|
-
optionText: '👉🏻 Select Options', // --- Optional, wrap all native flow into a single list
|
|
586
|
-
optionTitle: '📄 Select Options', // --- Optional
|
|
587
|
-
couponText: '🏷️ Newest Coupon!', // --- Optional, add coupon into message
|
|
588
|
-
couponCode: 'violetics', // --- Optional
|
|
589
|
-
nativeFlow: [{
|
|
590
|
-
text: '👋🏻 Greeting',
|
|
591
|
-
id: '#Greeting'
|
|
592
|
-
}, {
|
|
593
|
-
text: '📞 Call',
|
|
594
|
-
call: '628123456789'
|
|
595
|
-
}, {
|
|
596
|
-
text: '📋 Copy',
|
|
597
|
-
copy: 'violetics'
|
|
598
|
-
}, {
|
|
599
|
-
text: '🌐 Source',
|
|
600
|
-
url: 'https://www.npmjs.com/package/baileys'
|
|
601
|
-
}, {
|
|
602
|
-
text: '📋 Select',
|
|
603
|
-
sections: [{
|
|
604
|
-
title: '✨ Section 1',
|
|
605
|
-
rows: [{
|
|
606
|
-
header: '',
|
|
607
|
-
title: '🏷️ Coupon',
|
|
608
|
-
description: '',
|
|
609
|
-
id: '#CouponCode'
|
|
610
|
-
}]
|
|
611
|
-
}, {
|
|
612
|
-
title: '✨ Section 2',
|
|
613
|
-
highlight_label: '🔥 Popular',
|
|
614
|
-
rows: [{
|
|
615
|
-
header: '',
|
|
616
|
-
title: '💭 Secret Ingredient',
|
|
617
|
-
description: '',
|
|
618
|
-
id: '#SecretIngredient'
|
|
619
|
-
}]
|
|
620
|
-
}]
|
|
621
|
-
}],
|
|
622
|
-
interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
|
|
623
|
-
}, {
|
|
624
|
-
quoted: message
|
|
625
|
-
})
|
|
626
|
-
|
|
627
|
-
// --- Carousel & Native Flow
|
|
628
|
-
sock.sendMessage(jid, {
|
|
629
|
-
text: '🗂️ Interactive with Carousel!',
|
|
630
|
-
footer: 'violetics',
|
|
631
|
-
cards: [{
|
|
632
|
-
image: {
|
|
633
|
-
url: './path/to/image.jpg'
|
|
634
|
-
},
|
|
635
|
-
caption: '🖼️ Image 1',
|
|
636
|
-
footer: '🏷️️ Pinterest',
|
|
637
|
-
nativeFlow: [{
|
|
638
|
-
text: '🌐 Source',
|
|
639
|
-
url: 'https://www.npmjs.com/package/baileys'
|
|
640
|
-
}]
|
|
641
|
-
}, {
|
|
642
|
-
image: {
|
|
643
|
-
url: './path/to/image.jpg'
|
|
644
|
-
},
|
|
645
|
-
caption: '🖼️ Image 2',
|
|
646
|
-
footer: '🏷️ Pinterest',
|
|
647
|
-
couponText: '🏷️ New Coupon!',
|
|
648
|
-
couponCode: 'violetics',
|
|
649
|
-
nativeFlow: [{
|
|
650
|
-
text: '🌐 Source',
|
|
651
|
-
url: 'https://www.npmjs.com/package/baileys'
|
|
652
|
-
}]
|
|
653
|
-
}, {
|
|
654
|
-
image: {
|
|
655
|
-
url: './path/to/image.jpg'
|
|
656
|
-
},
|
|
657
|
-
caption: '🖼️ Image 3',
|
|
658
|
-
footer: '🏷️ Pinterest',
|
|
659
|
-
optionText: '👉🏻 Select Options',
|
|
660
|
-
optionTitle: '📄 Select Options',
|
|
661
|
-
couponText: '🏷️ New Coupon!',
|
|
662
|
-
couponCode: 'violetics',
|
|
663
|
-
nativeFlow: [{
|
|
664
|
-
text: '🛒 Product',
|
|
665
|
-
id: '#Product'
|
|
666
|
-
}, {
|
|
667
|
-
text: '🌐 Source',
|
|
668
|
-
url: 'https://www.npmjs.com/package/baileys'
|
|
669
|
-
}]
|
|
670
|
-
}]
|
|
671
|
-
}, {
|
|
672
|
-
quoted: message
|
|
673
|
-
})
|
|
674
|
-
```
|
|
333
|
+
### Improve Retry System & Decrypt Poll Votes
|
|
675
334
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
url: './path/to/image.jpg'
|
|
683
|
-
},
|
|
684
|
-
caption: '🫙 Template!',
|
|
685
|
-
footer: 'violetics',
|
|
686
|
-
templateButtons: [{
|
|
687
|
-
text: '👉🏻 Tap Here',
|
|
688
|
-
id: '#Order'
|
|
689
|
-
}, {
|
|
690
|
-
text: '🌐 Source',
|
|
691
|
-
url: 'https://www.npmjs.com/package/baileys'
|
|
692
|
-
}, {
|
|
693
|
-
text: '📞 Call',
|
|
694
|
-
call: '628123456789'
|
|
695
|
-
}]
|
|
696
|
-
}, {
|
|
697
|
-
quoted: message
|
|
698
|
-
})
|
|
699
|
-
```
|
|
335
|
+
- If you want to improve sending message, retrying when error occurs and decrypt poll votes, you need to have a store and set `getMessage` config in socket like this:
|
|
336
|
+
```ts
|
|
337
|
+
const sock = makeWASocket({
|
|
338
|
+
getMessage: async (key) => await getMessageFromStore(key),
|
|
339
|
+
});
|
|
340
|
+
```
|
|
700
341
|
|
|
701
|
-
|
|
342
|
+
### Receive Notifications in Whatsapp App
|
|
702
343
|
|
|
703
|
-
|
|
344
|
+
- If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
|
|
345
|
+
```ts
|
|
346
|
+
const sock = makeWASocket({
|
|
347
|
+
markOnlineOnConnect: false,
|
|
348
|
+
});
|
|
349
|
+
```
|
|
704
350
|
|
|
705
|
-
|
|
706
|
-
sock.sendMessage(jid, {
|
|
707
|
-
paymentInviteServiceType: 3 // 1, 2, or 3
|
|
708
|
-
})
|
|
709
|
-
```
|
|
351
|
+
## Saving & Restoring Sessions
|
|
710
352
|
|
|
711
|
-
|
|
353
|
+
You obviously don't want to keep scanning the QR code every time you want to connect.
|
|
712
354
|
|
|
713
|
-
|
|
714
|
-
Invoice message are not supported yet.
|
|
715
|
-
|
|
716
|
-
```javascript
|
|
717
|
-
sock.sendMessage(jid, {
|
|
718
|
-
image: {
|
|
719
|
-
url: './path/to/image.jpg'
|
|
720
|
-
},
|
|
721
|
-
invoiceNote: '🏷️ Invoice'
|
|
722
|
-
})
|
|
723
|
-
```
|
|
355
|
+
So, you can load the credentials to log back in:
|
|
724
356
|
|
|
725
|
-
|
|
357
|
+
```ts
|
|
358
|
+
import makeWASocket, { useMultiFileAuthState } from "violetics";
|
|
726
359
|
|
|
727
|
-
|
|
728
|
-
sock.sendMessage(chat, {
|
|
729
|
-
orderText: '🛍️ Order',
|
|
730
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg') // --- Must in buffer format
|
|
731
|
-
}, {
|
|
732
|
-
quoted: message
|
|
733
|
-
})
|
|
734
|
-
```
|
|
735
|
-
|
|
736
|
-
##### 4️⃣ Product
|
|
737
|
-
|
|
738
|
-
```javascript
|
|
739
|
-
sock.sendMessage(jid, {
|
|
740
|
-
image: {
|
|
741
|
-
url: './path/to/image.jpg'
|
|
742
|
-
},
|
|
743
|
-
product: {
|
|
744
|
-
title: '🛒 My Product'
|
|
745
|
-
},
|
|
746
|
-
businessOwnerJid: '0@s.whatsapp.net' // --- Must included
|
|
747
|
-
}, {
|
|
748
|
-
quoted: message
|
|
749
|
-
})
|
|
750
|
-
```
|
|
360
|
+
const { state, saveCreds } = await useMultiFileAuthState("auth_info_baileys");
|
|
751
361
|
|
|
752
|
-
|
|
362
|
+
// will use the given state to connect
|
|
363
|
+
// so if valid credentials are available -- it'll connect without QR
|
|
364
|
+
const sock = makeWASocket({ auth: state });
|
|
753
365
|
|
|
754
|
-
|
|
755
|
-
sock.
|
|
756
|
-
text: '💳 Request Payment',
|
|
757
|
-
requestPaymentFrom: '0@s.whatsapp.net'
|
|
758
|
-
})
|
|
366
|
+
// this will be called as soon as the credentials are updated
|
|
367
|
+
sock.ev.on("creds.update", saveCreds);
|
|
759
368
|
```
|
|
760
369
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
##### 1️⃣ AI Label
|
|
764
|
-
|
|
765
|
-
> [!NOTE]
|
|
766
|
-
It only works in private chat (`@s.whatsapp.net`).
|
|
767
|
-
|
|
768
|
-
```javascript
|
|
769
|
-
sock.sendMessage(jid, {
|
|
770
|
-
image: {
|
|
771
|
-
url: './path/to/image.jpg'
|
|
772
|
-
},
|
|
773
|
-
caption: '🤖 AI Labeled!',
|
|
774
|
-
ai: true
|
|
775
|
-
}, {
|
|
776
|
-
quoted: message
|
|
777
|
-
})
|
|
778
|
-
```
|
|
779
|
-
|
|
780
|
-
##### 2️⃣ Ephemeral
|
|
370
|
+
> [!IMPORTANT]
|
|
371
|
+
> `useMultiFileAuthState` is a utility function to help save the auth state in a single folder, this function serves as a good guide to help write auth & key states for SQL/no-SQL databases, which I would recommend in any production grade system.
|
|
781
372
|
|
|
782
373
|
> [!NOTE]
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
```javascript
|
|
786
|
-
sock.sendMessage(jid, {
|
|
787
|
-
image: {
|
|
788
|
-
url: './path/to/image.jpg'
|
|
789
|
-
},
|
|
790
|
-
caption: '👁️ Ephemeral',
|
|
791
|
-
ephemeral: true
|
|
792
|
-
})
|
|
793
|
-
```
|
|
374
|
+
> 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.
|
|
794
375
|
|
|
795
|
-
|
|
376
|
+
## Handling Events
|
|
796
377
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
```javascript
|
|
801
|
-
sock.sendMessage(jid, {
|
|
802
|
-
text: '📰 External Ad Reply',
|
|
803
|
-
externalAdReply: {
|
|
804
|
-
title: '📝 Did you know?',
|
|
805
|
-
body: '❓ I dont know',
|
|
806
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg'), // --- Must in buffer format
|
|
807
|
-
largeThumbnail: false, // --- Or true for bigger thumbnail
|
|
808
|
-
url: 'https://www.npmjs.com/package/baileys' // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
|
|
809
|
-
}
|
|
810
|
-
}, {
|
|
811
|
-
quoted: message
|
|
812
|
-
})
|
|
813
|
-
```
|
|
378
|
+
- Baileys uses the EventEmitter syntax for events.
|
|
379
|
+
They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
|
|
814
380
|
|
|
815
|
-
|
|
381
|
+
> [!IMPORTANT]
|
|
382
|
+
> **The events are [these](https://baileys.whiskeysockets.io/types/BaileysEventMap.html)**, it's important you see all events
|
|
816
383
|
|
|
817
|
-
|
|
818
|
-
It only works in group chat (`@g.us`)
|
|
819
|
-
|
|
820
|
-
```javascript
|
|
821
|
-
sock.sendMessage(jid, {
|
|
822
|
-
image: {
|
|
823
|
-
url: './path/to/image.jpg'
|
|
824
|
-
},
|
|
825
|
-
caption: '👥 Group Status!',
|
|
826
|
-
groupStatus: true
|
|
827
|
-
})
|
|
828
|
-
```
|
|
384
|
+
You can listen to these events like this:
|
|
829
385
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
text: '📃 Built manually from scratch using the raw WhatsApp proto structure',
|
|
836
|
-
contextInfo: {
|
|
837
|
-
externalAdReply: {
|
|
838
|
-
title: 'violetics',
|
|
839
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
840
|
-
sourceApp: 'whatsapp',
|
|
841
|
-
showAdAttribution: true,
|
|
842
|
-
mediaType: 1
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
},
|
|
846
|
-
raw: true
|
|
847
|
-
}, {
|
|
848
|
-
quoted: message
|
|
849
|
-
})
|
|
386
|
+
```ts
|
|
387
|
+
const sock = makeWASocket();
|
|
388
|
+
sock.ev.on("messages.upsert", ({ messages }) => {
|
|
389
|
+
console.log("got messages", messages);
|
|
390
|
+
});
|
|
850
391
|
```
|
|
851
392
|
|
|
852
|
-
|
|
393
|
+
### Example to Start
|
|
853
394
|
|
|
854
395
|
> [!NOTE]
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
```javascript
|
|
858
|
-
sock.sendMessage(jid, {
|
|
859
|
-
image: {
|
|
860
|
-
url: './path/to/image.jpg'
|
|
861
|
-
},
|
|
862
|
-
caption: '👁️ View Once',
|
|
863
|
-
viewOnce: true
|
|
864
|
-
})
|
|
865
|
-
```
|
|
866
|
-
|
|
867
|
-
##### 7️⃣ View Once V2
|
|
396
|
+
> This example includes basic auth storage too
|
|
868
397
|
|
|
869
398
|
> [!NOTE]
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
```
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
399
|
+
> For reliable serialization of the authentication state, especially when storing as JSON, always use the BufferJSON utility.
|
|
400
|
+
|
|
401
|
+
```ts
|
|
402
|
+
import makeWASocket, {
|
|
403
|
+
DisconnectReason,
|
|
404
|
+
useMultiFileAuthState,
|
|
405
|
+
} from "violetics";
|
|
406
|
+
import { Boom } from "@hapi/boom";
|
|
407
|
+
|
|
408
|
+
async function connectToWhatsApp() {
|
|
409
|
+
const { state, saveCreds } = await useMultiFileAuthState("auth_info_baileys");
|
|
410
|
+
const sock = makeWASocket({
|
|
411
|
+
// can provide additional config here
|
|
412
|
+
auth: state,
|
|
413
|
+
printQRInTerminal: true,
|
|
414
|
+
});
|
|
415
|
+
sock.ev.on("connection.update", (update) => {
|
|
416
|
+
const { connection, lastDisconnect } = update;
|
|
417
|
+
if (connection === "close") {
|
|
418
|
+
const shouldReconnect =
|
|
419
|
+
(lastDisconnect.error as Boom)?.output?.statusCode !==
|
|
420
|
+
DisconnectReason.loggedOut;
|
|
421
|
+
console.log(
|
|
422
|
+
"connection closed due to ",
|
|
423
|
+
lastDisconnect.error,
|
|
424
|
+
", reconnecting ",
|
|
425
|
+
shouldReconnect,
|
|
426
|
+
);
|
|
427
|
+
// reconnect if not logged out
|
|
428
|
+
if (shouldReconnect) {
|
|
429
|
+
connectToWhatsApp();
|
|
430
|
+
}
|
|
431
|
+
} else if (connection === "open") {
|
|
432
|
+
console.log("opened connection");
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
sock.ev.on("messages.upsert", (event) => {
|
|
436
|
+
for (const m of event.messages) {
|
|
437
|
+
console.log(JSON.stringify(m, undefined, 2));
|
|
438
|
+
|
|
439
|
+
console.log("replying to", m.key.remoteJid);
|
|
440
|
+
await sock.sendMessage(m.key.remoteJid!, { text: "Hello Word" });
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// to storage creds (session info) when it updates
|
|
445
|
+
sock.ev.on("creds.update", saveCreds);
|
|
446
|
+
}
|
|
447
|
+
// run in main file
|
|
448
|
+
connectToWhatsApp();
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### For example if you use useSingleFileAuthState and useMongoFileAuthState
|
|
452
|
+
|
|
453
|
+
```ts
|
|
454
|
+
import makeWASocket, {
|
|
455
|
+
useSingleFileAuthState,
|
|
456
|
+
useMongoFileAuthState,
|
|
457
|
+
} from "violetics";
|
|
458
|
+
|
|
459
|
+
// Single Auth
|
|
460
|
+
const { state, saveState } = await useSingleFileAuthState(
|
|
461
|
+
"./auth_info_baileys.json",
|
|
462
|
+
);
|
|
463
|
+
const sock = makeWASocket({
|
|
464
|
+
auth: state,
|
|
465
|
+
printQRInTerminal: true,
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
sock.ev.on("creds.update", saveState);
|
|
469
|
+
|
|
470
|
+
// Mongo Auth
|
|
471
|
+
import { MongoClient } from "mongodb";
|
|
472
|
+
|
|
473
|
+
const connectAuth = async () => {
|
|
474
|
+
global.client = new MongoClient("mongoURL");
|
|
475
|
+
global.client.connect((err) => {
|
|
476
|
+
if (err) {
|
|
477
|
+
console.warn("Warning: MongoDB link is invalid or cannot be connected.");
|
|
478
|
+
} else {
|
|
479
|
+
console.log("Successfully Connected To MongoDB Server");
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
await client.connect();
|
|
483
|
+
const collection = client.db("@blckrose").collection("sessions");
|
|
484
|
+
return collection;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
const Authentication = await connectAuth();
|
|
488
|
+
const { state, saveCreds } = await useMongoFileAuthState(Authentication);
|
|
489
|
+
const sock = makeWASocket({
|
|
490
|
+
auth: state,
|
|
491
|
+
printQRInTerminal: true,
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
sock.ev.on("creds.update", saveCreds);
|
|
880
495
|
```
|
|
881
496
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
497
|
+
> [!IMPORTANT]
|
|
498
|
+
> In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
|
|
499
|
+
|
|
500
|
+
### Decrypt Poll Votes
|
|
501
|
+
|
|
502
|
+
- By default poll votes are encrypted and handled in `messages.update`
|
|
503
|
+
- That's a simple example
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
sock.ev.on("messages.update", (event) => {
|
|
507
|
+
for (const { key, update } of event) {
|
|
508
|
+
if (update.pollUpdates) {
|
|
509
|
+
const pollCreation = await getMessage(key);
|
|
510
|
+
if (pollCreation) {
|
|
511
|
+
console.log(
|
|
512
|
+
"got poll update, aggregation: ",
|
|
513
|
+
getAggregateVotesInPollMessage({
|
|
514
|
+
message: pollCreation,
|
|
515
|
+
pollUpdates: update.pollUpdates,
|
|
516
|
+
}),
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
});
|
|
895
522
|
```
|
|
896
523
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
##### 🏷️ Find User ID (JID|PN/LID)
|
|
900
|
-
|
|
901
|
-
> [!NOTE]
|
|
902
|
-
The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
|
|
524
|
+
- `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
|
|
903
525
|
|
|
904
|
-
|
|
905
|
-
// --- PN (Phone Number)
|
|
906
|
-
const phoneNumber = '6281111111111@s.whatsapp.net'
|
|
526
|
+
### Summary of Events on First Connection
|
|
907
527
|
|
|
908
|
-
|
|
528
|
+
1. When you connect first time, `connection.update` will be fired requesting you to restart sock
|
|
529
|
+
2. Then, history messages will be received in `messaging.history-set`
|
|
909
530
|
|
|
910
|
-
|
|
531
|
+
## Implementing a Data Store
|
|
911
532
|
|
|
912
|
-
|
|
913
|
-
const lid = '43411111111111@lid'
|
|
533
|
+
- 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.
|
|
914
534
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
console.log('🏷️ Got user ID', ':', ids)
|
|
918
|
-
|
|
919
|
-
// --- Output
|
|
920
|
-
// {
|
|
921
|
-
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
922
|
-
// lid: '43411111111111@lid'
|
|
923
|
-
// }
|
|
924
|
-
// --- Output when failed
|
|
925
|
-
// {
|
|
926
|
-
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
927
|
-
// lid: 'id-not-found'
|
|
928
|
-
// }
|
|
929
|
-
// --- Same output shape regardless of input type
|
|
930
|
-
```
|
|
535
|
+
> [!IMPORTANT]
|
|
536
|
+
> I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
|
|
931
537
|
|
|
932
|
-
|
|
538
|
+
It can be used as follows:
|
|
933
539
|
|
|
934
|
-
|
|
935
|
-
|
|
540
|
+
```ts
|
|
541
|
+
import makeWASocket, { makeInMemoryStore } from "violetics";
|
|
542
|
+
// the store maintains the data of the WA connection in memory
|
|
543
|
+
// can be written out to a file & read from it
|
|
544
|
+
const store = makeInMemoryStore({});
|
|
545
|
+
// can be read from a file
|
|
546
|
+
store.readFromFile("./baileys_store.json");
|
|
547
|
+
// saves the state to a file every 10s
|
|
548
|
+
setInterval(() => {
|
|
549
|
+
store.writeToFile("./baileys_store.json");
|
|
550
|
+
}, 10_000);
|
|
936
551
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
552
|
+
const sock = makeWASocket({});
|
|
553
|
+
// will listen from this socket
|
|
554
|
+
// the store can listen from a new socket once the current socket outlives its lifetime
|
|
555
|
+
store.bind(sock.ev);
|
|
940
556
|
|
|
941
|
-
|
|
557
|
+
sock.ev.on("chats.upsert", () => {
|
|
558
|
+
// can use 'store.chats' however you want, even after the socket dies out
|
|
559
|
+
// 'chats' => a KeyedDB instance
|
|
560
|
+
console.log("got chats", store.chats.all());
|
|
561
|
+
});
|
|
942
562
|
|
|
943
|
-
|
|
563
|
+
sock.ev.on("contacts.upsert", () => {
|
|
564
|
+
console.log("got contacts", Object.values(store.contacts));
|
|
565
|
+
});
|
|
944
566
|
```
|
|
945
567
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
```javascript
|
|
949
|
-
// --- Create a new one
|
|
950
|
-
sock.newsletterCreate('violetics')
|
|
951
|
-
|
|
952
|
-
// --- Get info
|
|
953
|
-
sock.newsletterMetadata('1231111111111@newsletter')
|
|
954
|
-
|
|
955
|
-
// --- Demote admin
|
|
956
|
-
sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
568
|
+
The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
|
|
957
569
|
|
|
958
|
-
|
|
959
|
-
sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
570
|
+
## Whatsapp IDs Explain
|
|
960
571
|
|
|
961
|
-
|
|
962
|
-
|
|
572
|
+
- `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
|
|
573
|
+
- It must be in the format `[country code][phone number]@s.whatsapp.net`
|
|
574
|
+
- Example for people: `+19999999999@s.whatsapp.net`.
|
|
575
|
+
- For groups, it must be in the format `123456789-123345@g.us`.
|
|
576
|
+
- For broadcast lists, it's `[timestamp of creation]@broadcast`.
|
|
577
|
+
- For stories, the ID is `status@broadcast`.
|
|
963
578
|
|
|
964
|
-
|
|
965
|
-
sock.newsletterUpdateDescription('1231111111111@newsletter', '📣 Fresh updates weekly')
|
|
579
|
+
## Utility Functions
|
|
966
580
|
|
|
967
|
-
|
|
968
|
-
sock.newsletterUpdatePicture('1231111111111@newsletter', {
|
|
969
|
-
url: 'path/to/image.jpg'
|
|
970
|
-
})
|
|
581
|
+
### Resize Image
|
|
971
582
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
//
|
|
976
|
-
sock.
|
|
977
|
-
|
|
978
|
-
// --- Get all subscribed newsletters
|
|
979
|
-
const newsletters = await sock.newsletterSubscribed()
|
|
980
|
-
|
|
981
|
-
console.dir(newsletters, { depth: null })
|
|
583
|
+
```ts
|
|
584
|
+
// Resize an image (Buffer, URL, or stream) to given dimensions
|
|
585
|
+
const resized = await sock.resize("https://example.com/image.jpg", 320, 320);
|
|
586
|
+
// or
|
|
587
|
+
const resized = await sock.resize(buffer, 320, 320);
|
|
982
588
|
```
|
|
983
589
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
sock.groupMetadata(jid)
|
|
992
|
-
|
|
993
|
-
// --- Get invite code
|
|
994
|
-
sock.groupInviteCode(jid)
|
|
995
|
-
|
|
996
|
-
// --- Revoke invite link
|
|
997
|
-
sock.groupRevokeInvite(jid)
|
|
998
|
-
|
|
999
|
-
// --- Leave group
|
|
1000
|
-
sock.groupLeave(jid)
|
|
1001
|
-
|
|
1002
|
-
// --- Add participants
|
|
1003
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'add')
|
|
1004
|
-
|
|
1005
|
-
// --- Remove participants
|
|
1006
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'remove')
|
|
1007
|
-
|
|
1008
|
-
// --- Promote to admin
|
|
1009
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
|
|
1010
|
-
|
|
1011
|
-
// --- Demote from admin
|
|
1012
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
|
|
1013
|
-
|
|
1014
|
-
// --- Change name
|
|
1015
|
-
sock.groupUpdateSubject(jid, '📦 violetics')
|
|
1016
|
-
|
|
1017
|
-
// --- Change description
|
|
1018
|
-
sock.groupUpdateDescription(jid, 'Updated description')
|
|
1019
|
-
|
|
1020
|
-
// --- Change photo
|
|
1021
|
-
sock.updateProfilePicture(jid, {
|
|
1022
|
-
url: 'path/to/image.jpg'
|
|
1023
|
-
})
|
|
1024
|
-
|
|
1025
|
-
// --- Remove photo
|
|
1026
|
-
sock.removeProfilePicture(jid)
|
|
1027
|
-
|
|
1028
|
-
// --- Set group as admin only for chatting
|
|
1029
|
-
sock.groupSettingUpdate(jid, 'announcement')
|
|
1030
|
-
|
|
1031
|
-
// --- Set group as open to all for chatting
|
|
1032
|
-
sock.groupSettingUpdate(jid, 'not_announcement')
|
|
590
|
+
- `getContentType`, returns the content type for any message
|
|
591
|
+
- `getDevice`, returns the device from message
|
|
592
|
+
- `makeCacheableSignalKeyStore`, make auth store more fast
|
|
593
|
+
- `downloadContentFromMessage`, download content from any message
|
|
594
|
+
- `makeNewsletterUtils`, helper lengkap untuk kirim ke newsletter/channel
|
|
595
|
+
- `resolveJid`, resolve LID / participant ID ke JID @s.whatsapp.net
|
|
596
|
+
- `resolveJids`, resolve banyak JID sekaligus
|
|
1033
597
|
|
|
1034
|
-
|
|
1035
|
-
sock.groupSettingUpdate(jid, 'locked')
|
|
598
|
+
---
|
|
1036
599
|
|
|
1037
|
-
|
|
1038
|
-
sock.groupSettingUpdate(jid, 'unlocked')
|
|
1039
|
-
|
|
1040
|
-
// --- Set admin only can add participants
|
|
1041
|
-
sock.groupMemberAddMode(jid, 'admin_add')
|
|
1042
|
-
|
|
1043
|
-
// --- Set all participants can add participants
|
|
1044
|
-
sock.groupMemberAddMode(jid, 'all_member_add')
|
|
1045
|
-
|
|
1046
|
-
// --- Enable or disable temporary messages with seconds format
|
|
1047
|
-
sock.groupToggleEphemeral(jid, 86400)
|
|
1048
|
-
|
|
1049
|
-
// --- Disable temporary messages
|
|
1050
|
-
sock.groupToggleEphemeral(jid, 0)
|
|
1051
|
-
|
|
1052
|
-
// --- Enable or disable membership approval mode
|
|
1053
|
-
sock.groupJoinApprovalMode(jid, 'on')
|
|
1054
|
-
sock.groupJoinApprovalMode(jid, 'off')
|
|
1055
|
-
|
|
1056
|
-
// --- Get all groups metadata
|
|
1057
|
-
const groups = await sock.groupFetchAllParticipating()
|
|
1058
|
-
|
|
1059
|
-
console.dir(groups, { depth: null })
|
|
1060
|
-
|
|
1061
|
-
// --- Get pending invites
|
|
1062
|
-
const invites = await sock.groupGetInviteInfo(code)
|
|
1063
|
-
|
|
1064
|
-
console.dir(invites, { depth: null })
|
|
1065
|
-
|
|
1066
|
-
// --- Accept group invite
|
|
1067
|
-
sock.groupAcceptInvite(code)
|
|
1068
|
-
|
|
1069
|
-
// --- Get group info from link
|
|
1070
|
-
const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
|
|
1071
|
-
|
|
1072
|
-
console.log('👥 Got group info from link', ':', group)
|
|
1073
|
-
```
|
|
1074
|
-
|
|
1075
|
-
## 📦 Fork Base
|
|
1076
|
-
> [!NOTE]
|
|
1077
|
-
This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys)
|
|
1078
|
-
|
|
1079
|
-
## 📣 Credits
|
|
1080
|
-
> [!IMPORTANT]
|
|
1081
|
-
This fork uses Protocol Buffer definitions maintained by [WPP Connect](https://github.com/wppconnect-team) via [`wa-proto`](https://github.com/wppconnect-team/wa-proto)
|
|
1082
|
-
>
|
|
1083
|
-
> All rights belong to the original Baileys maintainers and contributors:
|
|
1084
|
-
> - [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)
|
|
1085
|
-
> - [purpshell](https://github.com/purpshell)
|
|
1086
|
-
> - [jlucaso1](https://github.com/jlucaso1)
|
|
1087
|
-
> - [adiwajshing](https://github.com/adiwajshing)
|
|
600
|
+
<p align="center">Made with ⬡ by <a href="https://github.com/blckrose">@blckrose</a></p>
|