@deffa5556/bail 1.0.6 → 1.0.9
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/cjs/WAProto/index.cjs +106053 -0
- package/cjs/deffa/config.cjs +14 -0
- package/cjs/deffa/plugins/ai/deepseekr1.cjs +35 -0
- package/cjs/deffa/plugins/ai/gita.cjs +26 -0
- package/cjs/deffa/plugins/ai/glm47flash.cjs +35 -0
- package/cjs/deffa/plugins/ai/gptoss120b.cjs +35 -0
- package/cjs/deffa/plugins/ai/qwq32b.cjs +35 -0
- package/cjs/deffa/plugins/berita/antara.cjs +25 -0
- package/cjs/deffa/plugins/berita/cnbcindonesia.cjs +25 -0
- package/cjs/deffa/plugins/berita/cnn.cjs +25 -0
- package/cjs/deffa/plugins/berita/kompas.cjs +25 -0
- package/cjs/deffa/plugins/berita/liputan6.cjs +25 -0
- package/cjs/deffa/plugins/berita/merdeka.cjs +25 -0
- package/cjs/deffa/plugins/berita/sindonews.cjs +25 -0
- package/cjs/deffa/plugins/berita/tribunnews.cjs +25 -0
- package/cjs/deffa/plugins/downloader/douyin.cjs +30 -0
- package/cjs/deffa/plugins/downloader/facebook.cjs +30 -0
- package/cjs/deffa/plugins/downloader/github.cjs +35 -0
- package/cjs/deffa/plugins/downloader/lahelu.cjs +30 -0
- package/cjs/deffa/plugins/downloader/snackvideo.cjs +30 -0
- package/cjs/deffa/plugins/downloader/soundcloud.cjs +30 -0
- package/cjs/deffa/plugins/downloader/tiktok.cjs +30 -0
- package/cjs/deffa/plugins/downloader/tiktokhd.cjs +30 -0
- package/cjs/deffa/plugins/downloader/twitter.cjs +30 -0
- package/cjs/deffa/plugins/downloader/ummy.cjs +36 -0
- package/cjs/deffa/plugins/index.cjs +213 -0
- package/cjs/deffa/plugins/info/bmkg.cjs +34 -0
- package/cjs/deffa/plugins/info/cuaca.cjs +31 -0
- package/cjs/deffa/plugins/info/jadwaltv.cjs +29 -0
- package/cjs/deffa/plugins/maker/brat.cjs +45 -0
- package/cjs/deffa/plugins/maker/bratvid.cjs +52 -0
- package/cjs/deffa/plugins/search/8font.cjs +28 -0
- package/cjs/deffa/plugins/search/applemusic.cjs +28 -0
- package/cjs/deffa/plugins/search/bimg.cjs +30 -0
- package/cjs/deffa/plugins/search/brave.cjs +34 -0
- package/cjs/deffa/plugins/search/duckduckgo.cjs +28 -0
- package/cjs/deffa/plugins/search/lahelu.cjs +28 -0
- package/cjs/deffa/plugins/search/mangatoon.cjs +28 -0
- package/cjs/deffa/plugins/search/mcpedl.cjs +28 -0
- package/cjs/deffa/plugins/search/myinstants.cjs +28 -0
- package/cjs/deffa/plugins/search/otakotaku.cjs +28 -0
- package/cjs/deffa/plugins/search/pinterest.cjs +30 -0
- package/cjs/deffa/plugins/search/resep.cjs +28 -0
- package/cjs/deffa/plugins/search/seegore.cjs +30 -0
- package/cjs/deffa/plugins/search/soundcloud.cjs +28 -0
- package/cjs/deffa/plugins/search/youtube.cjs +28 -0
- package/cjs/deffa/plugins/stalk/github.cjs +38 -0
- package/cjs/deffa/plugins/stalk/pinterest.cjs +37 -0
- package/cjs/deffa/plugins/stalk/threads.cjs +34 -0
- package/cjs/deffa/plugins/stalk/tiktok.cjs +37 -0
- package/cjs/deffa/plugins/stalk/twitter.cjs +37 -0
- package/cjs/deffa/plugins/stalk/youtube.cjs +37 -0
- package/cjs/lib/Defaults/index.cjs +158 -0
- package/cjs/lib/Discord/Client.cjs +263 -0
- package/cjs/lib/Discord/Constants.cjs +1842 -0
- package/cjs/lib/Discord/connect-dc.cjs +11 -0
- package/cjs/lib/Discord/esm-bridge.cjs +136 -0
- package/cjs/lib/Discord/gateway/Dispatcher.cjs +93 -0
- package/cjs/lib/Discord/gateway/Shard.cjs +695 -0
- package/cjs/lib/Discord/gateway/ShardManager.cjs +344 -0
- package/cjs/lib/Discord/gateway/compression/base.cjs +13 -0
- package/cjs/lib/Discord/gateway/compression/config.cjs +47 -0
- package/cjs/lib/Discord/gateway/compression/pako.cjs +44 -0
- package/cjs/lib/Discord/gateway/compression/zlib-native.cjs +47 -0
- package/cjs/lib/Discord/gateway/compression/zlib-sync.cjs +31 -0
- package/cjs/lib/Discord/gateway/compression/zstd-napi.cjs +80 -0
- package/cjs/lib/Discord/gateway/compression/zstd-native.cjs +46 -0
- package/cjs/lib/Discord/gateway/events.cjs +956 -0
- package/cjs/lib/Discord/index.cjs +238 -0
- package/cjs/lib/Discord/rest/Bucket.cjs +69 -0
- package/cjs/lib/Discord/rest/DiscordHTTPError.cjs +63 -0
- package/cjs/lib/Discord/rest/DiscordRESTError.cjs +84 -0
- package/cjs/lib/Discord/rest/OAuthHelper.cjs +226 -0
- package/cjs/lib/Discord/rest/RESTManager.cjs +116 -0
- package/cjs/lib/Discord/rest/RequestHandler.cjs +320 -0
- package/cjs/lib/Discord/rest/SequentialBucket.cjs +69 -0
- package/cjs/lib/Discord/routes/Applications.cjs +625 -0
- package/cjs/lib/Discord/routes/Channels.cjs +1199 -0
- package/cjs/lib/Discord/routes/Guilds.cjs +1792 -0
- package/cjs/lib/Discord/routes/Interactions.cjs +212 -0
- package/cjs/lib/Discord/routes/Lobbies.cjs +197 -0
- package/cjs/lib/Discord/routes/Miscellaneous.cjs +120 -0
- package/cjs/lib/Discord/routes/OAuth.cjs +350 -0
- package/cjs/lib/Discord/routes/Users.cjs +107 -0
- package/cjs/lib/Discord/routes/Webhooks.cjs +308 -0
- package/cjs/lib/Discord/structures/AnnouncementChannel.cjs +46 -0
- package/cjs/lib/Discord/structures/AnnouncementThreadChannel.cjs +28 -0
- package/cjs/lib/Discord/structures/Application.cjs +345 -0
- package/cjs/lib/Discord/structures/ApplicationCommand.cjs +109 -0
- package/cjs/lib/Discord/structures/Attachment.cjs +46 -0
- package/cjs/lib/Discord/structures/AuditLogEntry.cjs +41 -0
- package/cjs/lib/Discord/structures/AutoModerationRule.cjs +117 -0
- package/cjs/lib/Discord/structures/AutocompleteInteraction.cjs +90 -0
- package/cjs/lib/Discord/structures/Base.cjs +56 -0
- package/cjs/lib/Discord/structures/BaseEntitlement.cjs +40 -0
- package/cjs/lib/Discord/structures/CategoryChannel.cjs +102 -0
- package/cjs/lib/Discord/structures/Channel.cjs +89 -0
- package/cjs/lib/Discord/structures/ClientApplication.cjs +269 -0
- package/cjs/lib/Discord/structures/CommandInteraction.cjs +294 -0
- package/cjs/lib/Discord/structures/ComponentInteraction.cjs +306 -0
- package/cjs/lib/Discord/structures/Entitlement.cjs +24 -0
- package/cjs/lib/Discord/structures/ExtendedUser.cjs +48 -0
- package/cjs/lib/Discord/structures/ForumChannel.cjs +20 -0
- package/cjs/lib/Discord/structures/GroupChannel.cjs +160 -0
- package/cjs/lib/Discord/structures/Guild.cjs +1289 -0
- package/cjs/lib/Discord/structures/GuildChannel.cjs +82 -0
- package/cjs/lib/Discord/structures/GuildPreview.cjs +141 -0
- package/cjs/lib/Discord/structures/GuildScheduledEvent.cjs +166 -0
- package/cjs/lib/Discord/structures/GuildTemplate.cjs +96 -0
- package/cjs/lib/Discord/structures/Integration.cjs +123 -0
- package/cjs/lib/Discord/structures/Interaction.cjs +78 -0
- package/cjs/lib/Discord/structures/InteractionResolvedChannel.cjs +36 -0
- package/cjs/lib/Discord/structures/Invite.cjs +196 -0
- package/cjs/lib/Discord/structures/InviteGuild.cjs +117 -0
- package/cjs/lib/Discord/structures/InviteRole.cjs +88 -0
- package/cjs/lib/Discord/structures/Lobby.cjs +84 -0
- package/cjs/lib/Discord/structures/LobbyMember.cjs +30 -0
- package/cjs/lib/Discord/structures/MediaChannel.cjs +20 -0
- package/cjs/lib/Discord/structures/Member.cjs +300 -0
- package/cjs/lib/Discord/structures/Message.cjs +553 -0
- package/cjs/lib/Discord/structures/ModalSubmitInteraction.cjs +263 -0
- package/cjs/lib/Discord/structures/OAuthApplication.cjs +203 -0
- package/cjs/lib/Discord/structures/OAuthGuild.cjs +98 -0
- package/cjs/lib/Discord/structures/PartialApplication.cjs +97 -0
- package/cjs/lib/Discord/structures/Permission.cjs +61 -0
- package/cjs/lib/Discord/structures/PermissionOverwrite.cjs +46 -0
- package/cjs/lib/Discord/structures/PingInteraction.cjs +27 -0
- package/cjs/lib/Discord/structures/Poll.cjs +69 -0
- package/cjs/lib/Discord/structures/PrimaryGuild.cjs +93 -0
- package/cjs/lib/Discord/structures/PrivateChannel.cjs +131 -0
- package/cjs/lib/Discord/structures/PrivateThreadChannel.cjs +28 -0
- package/cjs/lib/Discord/structures/PublicThreadChannel.cjs +36 -0
- package/cjs/lib/Discord/structures/Role.cjs +126 -0
- package/cjs/lib/Discord/structures/SKU.cjs +58 -0
- package/cjs/lib/Discord/structures/Soundboard.cjs +58 -0
- package/cjs/lib/Discord/structures/StageChannel.cjs +45 -0
- package/cjs/lib/Discord/structures/StageInstance.cjs +80 -0
- package/cjs/lib/Discord/structures/Subscription.cjs +21 -0
- package/cjs/lib/Discord/structures/Team.cjs +70 -0
- package/cjs/lib/Discord/structures/TestEntitlement.cjs +22 -0
- package/cjs/lib/Discord/structures/TextChannel.cjs +48 -0
- package/cjs/lib/Discord/structures/TextableChannel.cjs +265 -0
- package/cjs/lib/Discord/structures/TextableVoiceChannel.cjs +70 -0
- package/cjs/lib/Discord/structures/ThreadChannel.cjs +276 -0
- package/cjs/lib/Discord/structures/ThreadOnlyChannel.cjs +205 -0
- package/cjs/lib/Discord/structures/ThreadableChannel.cjs +57 -0
- package/cjs/lib/Discord/structures/UnavailableGuild.cjs +21 -0
- package/cjs/lib/Discord/structures/User.cjs +223 -0
- package/cjs/lib/Discord/structures/VoiceChannel.cjs +34 -0
- package/cjs/lib/Discord/structures/VoiceState.cjs +113 -0
- package/cjs/lib/Discord/structures/Webhook.cjs +224 -0
- package/cjs/lib/Discord/util/Collection.cjs +77 -0
- package/cjs/lib/Discord/util/Errors.cjs +81 -0
- package/cjs/lib/Discord/util/QueryBuilder.cjs +20 -0
- package/cjs/lib/Discord/util/Routes.cjs +293 -0
- package/cjs/lib/Discord/util/SimpleCollection.cjs +78 -0
- package/cjs/lib/Discord/util/Time.cjs +92 -0
- package/cjs/lib/Discord/util/TypedCollection.cjs +78 -0
- package/cjs/lib/Discord/util/TypedEmitter.cjs +20 -0
- package/cjs/lib/Discord/util/Util.cjs +906 -0
- package/cjs/lib/Discord/util/interactions/InteractionOptionsWrapper.cjs +207 -0
- package/cjs/lib/Discord/util/interactions/MessageInteractionResponse.cjs +26 -0
- package/cjs/lib/Discord/util/interactions/ModalSubmitInteractionComponentsWrapper.cjs +98 -0
- package/cjs/lib/Discord/util/interactions/SelectMenuValuesWrapper.cjs +77 -0
- package/cjs/lib/Discord/util/interactions/shared.cjs +20 -0
- package/cjs/lib/Discord/util/warning.cjs +34 -0
- package/cjs/lib/Signal/Group/ciphertext-message.cjs +16 -0
- package/cjs/lib/Signal/Group/group-session-builder.cjs +67 -0
- package/cjs/lib/Signal/Group/group_cipher.cjs +86 -0
- package/cjs/lib/Signal/Group/index.cjs +58 -0
- package/cjs/lib/Signal/Group/keyhelper.cjs +56 -0
- package/cjs/lib/Signal/Group/sender-chain-key.cjs +30 -0
- package/cjs/lib/Signal/Group/sender-key-distribution-message.cjs +67 -0
- package/cjs/lib/Signal/Group/sender-key-message.cjs +70 -0
- package/cjs/lib/Signal/Group/sender-key-name.cjs +52 -0
- package/cjs/lib/Signal/Group/sender-key-record.cjs +45 -0
- package/cjs/lib/Signal/Group/sender-key-state.cjs +88 -0
- package/cjs/lib/Signal/Group/sender-message-key.cjs +30 -0
- package/cjs/lib/Signal/libsignal.cjs +467 -0
- package/cjs/lib/Signal/lid-mapping.cjs +281 -0
- package/cjs/lib/Socket/Client/index.cjs +19 -0
- package/cjs/lib/Socket/Client/types.cjs +15 -0
- package/cjs/lib/Socket/Client/websocket.cjs +61 -0
- package/cjs/lib/Socket/business.cjs +384 -0
- package/cjs/lib/Socket/chats.cjs +1221 -0
- package/cjs/lib/Socket/communities.cjs +440 -0
- package/cjs/lib/Socket/groups.cjs +353 -0
- package/cjs/lib/Socket/index.cjs +14 -0
- package/cjs/lib/Socket/messages-recv.cjs +1772 -0
- package/cjs/lib/Socket/messages-send.cjs +1376 -0
- package/cjs/lib/Socket/mex.cjs +46 -0
- package/cjs/lib/Socket/newsletter.cjs +230 -0
- package/cjs/lib/Socket/socket.cjs +976 -0
- package/cjs/lib/Store/index.cjs +20 -0
- package/cjs/lib/Store/make-in-memory-store.cjs +470 -0
- package/cjs/lib/Store/make-ordered-dictionary.cjs +82 -0
- package/cjs/lib/Store/object-repository.cjs +28 -0
- package/cjs/lib/Telegram/button.cjs +147 -0
- package/cjs/lib/Telegram/composer.cjs +582 -0
- package/cjs/lib/Telegram/context.cjs +853 -0
- package/cjs/lib/Telegram/core/helpers/args.cjs +57 -0
- package/cjs/lib/Telegram/core/helpers/check.cjs +55 -0
- package/cjs/lib/Telegram/core/helpers/compact.cjs +16 -0
- package/cjs/lib/Telegram/core/helpers/deunionize.cjs +12 -0
- package/cjs/lib/Telegram/core/helpers/formatting.cjs +91 -0
- package/cjs/lib/Telegram/core/helpers/util.cjs +50 -0
- package/cjs/lib/Telegram/core/network/client.cjs +338 -0
- package/cjs/lib/Telegram/core/network/error.cjs +21 -0
- package/cjs/lib/Telegram/core/network/multipart-stream.cjs +79 -0
- package/cjs/lib/Telegram/core/network/polling.cjs +87 -0
- package/cjs/lib/Telegram/core/network/webhook.cjs +54 -0
- package/cjs/lib/Telegram/core/types/typegram.cjs +31 -0
- package/cjs/lib/Telegram/deffa-telegraf.cjs +264 -0
- package/cjs/lib/Telegram/esm-bridge.cjs +20 -0
- package/cjs/lib/Telegram/filters.cjs +69 -0
- package/cjs/lib/Telegram/format.cjs +58 -0
- package/cjs/lib/Telegram/future.cjs +140 -0
- package/cjs/lib/Telegram/index.cjs +67 -0
- package/cjs/lib/Telegram/input.cjs +61 -0
- package/cjs/lib/Telegram/markup.cjs +129 -0
- package/cjs/lib/Telegram/middleware.cjs +2 -0
- package/cjs/lib/Telegram/reactions.cjs +84 -0
- package/cjs/lib/Telegram/router.cjs +46 -0
- package/cjs/lib/Telegram/scenes/base.cjs +39 -0
- package/cjs/lib/Telegram/scenes/context.cjs +104 -0
- package/cjs/lib/Telegram/scenes/index.cjs +21 -0
- package/cjs/lib/Telegram/scenes/stage.cjs +49 -0
- package/cjs/lib/Telegram/scenes/wizard/context.cjs +31 -0
- package/cjs/lib/Telegram/scenes/wizard/index.cjs +45 -0
- package/cjs/lib/Telegram/scenes.cjs +21 -0
- package/cjs/lib/Telegram/session.cjs +166 -0
- package/cjs/lib/Telegram/telegram-types.cjs +6 -0
- package/cjs/lib/Telegram/telegram.cjs +945 -0
- package/cjs/lib/Telegram/types.cjs +2 -0
- package/cjs/lib/Telegram/utils.cjs +5 -0
- package/cjs/lib/Types/Auth.cjs +3 -0
- package/cjs/lib/Types/Bussines.cjs +3 -0
- package/cjs/lib/Types/Call.cjs +3 -0
- package/cjs/lib/Types/Chat.cjs +11 -0
- package/cjs/lib/Types/Contact.cjs +3 -0
- package/cjs/lib/Types/Events.cjs +4 -0
- package/cjs/lib/Types/GroupMetadata.cjs +3 -0
- package/cjs/lib/Types/Label.cjs +26 -0
- package/cjs/lib/Types/LabelAssociation.cjs +8 -0
- package/cjs/lib/Types/Message.cjs +19 -0
- package/cjs/lib/Types/Mex.cjs +40 -0
- package/cjs/lib/Types/Product.cjs +3 -0
- package/cjs/lib/Types/RichType.cjs +24 -0
- package/cjs/lib/Types/Signal.cjs +4 -0
- package/cjs/lib/Types/Socket.cjs +4 -0
- package/cjs/lib/Types/State.cjs +54 -0
- package/cjs/lib/Types/USync.cjs +4 -0
- package/cjs/lib/Types/index.cjs +42 -0
- package/cjs/lib/Utils/auth-utils.cjs +312 -0
- package/cjs/lib/Utils/browser-utils.cjs +39 -0
- package/cjs/lib/Utils/business.cjs +241 -0
- package/cjs/lib/Utils/chat-utils.cjs +890 -0
- package/cjs/lib/Utils/companion-reg-client-utils.cjs +51 -0
- package/cjs/lib/Utils/crypto.cjs +170 -0
- package/cjs/lib/Utils/decode-wa-message.cjs +330 -0
- package/cjs/lib/Utils/event-buffer.cjs +629 -0
- package/cjs/lib/Utils/generics.cjs +427 -0
- package/cjs/lib/Utils/history.cjs +141 -0
- package/cjs/lib/Utils/identity-change-handler.cjs +56 -0
- package/cjs/lib/Utils/index.cjs +43 -0
- package/cjs/lib/Utils/link-preview.cjs +122 -0
- package/cjs/lib/Utils/logger.cjs +8 -0
- package/cjs/lib/Utils/lt-hash.cjs +11 -0
- package/cjs/lib/Utils/make-mutex.cjs +38 -0
- package/cjs/lib/Utils/message-retry-manager.cjs +267 -0
- package/cjs/lib/Utils/messages-media.cjs +906 -0
- package/cjs/lib/Utils/messages.cjs +1909 -0
- package/cjs/lib/Utils/noise-handler.cjs +205 -0
- package/cjs/lib/Utils/offline-node-processor.cjs +43 -0
- package/cjs/lib/Utils/pre-key-manager.cjs +113 -0
- package/cjs/lib/Utils/process-message.cjs +755 -0
- package/cjs/lib/Utils/reporting-utils.cjs +263 -0
- package/cjs/lib/Utils/rich-message-utils.cjs +434 -0
- package/cjs/lib/Utils/session-guard.cjs +163 -0
- package/cjs/lib/Utils/signal.cjs +214 -0
- package/cjs/lib/Utils/stanza-ack.cjs +41 -0
- package/cjs/lib/Utils/sync-action-utils.cjs +54 -0
- package/cjs/lib/Utils/tc-token-utils.cjs +174 -0
- package/cjs/lib/Utils/text-sticker.cjs +174 -0
- package/cjs/lib/Utils/use-multi-file-auth-state.cjs +125 -0
- package/cjs/lib/Utils/use-single-file-auth-state.cjs +113 -0
- package/cjs/lib/Utils/use-sqlite-auth-state.cjs +145 -0
- package/cjs/lib/Utils/validate-connection.cjs +210 -0
- package/cjs/lib/WABinary/constants.cjs +1470 -0
- package/cjs/lib/WABinary/decode.cjs +301 -0
- package/cjs/lib/WABinary/encode.cjs +257 -0
- package/cjs/lib/WABinary/generic-utils.cjs +240 -0
- package/cjs/lib/WABinary/index.cjs +22 -0
- package/cjs/lib/WABinary/jid-utils.cjs +114 -0
- package/cjs/lib/WABinary/types.cjs +37 -0
- package/cjs/lib/WAM/BinaryInfo.cjs +14 -0
- package/cjs/lib/WAM/constants.cjs +22856 -0
- package/cjs/lib/WAM/encode.cjs +154 -0
- package/cjs/lib/WAM/index.cjs +20 -0
- package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.cjs +56 -0
- package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.cjs +58 -0
- package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.cjs +31 -0
- package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.cjs +42 -0
- package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.cjs +29 -0
- package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.cjs +55 -0
- package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.cjs +33 -0
- package/cjs/lib/WAUSync/Protocols/index.cjs +22 -0
- package/cjs/lib/WAUSync/USyncQuery.cjs +102 -0
- package/cjs/lib/WAUSync/USyncUser.cjs +35 -0
- package/cjs/lib/WAUSync/index.cjs +20 -0
- package/cjs/lib/index.cjs +372 -0
- package/cjs/lib/plugins/loader.cjs +117 -0
- package/lib/Defaults/index.js +1 -1
- package/lib/Socket/socket.js +3 -3
- package/lib/Telegram/esm-bridge.mjs +1 -1
- package/package.json +11 -6
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./make-in-memory-store.cjs"), exports);
|
|
18
|
+
__exportStar(require("./make-ordered-dictionary.cjs"), exports);
|
|
19
|
+
__exportStar(require("./object-repository.cjs"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* deffa-baileys — makeInMemoryStore
|
|
4
|
+
* Enhanced in-memory store: no limit, full tracking, auto-group-cache,
|
|
5
|
+
* presence TTL, search, stats, dan event hooks.
|
|
6
|
+
* by Deffa
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.makeInMemoryStore = exports.waLabelAssociationKey = exports.waMessageID = exports.waChatKey = void 0;
|
|
13
|
+
const keyed_db_1 = __importDefault(require("@adiwajshing/keyed-db"));
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const index_js_1 = require("../Types/index.cjs");
|
|
16
|
+
const LabelAssociation_js_1 = require("../Types/LabelAssociation.cjs");
|
|
17
|
+
const index_js_2 = require("../Defaults/index.cjs");
|
|
18
|
+
const index_js_3 = require("../Utils/index.cjs");
|
|
19
|
+
const index_js_4 = require("../WABinary/index.cjs");
|
|
20
|
+
const make_ordered_dictionary_js_1 = require("./make-ordered-dictionary.cjs");
|
|
21
|
+
const object_repository_js_1 = require("./object-repository.cjs");
|
|
22
|
+
const waChatKey = (pin) => ({
|
|
23
|
+
key: (c) => (pin ? (c.pinned ? '1' : '0') : '') + (c.archived ? '0' : '1') + (c.conversationTimestamp ? c.conversationTimestamp.toString(16).padStart(8, '0') : '') + c.id,
|
|
24
|
+
compare: (k1, k2) => k2.localeCompare(k1)
|
|
25
|
+
});
|
|
26
|
+
exports.waChatKey = waChatKey;
|
|
27
|
+
const waMessageID = (m) => m.key.id || '';
|
|
28
|
+
exports.waMessageID = waMessageID;
|
|
29
|
+
exports.waLabelAssociationKey = {
|
|
30
|
+
key: (la) => (la.type === LabelAssociation_js_1.LabelAssociationType.Chat ? la.chatId + la.labelId : la.chatId + la.messageId + la.labelId),
|
|
31
|
+
compare: (k1, k2) => k2.localeCompare(k1)
|
|
32
|
+
};
|
|
33
|
+
const makeMessagesDictionary = () => (0, make_ordered_dictionary_js_1.makeOrderedDictionary)(exports.waMessageID);
|
|
34
|
+
const makeInMemoryStore = (config = {}) => {
|
|
35
|
+
const socket = config.socket;
|
|
36
|
+
const chatKey = config.chatKey || (0, exports.waChatKey)(true);
|
|
37
|
+
const labelAssociationKey = config.labelAssociationKey || exports.waLabelAssociationKey;
|
|
38
|
+
const logger = config.logger || index_js_2.DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' });
|
|
39
|
+
// ── No-limit: maxMessages per JID (default: Infinity) ──────────
|
|
40
|
+
const maxMessages = config.maxMessages || Infinity;
|
|
41
|
+
// ── Presence TTL (default 5 menit) ─────────────────────────────
|
|
42
|
+
const presenceTTL = config.presenceTTL || 5 * 60 * 1000;
|
|
43
|
+
const KeyedDB = keyed_db_1.default?.default ?? keyed_db_1.default;
|
|
44
|
+
const chats = new KeyedDB(chatKey, c => c.id);
|
|
45
|
+
const messages = {}; // jid → ordered dict — NO LIMIT
|
|
46
|
+
const contacts = {};
|
|
47
|
+
const groupMetadata = {};
|
|
48
|
+
const presences = {}; // jid → { participant → { lastSeen, ... } }
|
|
49
|
+
const presenceTimers = {}; // jid+participant → timeout handle
|
|
50
|
+
const state = { connection: 'close' };
|
|
51
|
+
const labels = new object_repository_js_1.ObjectRepository();
|
|
52
|
+
const labelAssociations = new KeyedDB(labelAssociationKey, labelAssociationKey.key);
|
|
53
|
+
// ── Internal stats ──────────────────────────────────────────────
|
|
54
|
+
let _stats = {
|
|
55
|
+
totalMessages: 0,
|
|
56
|
+
totalChats: 0,
|
|
57
|
+
totalContacts: 0,
|
|
58
|
+
totalGroups: 0,
|
|
59
|
+
messagesUpserted: 0,
|
|
60
|
+
messagesDeleted: 0,
|
|
61
|
+
lastActivity: null,
|
|
62
|
+
};
|
|
63
|
+
// ── Event hooks (user bisa pasang callback) ─────────────────────
|
|
64
|
+
const _hooks = { onMessage: [], onChat: [], onContact: [], onPresence: [] };
|
|
65
|
+
const on = (event, cb) => { if (_hooks[event])
|
|
66
|
+
_hooks[event].push(cb); };
|
|
67
|
+
const _emit = (event, data) => { for (const cb of (_hooks[event] || [])) {
|
|
68
|
+
try {
|
|
69
|
+
cb(data);
|
|
70
|
+
}
|
|
71
|
+
catch (_) { }
|
|
72
|
+
} };
|
|
73
|
+
// ── Helpers ─────────────────────────────────────────────────────
|
|
74
|
+
const assertMessageList = (jid) => {
|
|
75
|
+
if (!messages[jid])
|
|
76
|
+
messages[jid] = makeMessagesDictionary();
|
|
77
|
+
return messages[jid];
|
|
78
|
+
};
|
|
79
|
+
const upsertMessage = (jid, msg, mode = 'append') => {
|
|
80
|
+
const list = assertMessageList(jid);
|
|
81
|
+
list.upsert(msg, mode);
|
|
82
|
+
// Trim jika ada limit (default: Infinity = tidak di-trim)
|
|
83
|
+
if (maxMessages !== Infinity && list.array.length > maxMessages) {
|
|
84
|
+
list.array.splice(0, list.array.length - maxMessages);
|
|
85
|
+
}
|
|
86
|
+
_stats.messagesUpserted++;
|
|
87
|
+
_stats.totalMessages = Object.values(messages).reduce((s, l) => s + l.array.length, 0);
|
|
88
|
+
_stats.lastActivity = new Date();
|
|
89
|
+
_emit('onMessage', { jid, msg });
|
|
90
|
+
};
|
|
91
|
+
const contactsUpsert = (newContacts) => {
|
|
92
|
+
const oldContacts = new Set(Object.keys(contacts));
|
|
93
|
+
for (const contact of newContacts) {
|
|
94
|
+
oldContacts.delete(contact.id);
|
|
95
|
+
contacts[contact.id] = Object.assign(contacts[contact.id] || {}, contact);
|
|
96
|
+
}
|
|
97
|
+
_stats.totalContacts = Object.keys(contacts).length;
|
|
98
|
+
return oldContacts;
|
|
99
|
+
};
|
|
100
|
+
const labelsUpsert = (newLabels) => {
|
|
101
|
+
for (const label of newLabels)
|
|
102
|
+
labels.upsertById(label.id, label);
|
|
103
|
+
};
|
|
104
|
+
// ── Presence dengan TTL — otomatis hapus setelah timeout ───────
|
|
105
|
+
const setPresence = (jid, participant, data) => {
|
|
106
|
+
if (!presences[jid])
|
|
107
|
+
presences[jid] = {};
|
|
108
|
+
presences[jid][participant] = { ...data, _updatedAt: Date.now() };
|
|
109
|
+
_emit('onPresence', { jid, participant, data });
|
|
110
|
+
// Clear TTL lama kalau ada
|
|
111
|
+
const tKey = jid + '::' + participant;
|
|
112
|
+
if (presenceTimers[tKey])
|
|
113
|
+
clearTimeout(presenceTimers[tKey]);
|
|
114
|
+
presenceTimers[tKey] = setTimeout(() => {
|
|
115
|
+
if (presences[jid])
|
|
116
|
+
delete presences[jid][participant];
|
|
117
|
+
delete presenceTimers[tKey];
|
|
118
|
+
}, presenceTTL);
|
|
119
|
+
};
|
|
120
|
+
// ── Search messages ─────────────────────────────────────────────
|
|
121
|
+
const searchMessages = (query, jid = null) => {
|
|
122
|
+
const results = [];
|
|
123
|
+
const q = query.toLowerCase();
|
|
124
|
+
const jids = jid ? [jid] : Object.keys(messages);
|
|
125
|
+
for (const j of jids) {
|
|
126
|
+
const list = messages[j];
|
|
127
|
+
if (!list)
|
|
128
|
+
continue;
|
|
129
|
+
for (const msg of list.array) {
|
|
130
|
+
const text = msg.message?.conversation
|
|
131
|
+
|| msg.message?.extendedTextMessage?.text
|
|
132
|
+
|| msg.message?.imageMessage?.caption
|
|
133
|
+
|| msg.message?.videoMessage?.caption
|
|
134
|
+
|| '';
|
|
135
|
+
if (text.toLowerCase().includes(q))
|
|
136
|
+
results.push({ jid: j, msg });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return results;
|
|
140
|
+
};
|
|
141
|
+
// ── Stats snapshot ──────────────────────────────────────────────
|
|
142
|
+
const getStats = () => ({
|
|
143
|
+
..._stats,
|
|
144
|
+
totalMessages: Object.values(messages).reduce((s, l) => s + l.array.length, 0),
|
|
145
|
+
totalChats: chats.array?.length ?? 0,
|
|
146
|
+
totalContacts: Object.keys(contacts).length,
|
|
147
|
+
totalGroups: Object.keys(groupMetadata).length,
|
|
148
|
+
jidCount: Object.keys(messages).length,
|
|
149
|
+
});
|
|
150
|
+
// ── Bind ke event emitter ───────────────────────────────────────
|
|
151
|
+
const bind = (ev) => {
|
|
152
|
+
ev.on('connection.update', update => Object.assign(state, update));
|
|
153
|
+
ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
|
|
154
|
+
if (syncType === index_js_1.WAProto.HistorySync.HistorySyncType.ON_DEMAND)
|
|
155
|
+
return;
|
|
156
|
+
if (isLatest) {
|
|
157
|
+
chats.clear();
|
|
158
|
+
for (const id in messages)
|
|
159
|
+
delete messages[id];
|
|
160
|
+
}
|
|
161
|
+
const chatsAdded = chats.insertIfAbsent(...newChats).length;
|
|
162
|
+
logger.debug({ chatsAdded }, 'synced chats');
|
|
163
|
+
const oldContacts = contactsUpsert(newContacts);
|
|
164
|
+
if (isLatest) {
|
|
165
|
+
for (const jid of oldContacts)
|
|
166
|
+
delete contacts[jid];
|
|
167
|
+
}
|
|
168
|
+
logger.debug({ deletedContacts: isLatest ? oldContacts.size : 0, newContacts }, 'synced contacts');
|
|
169
|
+
for (const msg of newMessages) {
|
|
170
|
+
const jid = msg.key.remoteJidAlt || msg.key.remoteJid;
|
|
171
|
+
upsertMessage(jid, msg, 'prepend');
|
|
172
|
+
}
|
|
173
|
+
logger.debug({ messages: newMessages.length }, 'synced messages');
|
|
174
|
+
});
|
|
175
|
+
ev.on('contacts.upsert', c => contactsUpsert(c));
|
|
176
|
+
ev.on('contacts.update', async (updates) => {
|
|
177
|
+
for (const update of updates) {
|
|
178
|
+
let contact = contacts[update.id];
|
|
179
|
+
if (!contact) {
|
|
180
|
+
const contactHashes = await Promise.all(Object.keys(contacts).map(async (contactId) => {
|
|
181
|
+
const { user } = (0, index_js_4.jidDecode)(contactId);
|
|
182
|
+
return [contactId, (await (0, index_js_3.md5)(Buffer.from(user + 'WA_ADD_NOTIF', 'utf8'))).toString('base64').slice(0, 3)];
|
|
183
|
+
}));
|
|
184
|
+
contact = contacts[(contactHashes.find(([, b]) => b === update.id))?.[0] || ''];
|
|
185
|
+
}
|
|
186
|
+
if (contact) {
|
|
187
|
+
if (update.imgUrl === 'changed') {
|
|
188
|
+
contact.imgUrl = socket ? await socket?.profilePictureUrl(contact.id) : undefined;
|
|
189
|
+
}
|
|
190
|
+
else if (update.imgUrl === 'removed') {
|
|
191
|
+
delete contact.imgUrl;
|
|
192
|
+
}
|
|
193
|
+
Object.assign(contacts[contact.id], contact);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
logger.debug({ update }, 'got update for non-existant contact');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
ev.on('chats.upsert', newChats => {
|
|
201
|
+
chats.upsert(...newChats);
|
|
202
|
+
_stats.totalChats = chats.array?.length ?? 0;
|
|
203
|
+
_emit('onChat', newChats);
|
|
204
|
+
});
|
|
205
|
+
ev.on('chats.update', updates => {
|
|
206
|
+
for (let update of updates) {
|
|
207
|
+
const result = chats.update(update.id, chat => {
|
|
208
|
+
if (update.unreadCount > 0) {
|
|
209
|
+
update = { ...update };
|
|
210
|
+
update.unreadCount = (chat.unreadCount || 0) + update.unreadCount;
|
|
211
|
+
}
|
|
212
|
+
Object.assign(chat, update);
|
|
213
|
+
});
|
|
214
|
+
if (!result)
|
|
215
|
+
logger.debug({ update }, 'got update for non-existant chat');
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
ev.on('labels.edit', (label) => {
|
|
219
|
+
if (label.deleted)
|
|
220
|
+
return labels.deleteById(label.id);
|
|
221
|
+
if (labels.count() < 20)
|
|
222
|
+
return labels.upsertById(label.id, label);
|
|
223
|
+
logger.error('Labels count exceed');
|
|
224
|
+
});
|
|
225
|
+
ev.on('labels.association', ({ type, association }) => {
|
|
226
|
+
if (type === 'add')
|
|
227
|
+
labelAssociations.upsert(association);
|
|
228
|
+
else if (type === 'remove')
|
|
229
|
+
labelAssociations.delete(association);
|
|
230
|
+
else
|
|
231
|
+
console.error(`unknown operation type [${type}]`);
|
|
232
|
+
});
|
|
233
|
+
ev.on('presence.update', ({ id, presences: update }) => {
|
|
234
|
+
for (const [participant, data] of Object.entries(update)) {
|
|
235
|
+
setPresence(id, participant, data);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
ev.on('chats.delete', deletions => {
|
|
239
|
+
for (const item of deletions) {
|
|
240
|
+
if (chats.get(item))
|
|
241
|
+
chats.deleteById(item);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
ev.on('messages.upsert', ({ messages: newMessages, type }) => {
|
|
245
|
+
if (type === 'append' || type === 'notify') {
|
|
246
|
+
for (const msg of newMessages) {
|
|
247
|
+
const jid = (0, index_js_4.jidNormalizedUser)(msg.key.remoteJidAlt || msg.key.remoteJid);
|
|
248
|
+
upsertMessage(jid, msg, 'append');
|
|
249
|
+
if (type === 'notify' && !chats.get(jid)) {
|
|
250
|
+
ev.emit('chats.upsert', [{
|
|
251
|
+
id: jid,
|
|
252
|
+
conversationTimestamp: (0, index_js_3.toNumber)(msg.messageTimestamp),
|
|
253
|
+
unreadCount: 1
|
|
254
|
+
}]);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
ev.on('messages.update', updates => {
|
|
260
|
+
for (const { update, key } of updates) {
|
|
261
|
+
const list = assertMessageList((0, index_js_4.jidNormalizedUser)(key.remoteJid));
|
|
262
|
+
if (update?.status) {
|
|
263
|
+
const listStatus = list.get(key.id)?.status;
|
|
264
|
+
if (listStatus && update?.status <= listStatus) {
|
|
265
|
+
logger.debug({ update, storedStatus: listStatus }, 'status stored newer then update');
|
|
266
|
+
delete update.status;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const result = list.updateAssign(key.id, update);
|
|
270
|
+
if (!result)
|
|
271
|
+
logger.debug({ update }, 'got update for non-existent message');
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
ev.on('messages.delete', item => {
|
|
275
|
+
if ('all' in item) {
|
|
276
|
+
const list = messages[item.jid];
|
|
277
|
+
if (list) {
|
|
278
|
+
_stats.messagesDeleted += list.array.length;
|
|
279
|
+
_stats.totalMessages -= list.array.length;
|
|
280
|
+
list.clear();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
const jid = item.keys[0].remoteJidAlt || item.keys[0].remoteJid;
|
|
285
|
+
const list = messages[jid];
|
|
286
|
+
if (list) {
|
|
287
|
+
const idSet = new Set(item.keys.map(k => k.id));
|
|
288
|
+
const before = list.array.length;
|
|
289
|
+
list.filter(m => !idSet.has(m.key.id));
|
|
290
|
+
_stats.messagesDeleted += before - list.array.length;
|
|
291
|
+
_stats.totalMessages -= before - list.array.length;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
ev.on('groups.update', updates => {
|
|
296
|
+
for (const update of updates) {
|
|
297
|
+
const id = update.id;
|
|
298
|
+
if (groupMetadata[id])
|
|
299
|
+
Object.assign(groupMetadata[id], update);
|
|
300
|
+
else
|
|
301
|
+
logger.debug({ update }, 'got update for non-existant group metadata');
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
ev.on('group-participants.update', ({ id, participants, action }) => {
|
|
305
|
+
const metadata = groupMetadata[id];
|
|
306
|
+
if (!metadata)
|
|
307
|
+
return;
|
|
308
|
+
switch (action) {
|
|
309
|
+
case 'add':
|
|
310
|
+
metadata.participants.push(...participants.map(p => ({ id: p.id, phoneNumber: p.phoneNumber, admin: p.admin })));
|
|
311
|
+
break;
|
|
312
|
+
case 'demote':
|
|
313
|
+
case 'promote':
|
|
314
|
+
for (const p of metadata.participants) {
|
|
315
|
+
for (const pd of participants) {
|
|
316
|
+
if (pd.id === p.id || pd.phoneNumber === p.phoneNumber) {
|
|
317
|
+
p.admin = action === 'promote' ? 'admin' : null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
break;
|
|
322
|
+
case 'remove':
|
|
323
|
+
const removeSet = new Set(participants.flatMap(p => [p.id, p.phoneNumber].filter(Boolean)));
|
|
324
|
+
metadata.participants = metadata.participants.filter(p => !removeSet.has(p.id) && !removeSet.has(p.phoneNumber));
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
_stats.totalGroups = Object.keys(groupMetadata).length;
|
|
328
|
+
});
|
|
329
|
+
ev.on('message-receipt.update', updates => {
|
|
330
|
+
for (const { key, receipt } of updates) {
|
|
331
|
+
const obj = messages[key.remoteJidAlt || key.remoteJid];
|
|
332
|
+
const msg = obj?.get(key.id);
|
|
333
|
+
if (msg)
|
|
334
|
+
(0, index_js_3.updateMessageWithReceipt)(msg, receipt);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
ev.on('messages.reaction', reactions => {
|
|
338
|
+
for (const { key, reaction } of reactions) {
|
|
339
|
+
const obj = messages[key.remoteJidAlt || key.remoteJid];
|
|
340
|
+
const msg = obj?.get(key.id);
|
|
341
|
+
if (msg)
|
|
342
|
+
(0, index_js_3.updateMessageWithReaction)(msg, reaction);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
const toJSON = () => ({ chats, contacts, messages, labels, labelAssociations });
|
|
347
|
+
const fromJSON = (json) => {
|
|
348
|
+
chats.upsert(...json.chats);
|
|
349
|
+
labelAssociations.upsert(...(json.labelAssociations || []));
|
|
350
|
+
contactsUpsert(Object.values(json.contacts));
|
|
351
|
+
labelsUpsert(Object.values(json.labels || {}));
|
|
352
|
+
for (const jid in json.messages) {
|
|
353
|
+
const list = assertMessageList(jid);
|
|
354
|
+
for (const msg of json.messages[jid]) {
|
|
355
|
+
list.upsert(index_js_1.WAProto.WebMessageInfo.fromObject(msg), 'append');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
return {
|
|
360
|
+
chats,
|
|
361
|
+
contacts,
|
|
362
|
+
messages,
|
|
363
|
+
groupMetadata,
|
|
364
|
+
state,
|
|
365
|
+
presences,
|
|
366
|
+
labels,
|
|
367
|
+
labelAssociations,
|
|
368
|
+
// ── Enhanced API ─────────────────────────────────────────────
|
|
369
|
+
bind,
|
|
370
|
+
on,
|
|
371
|
+
getStats,
|
|
372
|
+
searchMessages,
|
|
373
|
+
loadMessages: async (jid, count, cursor) => {
|
|
374
|
+
const list = assertMessageList(jid);
|
|
375
|
+
const mode = !cursor || 'before' in cursor ? 'before' : 'after';
|
|
376
|
+
const cursorKey = !!cursor ? ('before' in cursor ? cursor.before : cursor.after) : undefined;
|
|
377
|
+
const cursorValue = cursorKey ? list.get(cursorKey.id) : undefined;
|
|
378
|
+
let msgs;
|
|
379
|
+
if (list && mode === 'before' && (!cursorKey || cursorValue)) {
|
|
380
|
+
if (cursorValue) {
|
|
381
|
+
const msgIdx = list.array.findIndex(m => m.key.id === cursorKey?.id);
|
|
382
|
+
msgs = list.array.slice(0, msgIdx);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
msgs = list.array;
|
|
386
|
+
}
|
|
387
|
+
const diff = count - msgs.length;
|
|
388
|
+
if (diff < 0)
|
|
389
|
+
msgs = msgs.slice(-count);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
msgs = [];
|
|
393
|
+
}
|
|
394
|
+
return msgs;
|
|
395
|
+
},
|
|
396
|
+
// Load semua pesan suatu JID tanpa limit
|
|
397
|
+
loadAllMessages: async (jid) => {
|
|
398
|
+
return messages[jid]?.array ?? [];
|
|
399
|
+
},
|
|
400
|
+
// Ambil N pesan terakhir
|
|
401
|
+
loadLastMessages: async (jid, n = 20) => {
|
|
402
|
+
return (messages[jid]?.array ?? []).slice(-n);
|
|
403
|
+
},
|
|
404
|
+
getLabels: () => labels,
|
|
405
|
+
getChatLabels: (chatId) => labelAssociations.filter(la => la.chatId === chatId).all(),
|
|
406
|
+
getMessageLabels: (messageId) => labelAssociations.filter(la => la.messageId === messageId).all().map(({ labelId }) => labelId),
|
|
407
|
+
loadMessage: async (jid, id) => messages[jid]?.get(id),
|
|
408
|
+
mostRecentMessage: async (jid) => messages[jid]?.array.slice(-1)[0],
|
|
409
|
+
fetchImageUrl: async (jid, sock) => {
|
|
410
|
+
const contact = contacts[jid];
|
|
411
|
+
if (!contact)
|
|
412
|
+
return sock?.profilePictureUrl(jid);
|
|
413
|
+
if (typeof contact.imgUrl === 'undefined')
|
|
414
|
+
contact.imgUrl = await sock?.profilePictureUrl(jid);
|
|
415
|
+
return contact.imgUrl;
|
|
416
|
+
},
|
|
417
|
+
fetchGroupMetadata: async (jid, sock) => {
|
|
418
|
+
if (!groupMetadata[jid]) {
|
|
419
|
+
const metadata = await sock?.groupMetadata(jid);
|
|
420
|
+
if (metadata) {
|
|
421
|
+
groupMetadata[jid] = metadata;
|
|
422
|
+
_stats.totalGroups = Object.keys(groupMetadata).length;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return groupMetadata[jid];
|
|
426
|
+
},
|
|
427
|
+
// Auto-fetch dan cache semua group yang diikuti
|
|
428
|
+
fetchAllGroupMetadata: async (sock) => {
|
|
429
|
+
if (!sock)
|
|
430
|
+
return groupMetadata;
|
|
431
|
+
const all = await sock.groupFetchAllParticipating();
|
|
432
|
+
for (const [jid, meta] of Object.entries(all))
|
|
433
|
+
groupMetadata[jid] = meta;
|
|
434
|
+
_stats.totalGroups = Object.keys(groupMetadata).length;
|
|
435
|
+
return groupMetadata;
|
|
436
|
+
},
|
|
437
|
+
fetchMessageReceipts: async ({ remoteJid, id }) => {
|
|
438
|
+
return messages[remoteJid]?.get(id)?.userReceipt;
|
|
439
|
+
},
|
|
440
|
+
// Cek apakah pesan sudah di-read oleh penerima
|
|
441
|
+
isMessageRead: (jid, id) => {
|
|
442
|
+
const msg = messages[jid]?.get(id);
|
|
443
|
+
return msg?.status >= 3; // 3 = READ
|
|
444
|
+
},
|
|
445
|
+
toJSON,
|
|
446
|
+
fromJSON,
|
|
447
|
+
writeToFile: (path) => (0, fs_1.writeFileSync)(path, JSON.stringify(toJSON())),
|
|
448
|
+
readFromFile: (path) => {
|
|
449
|
+
if ((0, fs_1.existsSync)(path)) {
|
|
450
|
+
logger.debug({ path }, 'reading from file');
|
|
451
|
+
fromJSON(JSON.parse((0, fs_1.readFileSync)(path, { encoding: 'utf-8' })));
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
// Clear semua data di store (reset total)
|
|
455
|
+
clear: () => {
|
|
456
|
+
chats.clear();
|
|
457
|
+
for (const id in messages)
|
|
458
|
+
delete messages[id];
|
|
459
|
+
for (const id in contacts)
|
|
460
|
+
delete contacts[id];
|
|
461
|
+
for (const id in groupMetadata)
|
|
462
|
+
delete groupMetadata[id];
|
|
463
|
+
for (const id in presences)
|
|
464
|
+
delete presences[id];
|
|
465
|
+
_stats = { totalMessages: 0, totalChats: 0, totalContacts: 0, totalGroups: 0, messagesUpserted: 0, messagesDeleted: 0, lastActivity: null };
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
exports.makeInMemoryStore = makeInMemoryStore;
|
|
470
|
+
//# sourceMappingURL=make-in-memory-store.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeOrderedDictionary = makeOrderedDictionary;
|
|
4
|
+
function makeOrderedDictionary(idGetter) {
|
|
5
|
+
const array = [];
|
|
6
|
+
const dict = {};
|
|
7
|
+
const get = (id) => dict[id];
|
|
8
|
+
const update = (item) => {
|
|
9
|
+
const id = idGetter(item);
|
|
10
|
+
const idx = array.findIndex(i => idGetter(i) === id);
|
|
11
|
+
if (idx >= 0) {
|
|
12
|
+
array[idx] = item;
|
|
13
|
+
dict[id] = item;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
const upsert = (item, mode) => {
|
|
18
|
+
const id = idGetter(item);
|
|
19
|
+
if (get(id)) {
|
|
20
|
+
update(item);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
if (mode === 'append') {
|
|
24
|
+
array.push(item);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
array.splice(0, 0, item);
|
|
28
|
+
}
|
|
29
|
+
dict[id] = item;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const remove = (item) => {
|
|
33
|
+
const id = idGetter(item);
|
|
34
|
+
const idx = array.findIndex(i => idGetter(i) === id);
|
|
35
|
+
if (idx >= 0) {
|
|
36
|
+
array.splice(idx, 1);
|
|
37
|
+
delete dict[id];
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
array,
|
|
44
|
+
get,
|
|
45
|
+
upsert,
|
|
46
|
+
update,
|
|
47
|
+
remove,
|
|
48
|
+
updateAssign: (id, update) => {
|
|
49
|
+
const item = get(id);
|
|
50
|
+
if (item) {
|
|
51
|
+
Object.assign(item, update);
|
|
52
|
+
delete dict[id];
|
|
53
|
+
dict[idGetter(item)] = item;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
},
|
|
58
|
+
clear: () => {
|
|
59
|
+
array.splice(0, array.length);
|
|
60
|
+
for (const key of Object.keys(dict)) {
|
|
61
|
+
delete dict[key];
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
filter: (contain) => {
|
|
65
|
+
let i = 0;
|
|
66
|
+
while (i < array.length) {
|
|
67
|
+
if (!contain(array[i])) {
|
|
68
|
+
delete dict[idGetter(array[i])];
|
|
69
|
+
array.splice(i, 1);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
i += 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
toJSON: () => array,
|
|
77
|
+
fromJSON: (newItems) => {
|
|
78
|
+
array.splice(0, array.length, ...newItems);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=make-ordered-dictionary.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectRepository = void 0;
|
|
4
|
+
class ObjectRepository {
|
|
5
|
+
constructor(entities = {}) {
|
|
6
|
+
this.entityMap = new Map(Object.entries(entities));
|
|
7
|
+
}
|
|
8
|
+
findById(id) {
|
|
9
|
+
return this.entityMap.get(id);
|
|
10
|
+
}
|
|
11
|
+
findAll() {
|
|
12
|
+
return Array.from(this.entityMap.values());
|
|
13
|
+
}
|
|
14
|
+
upsertById(id, entity) {
|
|
15
|
+
return this.entityMap.set(id, { ...entity });
|
|
16
|
+
}
|
|
17
|
+
deleteById(id) {
|
|
18
|
+
return this.entityMap.delete(id);
|
|
19
|
+
}
|
|
20
|
+
count() {
|
|
21
|
+
return this.entityMap.size;
|
|
22
|
+
}
|
|
23
|
+
toJSON() {
|
|
24
|
+
return this.findAll();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ObjectRepository = ObjectRepository;
|
|
28
|
+
//# sourceMappingURL=object-repository.js.map
|