@deffa5556/bail 1.0.6 → 1.0.7
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/package.json +11 -6
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.extractCommunityMetadata = exports.makeCommunitiesSocket = void 0;
|
|
7
|
+
const index_js_1 = require("../../WAProto/index.cjs");
|
|
8
|
+
const index_js_2 = require("../Types/index.cjs");
|
|
9
|
+
const index_js_3 = require("../Utils/index.cjs");
|
|
10
|
+
const logger_js_1 = __importDefault(require("../Utils/logger.cjs"));
|
|
11
|
+
const index_js_4 = require("../WABinary/index.cjs");
|
|
12
|
+
const business_js_1 = require("./business.cjs");
|
|
13
|
+
const makeCommunitiesSocket = (config) => {
|
|
14
|
+
const sock = (0, business_js_1.makeBusinessSocket)(config);
|
|
15
|
+
const { authState, ev, query, upsertMessage } = sock;
|
|
16
|
+
const communityQuery = async (jid, type, content) => query({
|
|
17
|
+
tag: 'iq',
|
|
18
|
+
attrs: {
|
|
19
|
+
type,
|
|
20
|
+
xmlns: 'w:g2',
|
|
21
|
+
to: jid
|
|
22
|
+
},
|
|
23
|
+
content
|
|
24
|
+
});
|
|
25
|
+
const communityMetadata = async (jid) => {
|
|
26
|
+
const result = await communityQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
27
|
+
return (0, exports.extractCommunityMetadata)(result);
|
|
28
|
+
};
|
|
29
|
+
const communityFetchAllParticipating = async () => {
|
|
30
|
+
const result = await query({
|
|
31
|
+
tag: 'iq',
|
|
32
|
+
attrs: {
|
|
33
|
+
to: '@g.us',
|
|
34
|
+
xmlns: 'w:g2',
|
|
35
|
+
type: 'get'
|
|
36
|
+
},
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
tag: 'participating',
|
|
40
|
+
attrs: {},
|
|
41
|
+
content: [
|
|
42
|
+
{ tag: 'participants', attrs: {} },
|
|
43
|
+
{ tag: 'description', attrs: {} }
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
const data = {};
|
|
49
|
+
const communitiesChild = (0, index_js_4.getBinaryNodeChild)(result, 'communities');
|
|
50
|
+
if (communitiesChild) {
|
|
51
|
+
const communities = (0, index_js_4.getBinaryNodeChildren)(communitiesChild, 'community');
|
|
52
|
+
for (const communityNode of communities) {
|
|
53
|
+
const meta = (0, exports.extractCommunityMetadata)({
|
|
54
|
+
tag: 'result',
|
|
55
|
+
attrs: {},
|
|
56
|
+
content: [communityNode]
|
|
57
|
+
});
|
|
58
|
+
data[meta.id] = meta;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
sock.ev.emit('groups.update', Object.values(data));
|
|
62
|
+
return data;
|
|
63
|
+
};
|
|
64
|
+
async function parseGroupResult(node) {
|
|
65
|
+
logger_js_1.default.info({ node }, 'parseGroupResult');
|
|
66
|
+
const groupNode = (0, index_js_4.getBinaryNodeChild)(node, 'group');
|
|
67
|
+
if (groupNode) {
|
|
68
|
+
try {
|
|
69
|
+
logger_js_1.default.info({ groupNode }, 'groupNode');
|
|
70
|
+
const metadata = await sock.groupMetadata(`${groupNode.attrs.id}@g.us`);
|
|
71
|
+
return metadata ? metadata : Optional.empty();
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error('Error parsing group metadata:', error);
|
|
75
|
+
return Optional.empty();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return Optional.empty();
|
|
79
|
+
}
|
|
80
|
+
const Optional = {
|
|
81
|
+
empty: () => null,
|
|
82
|
+
of: (value) => (value !== null ? { value } : null)
|
|
83
|
+
};
|
|
84
|
+
sock.ws.on('CB:ib,,dirty', async (node) => {
|
|
85
|
+
const { attrs } = (0, index_js_4.getBinaryNodeChild)(node, 'dirty');
|
|
86
|
+
if (attrs.type !== 'communities') {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
await communityFetchAllParticipating();
|
|
90
|
+
await sock.cleanDirtyBits('groups');
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
...sock,
|
|
94
|
+
communityQuery,
|
|
95
|
+
communityMetadata,
|
|
96
|
+
communityCreate: async (subject, body) => {
|
|
97
|
+
const descriptionId = (0, index_js_3.generateMessageID)().substring(0, 12);
|
|
98
|
+
const result = await communityQuery('@g.us', 'set', [
|
|
99
|
+
{
|
|
100
|
+
tag: 'create',
|
|
101
|
+
attrs: { subject },
|
|
102
|
+
content: [
|
|
103
|
+
{
|
|
104
|
+
tag: 'description',
|
|
105
|
+
attrs: { id: descriptionId },
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
tag: 'body',
|
|
109
|
+
attrs: {},
|
|
110
|
+
content: Buffer.from(body || '', 'utf-8')
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
tag: 'parent',
|
|
116
|
+
attrs: { default_membership_approval_mode: 'request_required' }
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
tag: 'allow_non_admin_sub_group_creation',
|
|
120
|
+
attrs: {}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
tag: 'create_general_chat',
|
|
124
|
+
attrs: {}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
]);
|
|
129
|
+
return await parseGroupResult(result);
|
|
130
|
+
},
|
|
131
|
+
communityCreateGroup: async (subject, participants, parentCommunityJid) => {
|
|
132
|
+
const key = (0, index_js_3.generateMessageIDV2)();
|
|
133
|
+
const result = await communityQuery('@g.us', 'set', [
|
|
134
|
+
{
|
|
135
|
+
tag: 'create',
|
|
136
|
+
attrs: {
|
|
137
|
+
subject,
|
|
138
|
+
key
|
|
139
|
+
},
|
|
140
|
+
content: [
|
|
141
|
+
...participants.map(jid => ({
|
|
142
|
+
tag: 'participant',
|
|
143
|
+
attrs: { jid }
|
|
144
|
+
})),
|
|
145
|
+
{ tag: 'linked_parent', attrs: { jid: parentCommunityJid } }
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
]);
|
|
149
|
+
return await parseGroupResult(result);
|
|
150
|
+
},
|
|
151
|
+
communityLeave: async (id) => {
|
|
152
|
+
await communityQuery('@g.us', 'set', [
|
|
153
|
+
{
|
|
154
|
+
tag: 'leave',
|
|
155
|
+
attrs: {},
|
|
156
|
+
content: [{ tag: 'community', attrs: { id } }]
|
|
157
|
+
}
|
|
158
|
+
]);
|
|
159
|
+
},
|
|
160
|
+
communityUpdateSubject: async (jid, subject) => {
|
|
161
|
+
await communityQuery(jid, 'set', [
|
|
162
|
+
{
|
|
163
|
+
tag: 'subject',
|
|
164
|
+
attrs: {},
|
|
165
|
+
content: Buffer.from(subject, 'utf-8')
|
|
166
|
+
}
|
|
167
|
+
]);
|
|
168
|
+
},
|
|
169
|
+
communityLinkGroup: async (groupJid, parentCommunityJid) => {
|
|
170
|
+
await communityQuery(parentCommunityJid, 'set', [
|
|
171
|
+
{
|
|
172
|
+
tag: 'links',
|
|
173
|
+
attrs: {},
|
|
174
|
+
content: [
|
|
175
|
+
{
|
|
176
|
+
tag: 'link',
|
|
177
|
+
attrs: { link_type: 'sub_group' },
|
|
178
|
+
content: [{ tag: 'group', attrs: { jid: groupJid } }]
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
]);
|
|
183
|
+
},
|
|
184
|
+
communityUnlinkGroup: async (groupJid, parentCommunityJid) => {
|
|
185
|
+
await communityQuery(parentCommunityJid, 'set', [
|
|
186
|
+
{
|
|
187
|
+
tag: 'unlink',
|
|
188
|
+
attrs: { unlink_type: 'sub_group' },
|
|
189
|
+
content: [{ tag: 'group', attrs: { jid: groupJid } }]
|
|
190
|
+
}
|
|
191
|
+
]);
|
|
192
|
+
},
|
|
193
|
+
communityFetchLinkedGroups: async (jid) => {
|
|
194
|
+
let communityJid = jid;
|
|
195
|
+
let isCommunity = false;
|
|
196
|
+
// Try to determine if it is a subgroup or a community
|
|
197
|
+
const metadata = await sock.groupMetadata(jid);
|
|
198
|
+
if (metadata.linkedParent) {
|
|
199
|
+
// It is a subgroup, get the community jid
|
|
200
|
+
communityJid = metadata.linkedParent;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// It is a community
|
|
204
|
+
isCommunity = true;
|
|
205
|
+
}
|
|
206
|
+
// Fetch all subgroups of the community
|
|
207
|
+
const result = await communityQuery(communityJid, 'get', [{ tag: 'sub_groups', attrs: {} }]);
|
|
208
|
+
const linkedGroupsData = [];
|
|
209
|
+
const subGroupsNode = (0, index_js_4.getBinaryNodeChild)(result, 'sub_groups');
|
|
210
|
+
if (subGroupsNode) {
|
|
211
|
+
const groupNodes = (0, index_js_4.getBinaryNodeChildren)(subGroupsNode, 'group');
|
|
212
|
+
for (const groupNode of groupNodes) {
|
|
213
|
+
linkedGroupsData.push({
|
|
214
|
+
id: groupNode.attrs.id ? (0, index_js_4.jidEncode)(groupNode.attrs.id, 'g.us') : undefined,
|
|
215
|
+
subject: groupNode.attrs.subject || '',
|
|
216
|
+
creation: groupNode.attrs.creation ? Number(groupNode.attrs.creation) : undefined,
|
|
217
|
+
owner: groupNode.attrs.creator ? (0, index_js_4.jidNormalizedUser)(groupNode.attrs.creator) : undefined,
|
|
218
|
+
size: groupNode.attrs.size ? Number(groupNode.attrs.size) : undefined
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
communityJid,
|
|
224
|
+
isCommunity,
|
|
225
|
+
linkedGroups: linkedGroupsData
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
communityRequestParticipantsList: async (jid) => {
|
|
229
|
+
const result = await communityQuery(jid, 'get', [
|
|
230
|
+
{
|
|
231
|
+
tag: 'membership_approval_requests',
|
|
232
|
+
attrs: {}
|
|
233
|
+
}
|
|
234
|
+
]);
|
|
235
|
+
const node = (0, index_js_4.getBinaryNodeChild)(result, 'membership_approval_requests');
|
|
236
|
+
const participants = (0, index_js_4.getBinaryNodeChildren)(node, 'membership_approval_request');
|
|
237
|
+
return participants.map(v => v.attrs);
|
|
238
|
+
},
|
|
239
|
+
communityRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
240
|
+
const result = await communityQuery(jid, 'set', [
|
|
241
|
+
{
|
|
242
|
+
tag: 'membership_requests_action',
|
|
243
|
+
attrs: {},
|
|
244
|
+
content: [
|
|
245
|
+
{
|
|
246
|
+
tag: action,
|
|
247
|
+
attrs: {},
|
|
248
|
+
content: participants.map(jid => ({
|
|
249
|
+
tag: 'participant',
|
|
250
|
+
attrs: { jid }
|
|
251
|
+
}))
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
]);
|
|
256
|
+
const node = (0, index_js_4.getBinaryNodeChild)(result, 'membership_requests_action');
|
|
257
|
+
const nodeAction = (0, index_js_4.getBinaryNodeChild)(node, action);
|
|
258
|
+
const participantsAffected = (0, index_js_4.getBinaryNodeChildren)(nodeAction, 'participant');
|
|
259
|
+
return participantsAffected.map(p => {
|
|
260
|
+
return { status: p.attrs.error || '200', jid: p.attrs.jid };
|
|
261
|
+
});
|
|
262
|
+
},
|
|
263
|
+
communityParticipantsUpdate: async (jid, participants, action) => {
|
|
264
|
+
const result = await communityQuery(jid, 'set', [
|
|
265
|
+
{
|
|
266
|
+
tag: action,
|
|
267
|
+
attrs: action === 'remove' ? { linked_groups: 'true' } : {},
|
|
268
|
+
content: participants.map(jid => ({
|
|
269
|
+
tag: 'participant',
|
|
270
|
+
attrs: { jid }
|
|
271
|
+
}))
|
|
272
|
+
}
|
|
273
|
+
]);
|
|
274
|
+
const node = (0, index_js_4.getBinaryNodeChild)(result, action);
|
|
275
|
+
const participantsAffected = (0, index_js_4.getBinaryNodeChildren)(node, 'participant');
|
|
276
|
+
return participantsAffected.map(p => {
|
|
277
|
+
return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
communityUpdateDescription: async (jid, description) => {
|
|
281
|
+
const metadata = await communityMetadata(jid);
|
|
282
|
+
const prev = metadata.descId ?? null;
|
|
283
|
+
await communityQuery(jid, 'set', [
|
|
284
|
+
{
|
|
285
|
+
tag: 'description',
|
|
286
|
+
attrs: {
|
|
287
|
+
...(description ? { id: (0, index_js_3.generateMessageID)() } : { delete: 'true' }),
|
|
288
|
+
...(prev ? { prev } : {})
|
|
289
|
+
},
|
|
290
|
+
content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
|
|
291
|
+
}
|
|
292
|
+
]);
|
|
293
|
+
},
|
|
294
|
+
communityInviteCode: async (jid) => {
|
|
295
|
+
const result = await communityQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
296
|
+
const inviteNode = (0, index_js_4.getBinaryNodeChild)(result, 'invite');
|
|
297
|
+
return inviteNode?.attrs.code;
|
|
298
|
+
},
|
|
299
|
+
communityRevokeInvite: async (jid) => {
|
|
300
|
+
const result = await communityQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
301
|
+
const inviteNode = (0, index_js_4.getBinaryNodeChild)(result, 'invite');
|
|
302
|
+
return inviteNode?.attrs.code;
|
|
303
|
+
},
|
|
304
|
+
communityAcceptInvite: async (code) => {
|
|
305
|
+
const results = await communityQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
306
|
+
const result = (0, index_js_4.getBinaryNodeChild)(results, 'community');
|
|
307
|
+
return result?.attrs.jid;
|
|
308
|
+
},
|
|
309
|
+
/**
|
|
310
|
+
* revoke a v4 invite for someone
|
|
311
|
+
* @param communityJid community jid
|
|
312
|
+
* @param invitedJid jid of person you invited
|
|
313
|
+
* @returns true if successful
|
|
314
|
+
*/
|
|
315
|
+
communityRevokeInviteV4: async (communityJid, invitedJid) => {
|
|
316
|
+
const result = await communityQuery(communityJid, 'set', [
|
|
317
|
+
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
318
|
+
]);
|
|
319
|
+
return !!result;
|
|
320
|
+
},
|
|
321
|
+
/**
|
|
322
|
+
* accept a CommunityInviteMessage
|
|
323
|
+
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
324
|
+
* @param inviteMessage the message to accept
|
|
325
|
+
*/
|
|
326
|
+
communityAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
327
|
+
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
328
|
+
const results = await communityQuery(inviteMessage.groupJid, 'set', [
|
|
329
|
+
{
|
|
330
|
+
tag: 'accept',
|
|
331
|
+
attrs: {
|
|
332
|
+
code: inviteMessage.inviteCode,
|
|
333
|
+
expiration: inviteMessage.inviteExpiration.toString(),
|
|
334
|
+
admin: key.remoteJid
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
]);
|
|
338
|
+
// if we have the full message key
|
|
339
|
+
// update the invite message to be expired
|
|
340
|
+
if (key.id) {
|
|
341
|
+
// create new invite message that is expired
|
|
342
|
+
inviteMessage = index_js_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
343
|
+
inviteMessage.inviteExpiration = 0;
|
|
344
|
+
inviteMessage.inviteCode = '';
|
|
345
|
+
ev.emit('messages.update', [
|
|
346
|
+
{
|
|
347
|
+
key,
|
|
348
|
+
update: {
|
|
349
|
+
message: {
|
|
350
|
+
groupInviteMessage: inviteMessage
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
]);
|
|
355
|
+
}
|
|
356
|
+
// generate the community add message
|
|
357
|
+
await upsertMessage({
|
|
358
|
+
key: {
|
|
359
|
+
remoteJid: inviteMessage.groupJid,
|
|
360
|
+
id: (0, index_js_3.generateMessageIDV2)(sock.user?.id),
|
|
361
|
+
fromMe: false,
|
|
362
|
+
participant: key.remoteJid // TODO: investigate if this makes any sense at all
|
|
363
|
+
},
|
|
364
|
+
messageStubType: index_js_2.WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
365
|
+
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
366
|
+
participant: key.remoteJid,
|
|
367
|
+
messageTimestamp: (0, index_js_3.unixTimestampSeconds)()
|
|
368
|
+
}, 'notify');
|
|
369
|
+
return results.attrs.from;
|
|
370
|
+
}),
|
|
371
|
+
communityGetInviteInfo: async (code) => {
|
|
372
|
+
const results = await communityQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
|
|
373
|
+
return (0, exports.extractCommunityMetadata)(results);
|
|
374
|
+
},
|
|
375
|
+
communityToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
376
|
+
const content = ephemeralExpiration
|
|
377
|
+
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
378
|
+
: { tag: 'not_ephemeral', attrs: {} };
|
|
379
|
+
await communityQuery(jid, 'set', [content]);
|
|
380
|
+
},
|
|
381
|
+
communitySettingUpdate: async (jid, setting) => {
|
|
382
|
+
await communityQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
|
|
383
|
+
},
|
|
384
|
+
communityMemberAddMode: async (jid, mode) => {
|
|
385
|
+
await communityQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
386
|
+
},
|
|
387
|
+
communityJoinApprovalMode: async (jid, mode) => {
|
|
388
|
+
await communityQuery(jid, 'set', [
|
|
389
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'community_join', attrs: { state: mode } }] }
|
|
390
|
+
]);
|
|
391
|
+
},
|
|
392
|
+
communityFetchAllParticipating
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
exports.makeCommunitiesSocket = makeCommunitiesSocket;
|
|
396
|
+
const extractCommunityMetadata = (result) => {
|
|
397
|
+
const community = (0, index_js_4.getBinaryNodeChild)(result, 'community');
|
|
398
|
+
const descChild = (0, index_js_4.getBinaryNodeChild)(community, 'description');
|
|
399
|
+
let desc;
|
|
400
|
+
let descId;
|
|
401
|
+
if (descChild) {
|
|
402
|
+
desc = (0, index_js_4.getBinaryNodeChildString)(descChild, 'body');
|
|
403
|
+
descId = descChild.attrs.id;
|
|
404
|
+
}
|
|
405
|
+
const communityId = community.attrs.id?.includes('@')
|
|
406
|
+
? community.attrs.id
|
|
407
|
+
: (0, index_js_4.jidEncode)(community.attrs.id || '', 'g.us');
|
|
408
|
+
const eph = (0, index_js_4.getBinaryNodeChild)(community, 'ephemeral')?.attrs.expiration;
|
|
409
|
+
const memberAddMode = (0, index_js_4.getBinaryNodeChildString)(community, 'member_add_mode') === 'all_member_add';
|
|
410
|
+
const metadata = {
|
|
411
|
+
id: communityId,
|
|
412
|
+
subject: community.attrs.subject || '',
|
|
413
|
+
subjectOwner: community.attrs.s_o,
|
|
414
|
+
subjectTime: Number(community.attrs.s_t || 0),
|
|
415
|
+
size: (0, index_js_4.getBinaryNodeChildren)(community, 'participant').length,
|
|
416
|
+
creation: Number(community.attrs.creation || 0),
|
|
417
|
+
owner: community.attrs.creator ? (0, index_js_4.jidNormalizedUser)(community.attrs.creator) : undefined,
|
|
418
|
+
desc,
|
|
419
|
+
descId,
|
|
420
|
+
linkedParent: (0, index_js_4.getBinaryNodeChild)(community, 'linked_parent')?.attrs.jid || undefined,
|
|
421
|
+
restrict: !!(0, index_js_4.getBinaryNodeChild)(community, 'locked'),
|
|
422
|
+
announce: !!(0, index_js_4.getBinaryNodeChild)(community, 'announcement'),
|
|
423
|
+
isCommunity: !!(0, index_js_4.getBinaryNodeChild)(community, 'parent'),
|
|
424
|
+
isCommunityAnnounce: !!(0, index_js_4.getBinaryNodeChild)(community, 'default_sub_community'),
|
|
425
|
+
joinApprovalMode: !!(0, index_js_4.getBinaryNodeChild)(community, 'membership_approval_mode'),
|
|
426
|
+
memberAddMode,
|
|
427
|
+
participants: (0, index_js_4.getBinaryNodeChildren)(community, 'participant').map(({ attrs }) => {
|
|
428
|
+
return {
|
|
429
|
+
// TODO: IMPLEMENT THE PN/LID FIELDS HERE!!
|
|
430
|
+
id: attrs.jid,
|
|
431
|
+
admin: (attrs.type || null)
|
|
432
|
+
};
|
|
433
|
+
}),
|
|
434
|
+
ephemeralDuration: eph ? +eph : undefined,
|
|
435
|
+
addressingMode: (0, index_js_4.getBinaryNodeChildString)(community, 'addressing_mode')
|
|
436
|
+
};
|
|
437
|
+
return metadata;
|
|
438
|
+
};
|
|
439
|
+
exports.extractCommunityMetadata = extractCommunityMetadata;
|
|
440
|
+
//# sourceMappingURL=communities.js.map
|