@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,230 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import makeWASocket from '../Socket/index.js';
|
|
3
|
+
import { DisconnectReason } from '../Types/index.js';
|
|
4
|
+
import { isJidGroup } from '../WABinary/index.js';
|
|
5
|
+
import defaultLogger from '../Utils/logger.js';
|
|
6
|
+
import { fetchBestWaVersion } from '../Utils/generics.js';
|
|
7
|
+
import { SQLiteStore } from './Store/SQLiteStore.js';
|
|
8
|
+
import { Context } from './Context.js';
|
|
9
|
+
import { SessionManager } from './SessionManager.js';
|
|
10
|
+
import { StatsManager } from './StatsManager.js';
|
|
11
|
+
|
|
12
|
+
// Vanz@Port (from @queenanya/baileys Framework, originally Baileys PR #2710
|
|
13
|
+
// by LuferOS) --- high-level Bot class: middleware routing (Express/Koa-style
|
|
14
|
+
// `use()`/`next()`), a `!command` dispatcher, an outgoing message queue that
|
|
15
|
+
// survives disconnects, and exponential-backoff auto-reconnect.
|
|
16
|
+
//
|
|
17
|
+
// Kept from upstream's fix pass:
|
|
18
|
+
// - command boundary check: `!sticker` no longer matches `!stickerSpam`
|
|
19
|
+
// - queue is rejected (not left hanging) on DisconnectReason.loggedOut
|
|
20
|
+
// - stats.observeMessage runs inside the per-message try block, so a
|
|
21
|
+
// SQLite error can't silently skip middleware for that message
|
|
22
|
+
// - reconnect timer handle is stored so stop()/restart() can cancel it
|
|
23
|
+
//
|
|
24
|
+
/**
|
|
25
|
+
* Vanz@Port (2.0.3) --- idea from @japofc/baileys 2.4.1 (resolveSocketVersionConfig). Resolves the freshest WA Web version
|
|
26
|
+
* (wa-web -> baileys fork -> hard-coded fallback) and merges it into the socket config.
|
|
27
|
+
* Differs from the donor on purpose: it is OPT-IN here (`config.versionCheck === true`), because this fork already ships a recent
|
|
28
|
+
* DEFAULT_WA_VERSION and an unrequested network call on every start() would be a behaviour change. A pinned `socketConfig.version`
|
|
29
|
+
* always wins, and a failed lookup never throws (the original socketConfig is returned untouched).
|
|
30
|
+
*/
|
|
31
|
+
export const resolveSocketVersionConfig = async (config, logger = defaultLogger, fetchVersion = fetchBestWaVersion) => {
|
|
32
|
+
const socketConfig = config?.socketConfig ?? {};
|
|
33
|
+
if (config?.versionCheck !== true || socketConfig.version) {
|
|
34
|
+
return socketConfig;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const { version, source, isLatest } = await fetchVersion();
|
|
38
|
+
if (!Array.isArray(version) || version.length !== 3) {
|
|
39
|
+
throw new Error('unexpected version shape');
|
|
40
|
+
}
|
|
41
|
+
logger.info?.({ version, source, isLatest }, 'resolved WA Web version');
|
|
42
|
+
return { ...socketConfig, version };
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
logger.warn?.({ err }, 'version lookup failed — using default');
|
|
46
|
+
return socketConfig;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export class Bot {
|
|
50
|
+
constructor(config) {
|
|
51
|
+
this.middlewares = [];
|
|
52
|
+
this.messageQueue = [];
|
|
53
|
+
this.isConnected = false;
|
|
54
|
+
this.reconnectAttempts = 0;
|
|
55
|
+
this.reconnectTimer = null;
|
|
56
|
+
this.BASE_RECONNECT_DELAY = 1000;
|
|
57
|
+
this.MAX_RECONNECT_DELAY = 30000;
|
|
58
|
+
this.socket = null;
|
|
59
|
+
this.sessions = null;
|
|
60
|
+
this.stats = null;
|
|
61
|
+
this.store = null;
|
|
62
|
+
this.config = config;
|
|
63
|
+
this.logger = config.logger ?? defaultLogger.child({ module: 'Framework.Bot' });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Register a middleware function */
|
|
67
|
+
use(middleware) {
|
|
68
|
+
this.middlewares.push(middleware);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Register a command handler.
|
|
74
|
+
* Uses exact match OR prefix + whitespace so '!sticker' does NOT
|
|
75
|
+
* match '!stickerSpam' or '!stickerset'.
|
|
76
|
+
*/
|
|
77
|
+
command(cmd, handler) {
|
|
78
|
+
this.use(async (ctx, next) => {
|
|
79
|
+
const text = ctx.text;
|
|
80
|
+
if (text === cmd || text?.startsWith(cmd + ' ')) {
|
|
81
|
+
await handler(ctx);
|
|
82
|
+
}
|
|
83
|
+
await next();
|
|
84
|
+
});
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Register a handler that fires on any non-empty text */
|
|
89
|
+
onText(handler) {
|
|
90
|
+
this.use(async (ctx, next) => {
|
|
91
|
+
if (ctx.text) {
|
|
92
|
+
await handler(ctx);
|
|
93
|
+
}
|
|
94
|
+
await next();
|
|
95
|
+
});
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Send a message — queues automatically when socket is disconnected */
|
|
100
|
+
async sendMessage(jid, content, options = {}) {
|
|
101
|
+
if (this.isConnected && this.socket) {
|
|
102
|
+
return this.socket.sendMessage(jid, content, options);
|
|
103
|
+
}
|
|
104
|
+
return new Promise((resolve, reject) => {
|
|
105
|
+
this.messageQueue.push({ jid, content, options, resolve, reject });
|
|
106
|
+
this.logger.info({ queueLength: this.messageQueue.length }, 'socket not connected — message queued');
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Drain queued messages after reconnect. */
|
|
111
|
+
drainQueue() {
|
|
112
|
+
if (!this.isConnected || !this.socket || this.messageQueue.length === 0)
|
|
113
|
+
return;
|
|
114
|
+
this.logger.info({ pending: this.messageQueue.length }, 'draining message queue');
|
|
115
|
+
const queue = [...this.messageQueue];
|
|
116
|
+
this.messageQueue = [];
|
|
117
|
+
for (const msg of queue) {
|
|
118
|
+
this.socket.sendMessage(msg.jid, msg.content, msg.options).then(msg.resolve).catch(msg.reject);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Reject and clear the message queue. Called on loggedOut so callers don't hang forever. */
|
|
123
|
+
rejectQueue(reason) {
|
|
124
|
+
const queue = [...this.messageQueue];
|
|
125
|
+
this.messageQueue = [];
|
|
126
|
+
for (const msg of queue) {
|
|
127
|
+
msg.reject(new Boom(reason, { statusCode: 401 }));
|
|
128
|
+
}
|
|
129
|
+
if (queue.length > 0) {
|
|
130
|
+
this.logger.warn({ rejected: queue.length }, 'message queue rejected — session terminated');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Start the socket and wire all event handlers */
|
|
135
|
+
async start() {
|
|
136
|
+
if (this.reconnectTimer) {
|
|
137
|
+
clearTimeout(this.reconnectTimer);
|
|
138
|
+
this.reconnectTimer = null;
|
|
139
|
+
}
|
|
140
|
+
if (!this.store) {
|
|
141
|
+
const dbPath = this.config.dbPath ?? 'baileys_store.db';
|
|
142
|
+
this.store = await SQLiteStore.create(dbPath);
|
|
143
|
+
this.sessions = new SessionManager(this.store);
|
|
144
|
+
}
|
|
145
|
+
this.socket = makeWASocket(await resolveSocketVersionConfig(this.config, this.logger));
|
|
146
|
+
if (this.config.enableStats && !this.stats) {
|
|
147
|
+
this.stats = await StatsManager.create(this.config.dbPath ?? 'baileys_store.db', jid => this.socket.groupMetadata(jid));
|
|
148
|
+
}
|
|
149
|
+
this.socket.ev.on('messages.upsert', async ({ messages, type }) => {
|
|
150
|
+
if (type !== 'notify')
|
|
151
|
+
return;
|
|
152
|
+
for (const msg of messages) {
|
|
153
|
+
const ctx = new Context(this, msg);
|
|
154
|
+
try {
|
|
155
|
+
if (this.stats && ctx.remoteJid && isJidGroup(ctx.remoteJid)) {
|
|
156
|
+
const participant = msg.key.participant || msg.participant;
|
|
157
|
+
if (participant) {
|
|
158
|
+
const isSticker = !!msg.message?.stickerMessage;
|
|
159
|
+
this.stats.observeMessage(ctx.remoteJid, participant, isSticker);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
await this.executeMiddlewares(ctx);
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
this.logger.error({ err }, 'error executing middleware');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
this.socket.ev.on('connection.update', update => {
|
|
170
|
+
const { connection, lastDisconnect } = update;
|
|
171
|
+
if (connection === 'open') {
|
|
172
|
+
this.logger.info('bot connected');
|
|
173
|
+
this.isConnected = true;
|
|
174
|
+
this.reconnectAttempts = 0;
|
|
175
|
+
this.drainQueue();
|
|
176
|
+
}
|
|
177
|
+
if (connection === 'close') {
|
|
178
|
+
this.isConnected = false;
|
|
179
|
+
const error = lastDisconnect?.error;
|
|
180
|
+
const statusCode = error?.output?.statusCode;
|
|
181
|
+
const isLoggedOut = statusCode === DisconnectReason.loggedOut;
|
|
182
|
+
this.logger.warn({ statusCode }, 'connection closed');
|
|
183
|
+
if (isLoggedOut) {
|
|
184
|
+
this.rejectQueue('session terminated (logged out)');
|
|
185
|
+
this.logger.info('session logged out — not reconnecting');
|
|
186
|
+
}
|
|
187
|
+
else if (statusCode === DisconnectReason.forbidden || statusCode === DisconnectReason.multideviceMismatch) {
|
|
188
|
+
this.rejectQueue(`session unusable (disconnect ${statusCode})`);
|
|
189
|
+
this.logger.warn({ statusCode }, 'fatal disconnect — not reconnecting');
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
this.reconnectAttempts++;
|
|
193
|
+
const delay = Math.min(this.MAX_RECONNECT_DELAY, this.BASE_RECONNECT_DELAY * Math.pow(2, this.reconnectAttempts - 1));
|
|
194
|
+
this.logger.info({ delay, attempt: this.reconnectAttempts }, 'scheduling reconnect');
|
|
195
|
+
this.reconnectTimer = setTimeout(() => {
|
|
196
|
+
this.reconnectTimer = null;
|
|
197
|
+
this.start().catch(err => {
|
|
198
|
+
this.logger.error({ err }, 'reconnect failed');
|
|
199
|
+
});
|
|
200
|
+
}, delay);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async executeMiddlewares(ctx) {
|
|
207
|
+
let index = -1;
|
|
208
|
+
const dispatch = async (i) => {
|
|
209
|
+
if (i <= index)
|
|
210
|
+
throw new Error('next() called multiple times');
|
|
211
|
+
index = i;
|
|
212
|
+
const middleware = this.middlewares[i];
|
|
213
|
+
if (middleware) {
|
|
214
|
+
await middleware(ctx, () => dispatch(i + 1));
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
await dispatch(0);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Gracefully stop the bot */
|
|
221
|
+
stop() {
|
|
222
|
+
if (this.reconnectTimer) {
|
|
223
|
+
clearTimeout(this.reconnectTimer);
|
|
224
|
+
this.reconnectTimer = null;
|
|
225
|
+
}
|
|
226
|
+
this.rejectQueue('bot stopped');
|
|
227
|
+
this.store?.close();
|
|
228
|
+
this.stats?.close();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class Context {
|
|
2
|
+
constructor(bot: any, message: any);
|
|
3
|
+
bot: any;
|
|
4
|
+
message: any;
|
|
5
|
+
get remoteJid(): any;
|
|
6
|
+
/** Text content, including image/video/document captions so caption-only commands still match. */
|
|
7
|
+
get text(): any;
|
|
8
|
+
get quoted(): any;
|
|
9
|
+
session(): any;
|
|
10
|
+
setSession(data: any): void;
|
|
11
|
+
updateSession(updater: any): void;
|
|
12
|
+
clearSession(): void;
|
|
13
|
+
reply(content: any, options: any): Promise<void>;
|
|
14
|
+
react(emoji: any): Promise<void>;
|
|
15
|
+
replySticker(inputPathOrBuffer: any, metadata: any): Promise<void>;
|
|
16
|
+
replyVoiceNote(inputPathOrBuffer: any): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { MediaManager } from './MediaManager.js';
|
|
2
|
+
|
|
3
|
+
// Vanz@Port (from @queenanya/baileys Framework, originally Baileys PR #2710
|
|
4
|
+
// by LuferOS) --- message context helper: wraps a WAMessage with reply,
|
|
5
|
+
// react, session, and media helpers so command handlers don't have to touch
|
|
6
|
+
// the raw socket API.
|
|
7
|
+
//
|
|
8
|
+
// Kept from upstream's fix pass:
|
|
9
|
+
// - text getter also reads imageMessage/videoMessage/documentMessage
|
|
10
|
+
// captions, so a command sent as an image caption still matches
|
|
11
|
+
// - reply()/react()/replySticker()/replyVoiceNote() throw when remoteJid is
|
|
12
|
+
// missing instead of silently no-op'ing, so a handler can't believe a
|
|
13
|
+
// reply went out when it never did
|
|
14
|
+
export class Context {
|
|
15
|
+
constructor(bot, message) {
|
|
16
|
+
this.bot = bot;
|
|
17
|
+
this.message = message;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get remoteJid() {
|
|
21
|
+
return this.message.key.remoteJid;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Text content, including image/video/document captions so caption-only commands still match. */
|
|
25
|
+
get text() {
|
|
26
|
+
return (this.message.message?.conversation ||
|
|
27
|
+
this.message.message?.extendedTextMessage?.text ||
|
|
28
|
+
this.message.message?.imageMessage?.caption ||
|
|
29
|
+
this.message.message?.videoMessage?.caption ||
|
|
30
|
+
this.message.message?.documentMessage?.caption ||
|
|
31
|
+
undefined);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get quoted() {
|
|
35
|
+
return this.message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
session() {
|
|
39
|
+
return this.bot.sessions?.get(this.remoteJid || '');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setSession(data) {
|
|
43
|
+
this.bot.sessions?.set(this.remoteJid || '', data);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
updateSession(updater) {
|
|
47
|
+
this.bot.sessions?.update(this.remoteJid || '', updater);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
clearSession() {
|
|
51
|
+
this.bot.sessions?.delete(this.remoteJid || '');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async reply(content, options) {
|
|
55
|
+
if (!this.remoteJid)
|
|
56
|
+
throw new Error('Cannot reply: remoteJid is undefined');
|
|
57
|
+
await this.bot.sendMessage(this.remoteJid, {
|
|
58
|
+
...content
|
|
59
|
+
}, {
|
|
60
|
+
quoted: this.message,
|
|
61
|
+
...options
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async react(emoji) {
|
|
66
|
+
if (!this.remoteJid)
|
|
67
|
+
throw new Error('Cannot react: remoteJid is undefined');
|
|
68
|
+
await this.bot.sendMessage(this.remoteJid, {
|
|
69
|
+
react: { text: emoji, key: this.message.key }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async replySticker(inputPathOrBuffer, metadata) {
|
|
74
|
+
if (!this.remoteJid)
|
|
75
|
+
throw new Error('Cannot reply: remoteJid is undefined');
|
|
76
|
+
const buffer = await MediaManager.convertToSticker(inputPathOrBuffer, metadata);
|
|
77
|
+
await this.reply({ sticker: buffer });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async replyVoiceNote(inputPathOrBuffer) {
|
|
81
|
+
if (!this.remoteJid)
|
|
82
|
+
throw new Error('Cannot reply: remoteJid is undefined');
|
|
83
|
+
const buffer = await MediaManager.convertToVoiceNote(inputPathOrBuffer);
|
|
84
|
+
await this.reply({
|
|
85
|
+
audio: buffer,
|
|
86
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
87
|
+
ptt: true
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class MediaManager {
|
|
2
|
+
/** Generate a temp file path with a given extension */
|
|
3
|
+
static getTempFile(ext: any): any;
|
|
4
|
+
/**
|
|
5
|
+
* Convert image or video to a WebP sticker buffer.
|
|
6
|
+
* Applies packname/author EXIF metadata when provided (requires the
|
|
7
|
+
* optional `node-webpmux` peer dependency — only loaded if metadata is given).
|
|
8
|
+
*/
|
|
9
|
+
static convertToSticker(inputPathOrBuffer: any, metadata: any): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Convert audio to OGG Opus voice note format.
|
|
12
|
+
* Mono, 16kHz, VOIP application mode — required by WA for PTT playback.
|
|
13
|
+
*/
|
|
14
|
+
static convertToVoiceNote(inputPathOrBuffer: any): Promise<any>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { randomBytes } from 'crypto';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { resolveFfmpegPath } from '../Utils/ffmpeg-path.js';
|
|
6
|
+
|
|
7
|
+
// Vanz@Port (from @queenanya/baileys Framework, originally Baileys PR #2710
|
|
8
|
+
// by LuferOS) --- media conversion helpers: image/video → WebP stickers
|
|
9
|
+
// (with optional packname/author EXIF), audio → OGG Opus voice notes.
|
|
10
|
+
//
|
|
11
|
+
let _ffmpeg;
|
|
12
|
+
const getFfmpeg = async () => {
|
|
13
|
+
if (_ffmpeg === undefined) {
|
|
14
|
+
_ffmpeg = await import('fluent-ffmpeg').then((m) => m.default ?? m).catch(() => null);
|
|
15
|
+
}
|
|
16
|
+
if (!_ffmpeg)
|
|
17
|
+
throw new Error('fluent-ffmpeg is required for sticker/voice-note conversion. Install it with: npm i fluent-ffmpeg');
|
|
18
|
+
// Vanz@Port (2.0.3): point fluent-ffmpeg at the resolved binary (setFfmpegPath()/FFMPEG_PATH/ffmpeg-static/ffmpeg-installer).
|
|
19
|
+
// A bare 'ffmpeg' (system PATH) is fluent-ffmpeg's own default, so nothing is set in that case.
|
|
20
|
+
try {
|
|
21
|
+
const resolved = await resolveFfmpegPath();
|
|
22
|
+
if (resolved && resolved !== 'ffmpeg' && typeof _ffmpeg.setFfmpegPath === 'function') {
|
|
23
|
+
_ffmpeg.setFfmpegPath(resolved);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch { /* keep fluent-ffmpeg's default lookup */ }
|
|
27
|
+
return _ffmpeg;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
let _webpmux;
|
|
31
|
+
const getWebpmux = async () => {
|
|
32
|
+
if (_webpmux === undefined) {
|
|
33
|
+
_webpmux = await import('node-webpmux').then((m) => m.default ?? m).catch(() => null);
|
|
34
|
+
}
|
|
35
|
+
if (!_webpmux)
|
|
36
|
+
throw new Error('node-webpmux is required for sticker packname/author metadata. Install it with: npm i node-webpmux (conversion without metadata does not need this package)');
|
|
37
|
+
return _webpmux;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export class MediaManager {
|
|
41
|
+
/** Generate a temp file path with a given extension */
|
|
42
|
+
static getTempFile(ext) {
|
|
43
|
+
return path.join(os.tmpdir(), `baileys-fw-${randomBytes(8).toString('hex')}.${ext}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Convert image or video to a WebP sticker buffer.
|
|
48
|
+
* Applies packname/author EXIF metadata when provided (requires the
|
|
49
|
+
* optional `node-webpmux` peer dependency — only loaded if metadata is given).
|
|
50
|
+
*/
|
|
51
|
+
static async convertToSticker(inputPathOrBuffer, metadata) {
|
|
52
|
+
const ffmpegLib = await getFfmpeg();
|
|
53
|
+
const tempInput = MediaManager.getTempFile('in');
|
|
54
|
+
const tempOutput = MediaManager.getTempFile('webp');
|
|
55
|
+
try {
|
|
56
|
+
if (Buffer.isBuffer(inputPathOrBuffer)) {
|
|
57
|
+
await fs.promises.writeFile(tempInput, inputPathOrBuffer);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
await fs.promises.copyFile(inputPathOrBuffer, tempInput);
|
|
61
|
+
}
|
|
62
|
+
await new Promise((resolve, reject) => {
|
|
63
|
+
ffmpegLib(tempInput)
|
|
64
|
+
.outputOptions([
|
|
65
|
+
'-vcodec', 'libwebp',
|
|
66
|
+
'-vf', 'scale=512:512:force_original_aspect_ratio=decrease,pad=512:512:(ow-iw)/2:(oh-ih)/2:color=white@0',
|
|
67
|
+
'-loop', '0',
|
|
68
|
+
'-preset', 'default',
|
|
69
|
+
'-an', '-vsync', '0',
|
|
70
|
+
'-t', '00:00:05'
|
|
71
|
+
])
|
|
72
|
+
.output(tempOutput)
|
|
73
|
+
.on('end', () => resolve())
|
|
74
|
+
.on('error', (err) => reject(err))
|
|
75
|
+
.run();
|
|
76
|
+
});
|
|
77
|
+
const webpBuffer = await fs.promises.readFile(tempOutput);
|
|
78
|
+
if (metadata?.packname || metadata?.author) {
|
|
79
|
+
// EXIF header: fixed 22-byte TIFF/IFD preamble (magic + one IFD
|
|
80
|
+
// entry pointing at the WhatsApp tag 0x0741) followed by a
|
|
81
|
+
// little-endian payload length and a little-endian offset to
|
|
82
|
+
// where the payload begins (always 22, the header's own size).
|
|
83
|
+
const exifJson = JSON.stringify({
|
|
84
|
+
'sticker-pack-id': `com.vanzxy.sticker.${randomBytes(4).toString('hex')}`,
|
|
85
|
+
'sticker-pack-name': metadata.packname || '',
|
|
86
|
+
'sticker-pack-publisher': metadata.author || '',
|
|
87
|
+
emojis: ['🤖']
|
|
88
|
+
});
|
|
89
|
+
const exifBytes = Buffer.from(exifJson, 'utf8');
|
|
90
|
+
const exifHeader = Buffer.from([
|
|
91
|
+
0x49, 0x49, 0x2a, 0x00, // TIFF byte order (little-endian) + magic number
|
|
92
|
+
0x08, 0x00, 0x00, 0x00, // offset to first IFD
|
|
93
|
+
0x01, 0x00, // number of IFD entries
|
|
94
|
+
0x41, 0x57, 0x07, 0x00, // tag 0x0741 (WhatsApp), type 0x0007 (undefined)
|
|
95
|
+
0x00, 0x00, 0x00, 0x00, // payload length placeholder — filled below
|
|
96
|
+
0x16, 0x00, 0x00, 0x00 // offset to payload data (fixed: 22 = header size)
|
|
97
|
+
]);
|
|
98
|
+
exifHeader.writeUInt32LE(exifBytes.length, 14);
|
|
99
|
+
const fullExif = Buffer.concat([exifHeader, exifBytes]);
|
|
100
|
+
const webpmux = await getWebpmux();
|
|
101
|
+
const img = new webpmux.Image();
|
|
102
|
+
await img.load(webpBuffer);
|
|
103
|
+
img.exif = fullExif;
|
|
104
|
+
return await img.save(null);
|
|
105
|
+
}
|
|
106
|
+
return webpBuffer;
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
await fs.promises.unlink(tempInput).catch(() => { });
|
|
110
|
+
await fs.promises.unlink(tempOutput).catch(() => { });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Convert audio to OGG Opus voice note format.
|
|
116
|
+
* Mono, 16kHz, VOIP application mode — required by WA for PTT playback.
|
|
117
|
+
*/
|
|
118
|
+
static async convertToVoiceNote(inputPathOrBuffer) {
|
|
119
|
+
const ffmpegLib = await getFfmpeg();
|
|
120
|
+
const tempInput = MediaManager.getTempFile('in');
|
|
121
|
+
const tempOutput = MediaManager.getTempFile('ogg');
|
|
122
|
+
try {
|
|
123
|
+
if (Buffer.isBuffer(inputPathOrBuffer)) {
|
|
124
|
+
await fs.promises.writeFile(tempInput, inputPathOrBuffer);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
await fs.promises.copyFile(inputPathOrBuffer, tempInput);
|
|
128
|
+
}
|
|
129
|
+
await new Promise((resolve, reject) => {
|
|
130
|
+
ffmpegLib(tempInput)
|
|
131
|
+
.inputOptions(['-y'])
|
|
132
|
+
.outputOptions([
|
|
133
|
+
'-c:a', 'libopus',
|
|
134
|
+
'-ac', '1', // mono channel (required by WA)
|
|
135
|
+
'-ar', '16000', // 16kHz sample rate
|
|
136
|
+
'-application', 'voip',
|
|
137
|
+
'-b:a', '32k',
|
|
138
|
+
'-compression_level', '10',
|
|
139
|
+
'-vbr', 'on'
|
|
140
|
+
])
|
|
141
|
+
.format('ogg')
|
|
142
|
+
.output(tempOutput)
|
|
143
|
+
.on('end', () => resolve())
|
|
144
|
+
.on('error', (err) => reject(err))
|
|
145
|
+
.run();
|
|
146
|
+
});
|
|
147
|
+
return await fs.promises.readFile(tempOutput);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
await fs.promises.unlink(tempInput).catch(() => { });
|
|
151
|
+
await fs.promises.unlink(tempOutput).catch(() => { });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Vanz@Port (from @queenanya/baileys Framework, originally Baileys PR #2710
|
|
2
|
+
// by LuferOS) --- per-JID session CRUD backed by SQLiteStore. Unchanged logic
|
|
3
|
+
// from upstream; only the SQLiteStore instance it wraps is now created via
|
|
4
|
+
// an async factory (see Store/SQLiteStore.js).
|
|
5
|
+
export class SessionManager {
|
|
6
|
+
constructor(store) {
|
|
7
|
+
this.store = store;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
key(jid) {
|
|
11
|
+
return `session_${jid}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get(jid) {
|
|
15
|
+
return this.store.get(this.key(jid));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set(jid, data) {
|
|
19
|
+
this.store.set(this.key(jid), data);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
update(jid, updater) {
|
|
23
|
+
const prev = this.get(jid);
|
|
24
|
+
this.set(jid, updater(prev));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
delete(jid) {
|
|
28
|
+
this.store.del(this.key(jid));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
has(jid) {
|
|
32
|
+
return this.get(jid) !== undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class StatsManager {
|
|
2
|
+
/** Vanz@Port: replaces the old synchronous `new StatsManager(dbPath, groupMetaFn)`. */
|
|
3
|
+
static create(dbPath: any, groupMetaFn: any): Promise<StatsManager>;
|
|
4
|
+
constructor(db: any, groupMetaFn: any);
|
|
5
|
+
db: any;
|
|
6
|
+
groupMetaFn: any;
|
|
7
|
+
insertStmt: any;
|
|
8
|
+
getStatsStmt: any;
|
|
9
|
+
getTopMsgStmt: (limit: any) => any;
|
|
10
|
+
getTopStickerStmt: (limit: any) => any;
|
|
11
|
+
/** Record a message observation for stats. Normalizes both JIDs before storing. */
|
|
12
|
+
observeMessage(groupJid: any, userJid: any, isSticker: any): void;
|
|
13
|
+
/** Top message senders for a group. */
|
|
14
|
+
getTopUsers(groupJid: any, limit?: number): any;
|
|
15
|
+
/** Top sticker senders for a group. */
|
|
16
|
+
getTopStickers(groupJid: any, limit?: number): any;
|
|
17
|
+
/** Detect inactive members ("ghosts") in a group. */
|
|
18
|
+
getGhosts(groupJid: any, socketConnected: any, inactiveDays?: number): Promise<any>;
|
|
19
|
+
close(): void;
|
|
20
|
+
}
|