@vanzxysenpai/baileys 0.0.0-stage → 0.0.2
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/CHANGELOG.md +30 -0
- package/LICENSE +25 -0
- package/NOTICE.md +158 -0
- package/README.md +5294 -2
- package/VanzxyBanner.js +134 -0
- package/WAProto/index.d.ts +13317 -0
- package/WAProto/index.js +147553 -0
- package/lib/Builders/A2UI.d.ts +131 -0
- package/lib/Builders/A2UI.js +343 -0
- package/lib/Builders/AIRich.d.ts +1021 -0
- package/lib/Builders/AIRich.js +2889 -0
- package/lib/Builders/Album.d.ts +51 -0
- package/lib/Builders/Album.js +99 -0
- package/lib/Builders/Button.d.ts +137449 -0
- package/lib/Builders/Button.js +1054 -0
- package/lib/Builders/ButtonV2.d.ts +43 -0
- package/lib/Builders/ButtonV2.js +175 -0
- package/lib/Builders/ButtonV3.d.ts +35 -0
- package/lib/Builders/ButtonV3.js +189 -0
- package/lib/Builders/Carousel.d.ts +68 -0
- package/lib/Builders/Carousel.js +161 -0
- package/lib/Builders/Event.d.ts +61 -0
- package/lib/Builders/Event.js +118 -0
- package/lib/Builders/Expiring.d.ts +17 -0
- package/lib/Builders/Expiring.js +27 -0
- package/lib/Builders/Poll.d.ts +63 -0
- package/lib/Builders/Poll.js +139 -0
- package/lib/Builders/VanzxyBaileys.d.ts +42 -0
- package/lib/Builders/VanzxyBaileys.js +110 -0
- package/lib/Builders/errors.d.ts +25 -0
- package/lib/Builders/errors.js +29 -0
- package/lib/Builders/index.d.ts +14 -0
- package/lib/Builders/index.js +23 -0
- package/lib/Builders/shared.d.ts +395 -0
- package/lib/Builders/shared.js +738 -0
- package/lib/Defaults/bot-jid.d.ts +1 -0
- package/lib/Defaults/bot-jid.js +1 -0
- package/lib/Defaults/index.d.ts +161 -0
- package/lib/Defaults/index.js +165 -0
- package/lib/Defaults/version.d.ts +1 -0
- package/lib/Defaults/version.js +1 -0
- package/lib/Framework/Bot.d.ts +865 -0
- package/lib/Framework/Bot.js +230 -0
- package/lib/Framework/Context.d.ts +17 -0
- package/lib/Framework/Context.js +90 -0
- package/lib/Framework/MediaManager.d.ts +15 -0
- package/lib/Framework/MediaManager.js +154 -0
- package/lib/Framework/SessionManager.d.ts +10 -0
- package/lib/Framework/SessionManager.js +34 -0
- package/lib/Framework/StatsManager.d.ts +20 -0
- package/lib/Framework/StatsManager.js +117 -0
- package/lib/Framework/Store/SQLiteStore.d.ts +13 -0
- package/lib/Framework/Store/SQLiteStore.js +68 -0
- package/lib/Framework/index.d.ts +6 -0
- package/lib/Framework/index.js +11 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.d.ts +10 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.d.ts +58 -0
- package/lib/Signal/libsignal.js +436 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Signal/lid-mapping.js +276 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.d.ts +674 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.d.ts +137 -0
- package/lib/Socket/chats.js +1299 -0
- package/lib/Socket/communities.d.ts +805 -0
- package/lib/Socket/communities.js +454 -0
- package/lib/Socket/dugong.d.ts +118 -0
- package/lib/Socket/dugong.js +810 -0
- package/lib/Socket/groups.d.ts +287 -0
- package/lib/Socket/groups.js +386 -0
- package/lib/Socket/index.d.ts +826 -0
- package/lib/Socket/index.js +35 -0
- package/lib/Socket/messages-recv.d.ts +613 -0
- package/lib/Socket/messages-recv.js +1851 -0
- package/lib/Socket/messages-send.d.ts +608 -0
- package/lib/Socket/messages-send.js +1574 -0
- package/lib/Socket/mex-fallback.d.ts +51 -0
- package/lib/Socket/mex-fallback.js +97 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter-ext.d.ts +47 -0
- package/lib/Socket/newsletter-ext.js +262 -0
- package/lib/Socket/newsletter.d.ts +285 -0
- package/lib/Socket/newsletter.js +223 -0
- package/lib/Socket/socket.d.ts +60 -0
- package/lib/Socket/socket.js +1001 -0
- package/lib/Socket/username.d.ts +842 -0
- package/lib/Socket/username.js +156 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.d.ts +62 -0
- package/lib/Store/make-in-memory-store.js +425 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +1 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.d.ts +1 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +1 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +1 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +1 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +2 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +2 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +11 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +1 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +1 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +1 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +5 -0
- package/lib/Types/State.js +55 -0
- package/lib/Types/USync.d.ts +1 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +15 -0
- package/lib/Types/index.js +27 -0
- package/lib/Utils/PersistentStore.d.ts +83 -0
- package/lib/Utils/PersistentStore.js +592 -0
- package/lib/Utils/anchor-guard.d.ts +31 -0
- package/lib/Utils/anchor-guard.js +329 -0
- package/lib/Utils/android-stanza-id.d.ts +4 -0
- package/lib/Utils/android-stanza-id.js +21 -0
- package/lib/Utils/anti-delete.d.ts +62 -0
- package/lib/Utils/anti-delete.js +212 -0
- package/lib/Utils/auth-secure.d.ts +180 -0
- package/lib/Utils/auth-secure.js +791 -0
- package/lib/Utils/auth-utils.d.ts +59 -0
- package/lib/Utils/auth-utils.js +326 -0
- package/lib/Utils/auto-reconnect.d.ts +8 -0
- package/lib/Utils/auto-reconnect.js +204 -0
- package/lib/Utils/auto-reply.d.ts +35 -0
- package/lib/Utils/auto-reply.js +152 -0
- package/lib/Utils/bad-mac-handler.d.ts +59 -0
- package/lib/Utils/bad-mac-handler.js +119 -0
- package/lib/Utils/baileys-event-stream.d.ts +5 -0
- package/lib/Utils/baileys-event-stream.js +62 -0
- package/lib/Utils/browser-utils.d.ts +9 -0
- package/lib/Utils/browser-utils.js +29 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +236 -0
- package/lib/Utils/button-helper-utils.d.ts +59 -0
- package/lib/Utils/button-helper-utils.js +266 -0
- package/lib/Utils/button-sender.d.ts +164 -0
- package/lib/Utils/button-sender.js +845 -0
- package/lib/Utils/chat-control.d.ts +98 -0
- package/lib/Utils/chat-control.js +231 -0
- package/lib/Utils/chat-history-helpers.d.ts +4 -0
- package/lib/Utils/chat-history-helpers.js +70 -0
- package/lib/Utils/chat-utils.d.ts +408 -0
- package/lib/Utils/chat-utils.js +879 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/companion-reg-client-utils.js +39 -0
- package/lib/Utils/connection-watchdog.d.ts +10 -0
- package/lib/Utils/connection-watchdog.js +74 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +145 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +315 -0
- package/lib/Utils/disconnect-reason.d.ts +13 -0
- package/lib/Utils/disconnect-reason.js +36 -0
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/event-buffer.js +640 -0
- package/lib/Utils/fetch-timeout.d.ts +4 -0
- package/lib/Utils/fetch-timeout.js +14 -0
- package/lib/Utils/ffmpeg-path.d.ts +5 -0
- package/lib/Utils/ffmpeg-path.js +130 -0
- package/lib/Utils/generics.d.ts +79 -0
- package/lib/Utils/generics.js +426 -0
- package/lib/Utils/group-metadata-cache.d.ts +3 -0
- package/lib/Utils/group-metadata-cache.js +25 -0
- package/lib/Utils/group-status-detection.d.ts +5 -0
- package/lib/Utils/group-status-detection.js +114 -0
- package/lib/Utils/history.d.ts +91 -0
- package/lib/Utils/history.js +144 -0
- package/lib/Utils/html-app.d.ts +14 -0
- package/lib/Utils/html-app.js +97 -0
- package/lib/Utils/html-multiplayer.d.ts +8 -0
- package/lib/Utils/html-multiplayer.js +90 -0
- package/lib/Utils/humanizer.d.ts +8 -0
- package/lib/Utils/humanizer.js +74 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/index.d.ts +88 -0
- package/lib/Utils/index.js +93 -0
- package/lib/Utils/jid-tools.d.ts +3 -0
- package/lib/Utils/jid-tools.js +78 -0
- package/lib/Utils/link-preview-metadata.d.ts +47 -0
- package/lib/Utils/link-preview-metadata.js +90 -0
- package/lib/Utils/link-preview.d.ts +12 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/lock-manager.d.ts +5 -0
- package/lib/Utils/lock-manager.js +50 -0
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +26 -0
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/media-messages.d.ts +35 -0
- package/lib/Utils/media-messages.js +70 -0
- package/lib/Utils/media-processor.d.ts +6 -0
- package/lib/Utils/media-processor.js +174 -0
- package/lib/Utils/media-set.d.ts +6 -0
- package/lib/Utils/media-set.js +169 -0
- package/lib/Utils/message-kind.d.ts +26 -0
- package/lib/Utils/message-kind.js +138 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/message-retry-manager.js +264 -0
- package/lib/Utils/message-search.d.ts +40 -0
- package/lib/Utils/message-search.js +181 -0
- package/lib/Utils/messages-media.d.ts +136 -0
- package/lib/Utils/messages-media.js +867 -0
- package/lib/Utils/messages.d.ts +66 -0
- package/lib/Utils/messages.js +2271 -0
- package/lib/Utils/meta-ai-msmsg.d.ts +3 -0
- package/lib/Utils/meta-ai-msmsg.js +132 -0
- package/lib/Utils/meta-ai.d.ts +4 -0
- package/lib/Utils/meta-ai.js +75 -0
- package/lib/Utils/migrate-auth-state.d.ts +23 -0
- package/lib/Utils/migrate-auth-state.js +126 -0
- package/lib/Utils/mini-app.d.ts +20 -0
- package/lib/Utils/mini-app.js +215 -0
- package/lib/Utils/mock-socket.d.ts +67 -0
- package/lib/Utils/mock-socket.js +254 -0
- package/lib/Utils/modern-messages.d.ts +64 -0
- package/lib/Utils/modern-messages.js +497 -0
- package/lib/Utils/native-flow.d.ts +19 -0
- package/lib/Utils/native-flow.js +112 -0
- package/lib/Utils/newsletter-status.d.ts +157 -0
- package/lib/Utils/newsletter-status.js +652 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +9 -0
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/pairing-utils.d.ts +5 -0
- package/lib/Utils/pairing-utils.js +29 -0
- package/lib/Utils/passkey.d.ts +4 -0
- package/lib/Utils/passkey.js +11 -0
- package/lib/Utils/past-participants.d.ts +2 -0
- package/lib/Utils/past-participants.js +40 -0
- package/lib/Utils/payment-detection.d.ts +40 -0
- package/lib/Utils/payment-detection.js +213 -0
- package/lib/Utils/payment-guard.d.ts +28 -0
- package/lib/Utils/payment-guard.js +143 -0
- package/lib/Utils/payment-messages.d.ts +42 -0
- package/lib/Utils/payment-messages.js +161 -0
- package/lib/Utils/payment-utils.d.ts +75 -0
- package/lib/Utils/payment-utils.js +145 -0
- package/lib/Utils/phone-utils.d.ts +3 -0
- package/lib/Utils/phone-utils.js +29 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +103 -0
- package/lib/Utils/process-message.js +868 -0
- package/lib/Utils/qr-terminal.d.ts +1 -0
- package/lib/Utils/qr-terminal.js +16 -0
- package/lib/Utils/reconnect-backoff.d.ts +25 -0
- package/lib/Utils/reconnect-backoff.js +47 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-message-utils.d.ts +54 -0
- package/lib/Utils/rich-message-utils.js +435 -0
- package/lib/Utils/rich-messages.d.ts +298 -0
- package/lib/Utils/rich-messages.js +1145 -0
- package/lib/Utils/scheduled-message.d.ts +81 -0
- package/lib/Utils/scheduled-message.js +101 -0
- package/lib/Utils/scheduling.d.ts +59 -0
- package/lib/Utils/scheduling.js +139 -0
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/signal.js +200 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/status-stickers.d.ts +79 -0
- package/lib/Utils/status-stickers.js +261 -0
- package/lib/Utils/status.d.ts +107 -0
- package/lib/Utils/status.js +131 -0
- package/lib/Utils/sticker-pack-maker.d.ts +20 -0
- package/lib/Utils/sticker-pack-maker.js +112 -0
- package/lib/Utils/stickerpack.d.ts +18 -0
- package/lib/Utils/stickerpack.js +316 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tag.d.ts +8 -0
- package/lib/Utils/tag.js +45 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/tc-token-utils.js +162 -0
- package/lib/Utils/templates.d.ts +86 -0
- package/lib/Utils/templates.js +148 -0
- package/lib/Utils/text-format.d.ts +13 -0
- package/lib/Utils/text-format.js +81 -0
- package/lib/Utils/text-tools.d.ts +3 -0
- package/lib/Utils/text-tools.js +38 -0
- package/lib/Utils/ttl-cache.d.ts +29 -0
- package/lib/Utils/ttl-cache.js +123 -0
- package/lib/Utils/use-cache-manager-auth-state.d.ts +22 -0
- package/lib/Utils/use-cache-manager-auth-state.js +86 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +20 -0
- package/lib/Utils/use-multi-file-auth-state.js +201 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.js +111 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
- package/lib/Utils/use-sqlite-auth-state.js +171 -0
- package/lib/Utils/username.d.ts +22 -0
- package/lib/Utils/username.js +59 -0
- package/lib/Utils/validate-connection.d.ts +43 -0
- package/lib/Utils/validate-connection.js +197 -0
- package/lib/Utils/vcard.d.ts +40 -0
- package/lib/Utils/vcard.js +92 -0
- package/lib/Utils/voice-note.d.ts +13 -0
- package/lib/Utils/voice-note.js +47 -0
- package/lib/VoIP/audio-feeder.d.ts +15 -0
- package/lib/VoIP/audio-feeder.js +132 -0
- package/lib/VoIP/index.d.ts +22 -0
- package/lib/VoIP/index.js +277 -0
- package/lib/VoIP/relay-transport.d.ts +16 -0
- package/lib/VoIP/relay-transport.js +559 -0
- package/lib/VoIP/signaling.d.ts +16 -0
- package/lib/VoIP/signaling.js +624 -0
- package/lib/VoIP/types.d.ts +11 -0
- package/lib/VoIP/types.js +17 -0
- package/lib/VoIP/wasm-engine.d.ts +28 -0
- package/lib/VoIP/wasm-engine.js +1214 -0
- package/lib/VoIP/worker-bootstrap.d.ts +1 -0
- package/lib/VoIP/worker-bootstrap.js +1042 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/constants.js +1466 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +45 -0
- package/lib/WABinary/generic-utils.js +285 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +32 -0
- package/lib/WABinary/jid-utils.js +102 -0
- package/lib/WABinary/types.d.ts +1 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.d.ts +43 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +60 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.d.ts +20 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +23 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +24 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +49 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +12 -0
- package/lib/WAUSync/Protocols/index.js +12 -0
- package/lib/WAUSync/USyncQuery.d.ts +25 -0
- package/lib/WAUSync/USyncQuery.js +140 -0
- package/lib/WAUSync/USyncUser.d.ts +24 -0
- package/lib/WAUSync/USyncUser.js +47 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/exports-extra.d.ts +45 -0
- package/lib/exports-extra.js +47 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +24 -0
- package/package.json +161 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Mutex as AsyncMutex } from 'async-mutex';
|
|
2
|
+
export const makeMutex = () => {
|
|
3
|
+
const mutex = new AsyncMutex();
|
|
4
|
+
return {
|
|
5
|
+
mutex(code) {
|
|
6
|
+
return mutex.runExclusive(code);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export const makeKeyedMutex = () => {
|
|
11
|
+
const map = new Map();
|
|
12
|
+
return {
|
|
13
|
+
async mutex(key, task) {
|
|
14
|
+
let entry = map.get(key);
|
|
15
|
+
if (!entry) {
|
|
16
|
+
entry = { mutex: new AsyncMutex(), refCount: 0 };
|
|
17
|
+
map.set(key, entry);
|
|
18
|
+
}
|
|
19
|
+
entry.refCount++;
|
|
20
|
+
try {
|
|
21
|
+
return await entry.mutex.runExclusive(task);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
entry.refCount--;
|
|
25
|
+
// only delete it if this is still the current entry
|
|
26
|
+
if (entry.refCount === 0 && map.get(key) === entry) {
|
|
27
|
+
map.delete(key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a panoramic/wide profile picture buffer — landscape images are
|
|
3
|
+
* scaled down to a 720px-wide target, portrait images to a 324px-wide
|
|
4
|
+
* target, preserving aspect ratio throughout.
|
|
5
|
+
*/
|
|
6
|
+
export function generateProfilePictureFull(img: any): Promise<{
|
|
7
|
+
img: any;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Generates a panoramic/wide profile picture buffer — landscape images are
|
|
11
|
+
* scaled down to a 720px-wide target, portrait images to a 324px-wide
|
|
12
|
+
* target, preserving aspect ratio throughout.
|
|
13
|
+
*/
|
|
14
|
+
export function changeprofileFull(img: any): Promise<{
|
|
15
|
+
img: any;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Generates a square profile picture buffer (main image, scaled to fit
|
|
19
|
+
* within 720x720) plus a normalized preview buffer.
|
|
20
|
+
*/
|
|
21
|
+
export function generateProfilePictureFP(buffer: any): Promise<{
|
|
22
|
+
img: any;
|
|
23
|
+
preview: any;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Generates a square profile picture buffer (main image, scaled to fit
|
|
27
|
+
* within 720x720) plus a normalized preview buffer.
|
|
28
|
+
*/
|
|
29
|
+
export function generatePP(buffer: any): Promise<{
|
|
30
|
+
img: any;
|
|
31
|
+
preview: any;
|
|
32
|
+
}>;
|
|
33
|
+
export function generateProfilePicturee(mediaUpload: any): Promise<{
|
|
34
|
+
img: any;
|
|
35
|
+
}>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ported from Bail-master addons/media-messages.ts.
|
|
3
|
+
* Jimp-based profile-picture image generators (square + panoramic/wide).
|
|
4
|
+
* Deduplicated aliases kept intact: generateProfilePictureFull ===
|
|
5
|
+
* changeprofileFull, generateProfilePictureFP === generatePP (source had
|
|
6
|
+
* these as byte-identical pairs under different names).
|
|
7
|
+
*/
|
|
8
|
+
import { Jimp, JimpMime } from 'jimp';
|
|
9
|
+
const toBuffer = async (stream) => {
|
|
10
|
+
const chunks = [];
|
|
11
|
+
for await (const chunk of stream) {
|
|
12
|
+
chunks.push(chunk);
|
|
13
|
+
}
|
|
14
|
+
stream.destroy?.();
|
|
15
|
+
return Buffer.concat(chunks);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Generates a panoramic/wide profile picture buffer — landscape images are
|
|
19
|
+
* scaled down to a 720px-wide target, portrait images to a 324px-wide
|
|
20
|
+
* target, preserving aspect ratio throughout.
|
|
21
|
+
*/
|
|
22
|
+
const generateWideProfilePicture = async (img) => {
|
|
23
|
+
const jimp = await Jimp.read(img);
|
|
24
|
+
const width = jimp.bitmap.width;
|
|
25
|
+
const height = jimp.bitmap.height;
|
|
26
|
+
const ratio = width > height ? width / 720 : width / 324;
|
|
27
|
+
const targetWidth = Math.round(width / ratio);
|
|
28
|
+
const targetHeight = Math.round(height / ratio);
|
|
29
|
+
const buffer = await jimp.resize({ w: targetWidth, h: targetHeight }).getBuffer(JimpMime.jpeg, { quality: 100 });
|
|
30
|
+
return { img: buffer };
|
|
31
|
+
};
|
|
32
|
+
export const generateProfilePictureFull = generateWideProfilePicture;
|
|
33
|
+
export const changeprofileFull = generateWideProfilePicture;
|
|
34
|
+
/**
|
|
35
|
+
* Generates a square profile picture buffer (main image, scaled to fit
|
|
36
|
+
* within 720x720) plus a normalized preview buffer.
|
|
37
|
+
*/
|
|
38
|
+
const generateSquareProfilePicture = async (buffer) => {
|
|
39
|
+
const jimp = await Jimp.read(buffer);
|
|
40
|
+
const img = await jimp.clone().scaleToFit({ w: 720, h: 720 }).getBuffer(JimpMime.jpeg);
|
|
41
|
+
const preview = await jimp.clone().normalize().getBuffer(JimpMime.jpeg);
|
|
42
|
+
return { img, preview };
|
|
43
|
+
};
|
|
44
|
+
export const generateProfilePictureFP = generateSquareProfilePicture;
|
|
45
|
+
export const generatePP = generateSquareProfilePicture;
|
|
46
|
+
/**
|
|
47
|
+
* Generates a profile picture buffer from a flexible input source — a raw
|
|
48
|
+
* Buffer, a `{ url }` media-upload descriptor, or a `{ stream }`
|
|
49
|
+
* media-upload descriptor. Resizes the longer dimension down to 720px,
|
|
50
|
+
* preserving aspect ratio on the other.
|
|
51
|
+
*/
|
|
52
|
+
export const generateProfilePicturee = async (mediaUpload) => {
|
|
53
|
+
let bufferOrFilePath;
|
|
54
|
+
if (Buffer.isBuffer(mediaUpload)) {
|
|
55
|
+
bufferOrFilePath = mediaUpload;
|
|
56
|
+
}
|
|
57
|
+
else if ('url' in mediaUpload) {
|
|
58
|
+
bufferOrFilePath = mediaUpload.url.toString();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
bufferOrFilePath = await toBuffer(mediaUpload.stream);
|
|
62
|
+
}
|
|
63
|
+
const jimp = await Jimp.read(bufferOrFilePath);
|
|
64
|
+
const { width, height } = jimp.bitmap;
|
|
65
|
+
const resized = width > height
|
|
66
|
+
? jimp.resize({ w: 720, h: Math.round((height / width) * 720) })
|
|
67
|
+
: jimp.resize({ w: Math.round((width / height) * 720), h: 720 });
|
|
68
|
+
const img = await resized.getBuffer(JimpMime.jpeg, { quality: 100 });
|
|
69
|
+
return { img };
|
|
70
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const resizeImage: (buffer: Buffer, options?: { width?: number; height?: number; fit?: string; format?: string; quality?: number }) => Promise<Buffer>;
|
|
2
|
+
export declare const convertToWhatsAppVideo: (buffer: Buffer, options?: { maxWidth?: number; videoBitrate?: string; audioBitrate?: string }) => Promise<Buffer>;
|
|
3
|
+
export declare const convertToOpusAudio: (buffer: Buffer, options?: { bitrate?: string; channels?: number; sampleRate?: number }) => Promise<Buffer>;
|
|
4
|
+
export declare const getVideoThumbnail: (buffer: Buffer, timeSec?: number, options?: { width?: number; height?: number }) => Promise<Buffer>;
|
|
5
|
+
export declare const probeMedia: (buffer: Buffer, mimeType?: string) => Promise<any>;
|
|
6
|
+
export declare const getMp4Duration: (buffer: Buffer, options?: { silent?: boolean }) => number | null;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// Ported into @vanzxysenpai/baileys 0.0.1 from @rennzsync/baileys 10.7.4, MIT. See NOTICE.md.
|
|
2
|
+
/**
|
|
3
|
+
* media-processor.js — utilitas media terpusat untuk bot WhatsApp multi-media.
|
|
4
|
+
*
|
|
5
|
+
* Semua dependency berat (sharp, fluent-ffmpeg, audio-decode) di-load secara
|
|
6
|
+
* LAZY (dynamic import) sehingga proses yang tidak memakai fitur media tidak
|
|
7
|
+
* membayar biaya RAM-nya. Jika package opsional tidak terpasang, fungsi yang
|
|
8
|
+
* membutuhkannya melempar error yang jelas.
|
|
9
|
+
*/
|
|
10
|
+
import { PassThrough, Readable } from 'stream';
|
|
11
|
+
|
|
12
|
+
const loadSharp = async () => {
|
|
13
|
+
try {
|
|
14
|
+
return (await import('sharp')).default;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
throw new Error('Package "sharp" tidak terpasang. Jalankan: npm install sharp');
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const loadFfmpeg = async () => {
|
|
22
|
+
try {
|
|
23
|
+
return (await import('fluent-ffmpeg')).default;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error('Package "fluent-ffmpeg" tidak terpasang. Jalankan: npm install fluent-ffmpeg');
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const bufferToStream = (buffer) => {
|
|
31
|
+
const stream = new Readable({ read() { } });
|
|
32
|
+
stream.push(buffer);
|
|
33
|
+
stream.push(null);
|
|
34
|
+
return stream;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const ffmpegToBuffer = (ffmpeg, input, outputOptions, extraArgs = []) => new Promise((resolve, reject) => {
|
|
38
|
+
const output = new PassThrough();
|
|
39
|
+
const chunks = [];
|
|
40
|
+
output.on('data', (chunk) => chunks.push(chunk));
|
|
41
|
+
output.on('end', () => resolve(Buffer.concat(chunks)));
|
|
42
|
+
output.on('error', reject);
|
|
43
|
+
ffmpeg(bufferToStream(input))
|
|
44
|
+
.outputOptions([...outputOptions, ...extraArgs])
|
|
45
|
+
.on('error', (err) => reject(new Error(`ffmpeg error: ${err.message}`)))
|
|
46
|
+
.pipe(output, { end: true });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** Resize/kompres gambar via sharp. fit: 'cover' | 'contain' | 'inside' ... */
|
|
50
|
+
export const resizeImage = async (buffer, { width = 300, height = 300, fit = 'cover', format = 'jpeg', quality } = {}) => {
|
|
51
|
+
const sharp = await loadSharp();
|
|
52
|
+
let pipeline = sharp(buffer).resize(width, height, { fit, position: 'center', background: { r: 0, g: 0, b: 0, alpha: 0 } });
|
|
53
|
+
if (format === 'png') {
|
|
54
|
+
pipeline = pipeline.png();
|
|
55
|
+
}
|
|
56
|
+
else if (format === 'webp') {
|
|
57
|
+
pipeline = pipeline.webp(quality ? { quality } : {});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
pipeline = pipeline.jpeg(quality ? { quality } : {});
|
|
61
|
+
}
|
|
62
|
+
return pipeline.toBuffer();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Konversi video ke format kompatibel WhatsApp (MP4/H.264 + AAC). */
|
|
66
|
+
export const convertToWhatsAppVideo = async (buffer, { maxWidth = 1280, videoBitrate = '1000k', audioBitrate = '128k' } = {}) => {
|
|
67
|
+
const ffmpeg = await loadFfmpeg();
|
|
68
|
+
return ffmpegToBuffer(ffmpeg, buffer, [
|
|
69
|
+
'-c:v libx264',
|
|
70
|
+
'-preset fast',
|
|
71
|
+
'-profile:v baseline',
|
|
72
|
+
'-level 3.0',
|
|
73
|
+
`-vf scale='min(${maxWidth},iw)':-2`,
|
|
74
|
+
`-b:v ${videoBitrate}`,
|
|
75
|
+
'-c:a aac',
|
|
76
|
+
`-b:a ${audioBitrate}`,
|
|
77
|
+
'-movflags +faststart',
|
|
78
|
+
'-f mp4'
|
|
79
|
+
]);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Konversi audio apapun ke OGG/Opus (format voice note WhatsApp). */
|
|
83
|
+
export const convertToOpusAudio = async (buffer, { bitrate = '32k', channels = 1, sampleRate = 48000 } = {}) => {
|
|
84
|
+
const ffmpeg = await loadFfmpeg();
|
|
85
|
+
return ffmpegToBuffer(ffmpeg, buffer, [
|
|
86
|
+
'-c:a libopus',
|
|
87
|
+
`-b:a ${bitrate}`,
|
|
88
|
+
`-ac ${channels}`,
|
|
89
|
+
`-ar ${sampleRate}`,
|
|
90
|
+
'-application voip',
|
|
91
|
+
'-f ogg'
|
|
92
|
+
]);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** Ambil satu frame video sebagai thumbnail JPEG. */
|
|
96
|
+
export const getVideoThumbnail = async (buffer, timeSec = 0, { width = 300, height = 300 } = {}) => {
|
|
97
|
+
const ffmpeg = await loadFfmpeg();
|
|
98
|
+
const frame = await ffmpegToBuffer(ffmpeg, buffer, [
|
|
99
|
+
`-ss ${timeSec}`,
|
|
100
|
+
'-vframes 1',
|
|
101
|
+
'-vcodec png',
|
|
102
|
+
'-f image2pipe'
|
|
103
|
+
]);
|
|
104
|
+
return resizeImage(frame, { width, height, format: 'jpeg' });
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Metadata media (durasi, dimensi, format) via music-metadata (audio) atau ffprobe fallback. */
|
|
108
|
+
export const probeMedia = async (buffer, mimeType = '') => {
|
|
109
|
+
try {
|
|
110
|
+
const { parseBuffer } = await import('music-metadata');
|
|
111
|
+
const meta = await parseBuffer(buffer, { mimeType: mimeType || undefined }, { duration: true });
|
|
112
|
+
return {
|
|
113
|
+
duration: meta.format.duration,
|
|
114
|
+
bitrate: meta.format.bitrate,
|
|
115
|
+
container: meta.format.container,
|
|
116
|
+
codec: meta.format.codec
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new Error(`probeMedia gagal: ${error.message}`);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** Durasi MP4 tanpa ffmpeg — parse atom moov/mvhd langsung. */
|
|
125
|
+
export const getMp4Duration = (buffer, { silent = true } = {}) => {
|
|
126
|
+
try {
|
|
127
|
+
if (!Buffer.isBuffer(buffer) || buffer.length < 8) {
|
|
128
|
+
if (silent) return 0;
|
|
129
|
+
throw new Error('Invalid buffer');
|
|
130
|
+
}
|
|
131
|
+
let offset = 0;
|
|
132
|
+
while (offset < buffer.length - 8) {
|
|
133
|
+
const size = buffer.readUInt32BE(offset);
|
|
134
|
+
if (size < 8 || offset + size > buffer.length) {
|
|
135
|
+
if (silent) return 0;
|
|
136
|
+
throw new Error('Invalid atom size');
|
|
137
|
+
}
|
|
138
|
+
const type = buffer.toString('ascii', offset + 4, offset + 8);
|
|
139
|
+
if (type === 'moov') {
|
|
140
|
+
let moovOffset = offset + 8;
|
|
141
|
+
const moovEnd = offset + size;
|
|
142
|
+
while (moovOffset < moovEnd - 8) {
|
|
143
|
+
const childSize = buffer.readUInt32BE(moovOffset);
|
|
144
|
+
if (childSize < 8 || moovOffset + childSize > moovEnd) {
|
|
145
|
+
if (silent) return 0;
|
|
146
|
+
throw new Error('Invalid child atom size');
|
|
147
|
+
}
|
|
148
|
+
const childType = buffer.toString('ascii', moovOffset + 4, moovOffset + 8);
|
|
149
|
+
if (childType === 'mvhd') {
|
|
150
|
+
const version = buffer.readUInt8(moovOffset + 8);
|
|
151
|
+
if (version === 0) {
|
|
152
|
+
const timescale = buffer.readUInt32BE(moovOffset + 20);
|
|
153
|
+
const duration = buffer.readUInt32BE(moovOffset + 24);
|
|
154
|
+
return timescale ? duration / timescale : 0;
|
|
155
|
+
}
|
|
156
|
+
if (version === 1) {
|
|
157
|
+
const timescale = buffer.readUInt32BE(moovOffset + 32);
|
|
158
|
+
const duration = Number(buffer.readBigUInt64BE(moovOffset + 36));
|
|
159
|
+
return timescale ? duration / timescale : 0;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
moovOffset += childSize;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
offset += size;
|
|
166
|
+
}
|
|
167
|
+
if (silent) return 0;
|
|
168
|
+
throw new Error('No mvhd found!');
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
if (silent) return 0;
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function updateProfilePictureFull(jid: any, content: any, sock: any): Promise<any>;
|
|
2
|
+
export function updateProfilePictureFull2(jid: any, content: any, sock: any): Promise<any>;
|
|
3
|
+
export function groupStatus(jid: any, content: any, sock: any): Promise<import("../index.js").proto.WebMessageInfo>;
|
|
4
|
+
export function groupStatusV2(jids: any, content: any, sock: any): Promise<import("../index.js").proto.WebMessageInfo[]>;
|
|
5
|
+
export function groupSetMemberLabel(jid: any, memberLabel: any, sock: any): Promise<any>;
|
|
6
|
+
export function groupLabel(jid: any, text: any, sock: any): Promise<void>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ported from Bail-master addons/media-set.ts.
|
|
3
|
+
* Profile-picture setters (full/panoramic variants) and group-status /
|
|
4
|
+
* member-label senders. Depends on this fork's own media-messages.js
|
|
5
|
+
* (also ported this batch) and its existing generateWAMessageContent /
|
|
6
|
+
* generateWAMessageFromContent / unixTimestampSeconds / S_WHATSAPP_NET.
|
|
7
|
+
*
|
|
8
|
+
* NOTE ON DUPLICATE-LOOKING SETTERS: `updateProfilePictureFull` and
|
|
9
|
+
* `updateProfilePictureFull2` are genuinely different, not duplicates —
|
|
10
|
+
* the first sends the `img` buffer from `generateProfilePictureFP`
|
|
11
|
+
* (scaled-to-fit 720x720 main image), the second sends the `preview`
|
|
12
|
+
* buffer from `generatePP` (normalized preview). Both are kept.
|
|
13
|
+
*/
|
|
14
|
+
import { randomBytes } from 'node:crypto';
|
|
15
|
+
import { generateWAMessageContent, generateWAMessageFromContent } from './messages.js';
|
|
16
|
+
import { unixTimestampSeconds } from './generics.js';
|
|
17
|
+
import { S_WHATSAPP_NET } from '../WABinary/index.js';
|
|
18
|
+
import { generatePP, generateProfilePictureFP } from './media-messages.js';
|
|
19
|
+
/** Update the profile picture for yourself or a group — sends the main (scaled-to-fit) image. */
|
|
20
|
+
export const updateProfilePictureFull = async (jid, content, sock) => {
|
|
21
|
+
const { query } = sock;
|
|
22
|
+
const { img } = await generateProfilePictureFP(content);
|
|
23
|
+
const media = await query({
|
|
24
|
+
tag: 'iq',
|
|
25
|
+
attrs: {
|
|
26
|
+
target: jid,
|
|
27
|
+
to: S_WHATSAPP_NET,
|
|
28
|
+
type: 'set',
|
|
29
|
+
xmlns: 'w:profile:picture'
|
|
30
|
+
},
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
tag: 'picture',
|
|
34
|
+
attrs: { type: 'image' },
|
|
35
|
+
content: img
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
return media;
|
|
40
|
+
};
|
|
41
|
+
/** Update the profile picture for yourself or a group — sends the normalized preview image. */
|
|
42
|
+
export const updateProfilePictureFull2 = async (jid, content, sock) => {
|
|
43
|
+
const { query } = sock;
|
|
44
|
+
const { preview } = await generatePP(content);
|
|
45
|
+
const media = await query({
|
|
46
|
+
tag: 'iq',
|
|
47
|
+
attrs: {
|
|
48
|
+
target: jid,
|
|
49
|
+
to: S_WHATSAPP_NET,
|
|
50
|
+
type: 'set',
|
|
51
|
+
xmlns: 'w:profile:picture'
|
|
52
|
+
},
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
tag: 'picture',
|
|
56
|
+
attrs: { type: 'image' },
|
|
57
|
+
content: preview
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
return media;
|
|
62
|
+
};
|
|
63
|
+
/** Send a group status (status update visible only within a group's members). */
|
|
64
|
+
export const groupStatus = async (jid, content, sock) => {
|
|
65
|
+
const { backgroundColor, ...rest } = content;
|
|
66
|
+
const inside = await generateWAMessageContent(rest, {
|
|
67
|
+
upload: sock.waUploadToServer,
|
|
68
|
+
backgroundColor
|
|
69
|
+
});
|
|
70
|
+
const messageSecret = randomBytes(32);
|
|
71
|
+
const userJid = sock.authState?.creds?.me?.id;
|
|
72
|
+
const userJidLid = sock.authState?.creds?.me?.lid;
|
|
73
|
+
const m = generateWAMessageFromContent(jid, {
|
|
74
|
+
messageContextInfo: { messageSecret },
|
|
75
|
+
groupStatusMessageV2: {
|
|
76
|
+
message: {
|
|
77
|
+
...inside,
|
|
78
|
+
messageContextInfo: { messageSecret }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, { userJid, userJidLid });
|
|
82
|
+
await sock.relayMessage(jid, m.message, { messageId: m.key.id });
|
|
83
|
+
return m;
|
|
84
|
+
};
|
|
85
|
+
/** Send the same group status to multiple groups at once. */
|
|
86
|
+
export const groupStatusV2 = async (jids, content, sock) => {
|
|
87
|
+
const { backgroundColor, ...rest } = content;
|
|
88
|
+
const inside = await generateWAMessageContent(rest, {
|
|
89
|
+
upload: sock.waUploadToServer,
|
|
90
|
+
backgroundColor
|
|
91
|
+
});
|
|
92
|
+
const messageSecret = randomBytes(32);
|
|
93
|
+
const userJid = sock.authState?.creds?.me?.id;
|
|
94
|
+
const userJidLid = sock.authState?.creds?.me?.lid;
|
|
95
|
+
const results = [];
|
|
96
|
+
for (const id of jids) {
|
|
97
|
+
const m = generateWAMessageFromContent(id, {
|
|
98
|
+
messageContextInfo: { messageSecret },
|
|
99
|
+
groupStatusMessageV2: {
|
|
100
|
+
message: {
|
|
101
|
+
...inside,
|
|
102
|
+
messageContextInfo: { messageSecret }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, { userJid, userJidLid });
|
|
106
|
+
await sock.relayMessage(id, m.message, { messageId: m.key.id });
|
|
107
|
+
results.push(m);
|
|
108
|
+
}
|
|
109
|
+
return results;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Set/update a member's label in a group (awaits the relay and returns the result).
|
|
113
|
+
* Label is truncated to 30 characters (WA's limit).
|
|
114
|
+
*/
|
|
115
|
+
export const groupSetMemberLabel = async (jid, memberLabel, sock) => {
|
|
116
|
+
const result = await sock.relayMessage(jid, {
|
|
117
|
+
protocolMessage: {
|
|
118
|
+
type: 30,
|
|
119
|
+
memberLabel: {
|
|
120
|
+
label: memberLabel.slice(0, 30),
|
|
121
|
+
labelTimestamp: unixTimestampSeconds() || Date.now()
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
additionalNodes: [
|
|
126
|
+
{
|
|
127
|
+
tag: 'meta',
|
|
128
|
+
attrs: {
|
|
129
|
+
tag_reason: 'user_update',
|
|
130
|
+
appdata: 'member_tag'
|
|
131
|
+
},
|
|
132
|
+
content: undefined
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Set/update a member's label in a group — fire-and-forget variant (errors
|
|
140
|
+
* are swallowed, matching the source's behavior; prefer
|
|
141
|
+
* `groupSetMemberLabel` if you need to await/observe failures).
|
|
142
|
+
*/
|
|
143
|
+
export const groupLabel = async (jid, text, sock) => {
|
|
144
|
+
try {
|
|
145
|
+
void sock.relayMessage(jid, {
|
|
146
|
+
protocolMessage: {
|
|
147
|
+
type: 30,
|
|
148
|
+
memberLabel: {
|
|
149
|
+
label: text.slice(0, 30),
|
|
150
|
+
labelTimestamp: unixTimestampSeconds() || Date.now()
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
additionalNodes: [
|
|
155
|
+
{
|
|
156
|
+
tag: 'meta',
|
|
157
|
+
attrs: {
|
|
158
|
+
tag_reason: 'user_update',
|
|
159
|
+
appdata: 'member_tag'
|
|
160
|
+
},
|
|
161
|
+
content: undefined
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// intentionally swallowed — matches source behavior
|
|
168
|
+
}
|
|
169
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function resolveButtonAddonKind(message: any): WaButtonAddonKind | null;
|
|
2
|
+
export function parseInteractiveReply(message: any): NormalizedInteractiveReply;
|
|
3
|
+
/**
|
|
4
|
+
* Companion "addon kind" for list / native-flow style messages.
|
|
5
|
+
* Ported from zapo-js's resolveButtonAddonKind (src/message/encode/content.ts).
|
|
6
|
+
*/
|
|
7
|
+
export type WaButtonAddonKind = "list" | "interactive" | "payment_info" | "order_details";
|
|
8
|
+
/**
|
|
9
|
+
* Normalized shape returned by parseInteractiveReply, regardless of which
|
|
10
|
+
* underlying WhatsApp reply type produced it.
|
|
11
|
+
*/
|
|
12
|
+
export type NormalizedInteractiveReply = {
|
|
13
|
+
kind: "buttons_response" | "list_response" | "native_flow_response" | "template_button_reply" | null;
|
|
14
|
+
/**
|
|
15
|
+
* - the button/row/native-flow id the user selected
|
|
16
|
+
*/
|
|
17
|
+
id: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* - visible text of the selection, if present
|
|
20
|
+
*/
|
|
21
|
+
displayText: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* - parsed paramsJson for native-flow responses, or null
|
|
24
|
+
*/
|
|
25
|
+
params: any | null;
|
|
26
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evernight AI — lib/Utils/message-kind.js / Creator : Vanzxy🍃
|
|
3
|
+
*
|
|
4
|
+
* Addon-kind resolution logic adapted from zapo-js (MIT, © vinikjkkj)
|
|
5
|
+
* <https://github.com/vinikjkkj/zapo>, ported to this Baileys fork's
|
|
6
|
+
* message-content shape. The normalized reply parser below is original,
|
|
7
|
+
* written to cover this fork's own buttonsResponseMessage /
|
|
8
|
+
* listResponseMessage / interactiveResponseMessage / templateButtonReplyMessage
|
|
9
|
+
* send-side shapes (see messages.js).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Unwraps ephemeral/viewOnce/edited wrappers to get at the real content.
|
|
14
|
+
* Mirrors the wrapper set already handled by normalizeMessageContent()
|
|
15
|
+
* in messages.js, kept local here to avoid a circular import.
|
|
16
|
+
*/
|
|
17
|
+
const unwrapMessage = (message) => {
|
|
18
|
+
let content = message;
|
|
19
|
+
for (let i = 0; i < 5; i++) {
|
|
20
|
+
const inner = content?.ephemeralMessage?.message ||
|
|
21
|
+
content?.viewOnceMessage?.message ||
|
|
22
|
+
content?.viewOnceMessageV2?.message ||
|
|
23
|
+
content?.viewOnceMessageV2Extension?.message ||
|
|
24
|
+
content?.documentWithCaptionMessage?.message ||
|
|
25
|
+
content?.editedMessage?.message;
|
|
26
|
+
if (!inner) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
content = inner;
|
|
30
|
+
}
|
|
31
|
+
return content;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Companion "addon kind" for list / native-flow style messages.
|
|
36
|
+
* Ported from zapo-js's resolveButtonAddonKind (src/message/encode/content.ts).
|
|
37
|
+
* @typedef {'list' | 'interactive' | 'payment_info' | 'order_details'} WaButtonAddonKind
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const resolveNativeFlowAddonKind = (nativeFlow) => {
|
|
41
|
+
const firstButtonName = nativeFlow?.buttons?.[0]?.name;
|
|
42
|
+
if (firstButtonName === 'payment_info')
|
|
43
|
+
return 'payment_info';
|
|
44
|
+
if (firstButtonName === 'review_and_pay')
|
|
45
|
+
return 'order_details';
|
|
46
|
+
return 'interactive';
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Resolves which kind of button/list addon an outgoing message carries.
|
|
51
|
+
* Returns null if the message has no button/list/native-flow content.
|
|
52
|
+
* @param {import('../../WAProto').proto.IMessage} message
|
|
53
|
+
* @returns {WaButtonAddonKind | null}
|
|
54
|
+
*/
|
|
55
|
+
export const resolveButtonAddonKind = (message) => {
|
|
56
|
+
const msg = unwrapMessage(message);
|
|
57
|
+
if (!msg)
|
|
58
|
+
return null;
|
|
59
|
+
if (msg.listMessage)
|
|
60
|
+
return 'list';
|
|
61
|
+
if (msg.buttonsMessage)
|
|
62
|
+
return 'interactive';
|
|
63
|
+
const nativeFlow = msg.interactiveMessage?.nativeFlowMessage;
|
|
64
|
+
if (nativeFlow)
|
|
65
|
+
return resolveNativeFlowAddonKind(nativeFlow);
|
|
66
|
+
return null;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Normalized shape returned by parseInteractiveReply, regardless of which
|
|
71
|
+
* underlying WhatsApp reply type produced it.
|
|
72
|
+
* @typedef {Object} NormalizedInteractiveReply
|
|
73
|
+
* @property {'buttons_response'|'list_response'|'native_flow_response'|'template_button_reply'|null} kind
|
|
74
|
+
* @property {string|null} id - the button/row/native-flow id the user selected
|
|
75
|
+
* @property {string|null} displayText - visible text of the selection, if present
|
|
76
|
+
* @property {Object|null} params - parsed paramsJson for native-flow responses, or null
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Reads whatever a user tapped (button, list row, or native-flow reply) and
|
|
81
|
+
* returns one consistent shape, so plugin authors don't need a different
|
|
82
|
+
* branch per response type. Safe against malformed paramsJson (returns null
|
|
83
|
+
* instead of throwing).
|
|
84
|
+
* @param {import('../../WAProto').proto.IMessage} message
|
|
85
|
+
* @returns {NormalizedInteractiveReply}
|
|
86
|
+
*/
|
|
87
|
+
export const parseInteractiveReply = (message) => {
|
|
88
|
+
const msg = unwrapMessage(message);
|
|
89
|
+
const empty = { kind: null, id: null, displayText: null, params: null };
|
|
90
|
+
if (!msg)
|
|
91
|
+
return empty;
|
|
92
|
+
if (msg.buttonsResponseMessage) {
|
|
93
|
+
const r = msg.buttonsResponseMessage;
|
|
94
|
+
return {
|
|
95
|
+
kind: 'buttons_response',
|
|
96
|
+
id: r.selectedButtonId || null,
|
|
97
|
+
displayText: r.selectedDisplayText || null,
|
|
98
|
+
params: null
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (msg.listResponseMessage) {
|
|
102
|
+
const r = msg.listResponseMessage;
|
|
103
|
+
return {
|
|
104
|
+
kind: 'list_response',
|
|
105
|
+
id: r.singleSelectReply?.selectedRowId || null,
|
|
106
|
+
displayText: r.title || r.description || null,
|
|
107
|
+
params: null
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (msg.interactiveResponseMessage) {
|
|
111
|
+
const r = msg.interactiveResponseMessage;
|
|
112
|
+
let params = null;
|
|
113
|
+
if (r.nativeFlowResponseMessage?.paramsJson) {
|
|
114
|
+
try {
|
|
115
|
+
params = JSON.parse(r.nativeFlowResponseMessage.paramsJson);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
params = null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
kind: 'native_flow_response',
|
|
123
|
+
id: params?.id ?? r.nativeFlowResponseMessage?.name ?? null,
|
|
124
|
+
displayText: r.body?.text || null,
|
|
125
|
+
params
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (msg.templateButtonReplyMessage) {
|
|
129
|
+
const r = msg.templateButtonReplyMessage;
|
|
130
|
+
return {
|
|
131
|
+
kind: 'template_button_reply',
|
|
132
|
+
id: r.selectedId || null,
|
|
133
|
+
displayText: r.selectedDisplayText || null,
|
|
134
|
+
params: null
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return empty;
|
|
138
|
+
};
|