@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,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined)
|
|
4
|
+
k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function (o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined)
|
|
12
|
+
k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function (o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function (o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o)
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(o, k))
|
|
26
|
+
ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule)
|
|
33
|
+
return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null)
|
|
36
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
37
|
+
if (k[i] !== "default")
|
|
38
|
+
__createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
|
+
};
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
const stream = __importStar(require("stream"));
|
|
48
|
+
const check_1 = require("../helpers/check");
|
|
49
|
+
const sandwich_stream_1 = __importDefault(require("sandwich-stream"));
|
|
50
|
+
const CRNL = '\r\n';
|
|
51
|
+
class MultipartStream extends sandwich_stream_1.default {
|
|
52
|
+
constructor(boundary) {
|
|
53
|
+
super({
|
|
54
|
+
head: `--${boundary}${CRNL}`,
|
|
55
|
+
tail: `${CRNL}--${boundary}--`,
|
|
56
|
+
separator: `${CRNL}--${boundary}${CRNL}`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
addPart(part) {
|
|
60
|
+
const partStream = new stream.PassThrough();
|
|
61
|
+
for (const [key, header] of Object.entries(part.headers)) {
|
|
62
|
+
partStream.write(`${key}:${header}${CRNL}`);
|
|
63
|
+
}
|
|
64
|
+
partStream.write(CRNL);
|
|
65
|
+
if (MultipartStream.isStream(part.body)) {
|
|
66
|
+
part.body.pipe(partStream);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
partStream.end(part.body);
|
|
70
|
+
}
|
|
71
|
+
this.add(partStream);
|
|
72
|
+
}
|
|
73
|
+
static isStream(stream) {
|
|
74
|
+
return (typeof stream === 'object' &&
|
|
75
|
+
stream !== null &&
|
|
76
|
+
(0, check_1.hasPropType)(stream, 'pipe', 'function'));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.default = MultipartStream;
|
|
@@ -0,0 +1,87 @@
|
|
|
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.Polling = void 0;
|
|
7
|
+
const abort_controller_1 = __importDefault(require("abort-controller"));
|
|
8
|
+
const debug_1 = __importDefault(require("debug"));
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const error_1 = require("./error");
|
|
11
|
+
const debug = (0, debug_1.default)('telegraf:polling');
|
|
12
|
+
const wait = (0, util_1.promisify)(setTimeout);
|
|
13
|
+
function always(x) {
|
|
14
|
+
return () => x;
|
|
15
|
+
}
|
|
16
|
+
const noop = always(Promise.resolve());
|
|
17
|
+
class Polling {
|
|
18
|
+
constructor(telegram, allowedUpdates) {
|
|
19
|
+
this.telegram = telegram;
|
|
20
|
+
this.allowedUpdates = allowedUpdates;
|
|
21
|
+
this.abortController = new abort_controller_1.default();
|
|
22
|
+
this.skipOffsetSync = false;
|
|
23
|
+
this.offset = 0;
|
|
24
|
+
}
|
|
25
|
+
async *[Symbol.asyncIterator]() {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
debug('Starting long polling');
|
|
28
|
+
do {
|
|
29
|
+
try {
|
|
30
|
+
const updates = await this.telegram.callApi('getUpdates', {
|
|
31
|
+
timeout: 50,
|
|
32
|
+
offset: this.offset,
|
|
33
|
+
allowed_updates: this.allowedUpdates,
|
|
34
|
+
}, this.abortController);
|
|
35
|
+
const last = updates[updates.length - 1];
|
|
36
|
+
if (last !== undefined) {
|
|
37
|
+
this.offset = last.update_id + 1;
|
|
38
|
+
}
|
|
39
|
+
yield updates;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const err = error;
|
|
43
|
+
if (err.name === 'AbortError')
|
|
44
|
+
return;
|
|
45
|
+
if (err.name === 'FetchError' ||
|
|
46
|
+
(err instanceof error_1.TelegramError && err.code === 429) ||
|
|
47
|
+
(err instanceof error_1.TelegramError && err.code >= 500)) {
|
|
48
|
+
const retryAfter = (_b = (_a = err.parameters) === null || _a === void 0 ? void 0 : _a.retry_after) !== null && _b !== void 0 ? _b : 5;
|
|
49
|
+
debug('Failed to fetch updates, retrying after %ds.', retryAfter, err);
|
|
50
|
+
await wait(retryAfter * 1000);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (err instanceof error_1.TelegramError &&
|
|
54
|
+
// Unauthorized Conflict
|
|
55
|
+
(err.code === 401 || err.code === 409)) {
|
|
56
|
+
this.skipOffsetSync = true;
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
} while (!this.abortController.signal.aborted);
|
|
62
|
+
}
|
|
63
|
+
async syncUpdateOffset() {
|
|
64
|
+
if (this.skipOffsetSync)
|
|
65
|
+
return;
|
|
66
|
+
debug('Syncing update offset...');
|
|
67
|
+
await this.telegram.callApi('getUpdates', { offset: this.offset, limit: 1 });
|
|
68
|
+
}
|
|
69
|
+
async loop(handleUpdate) {
|
|
70
|
+
if (this.abortController.signal.aborted)
|
|
71
|
+
throw new Error('Polling instances must not be reused!');
|
|
72
|
+
try {
|
|
73
|
+
for await (const updates of this)
|
|
74
|
+
await Promise.all(updates.map(handleUpdate));
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
debug('Long polling stopped');
|
|
78
|
+
// prevent instance reuse
|
|
79
|
+
this.stop();
|
|
80
|
+
await this.syncUpdateOffset().catch(noop);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
stop() {
|
|
84
|
+
this.abortController.abort();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.Polling = Polling;
|
|
@@ -0,0 +1,54 @@
|
|
|
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.default = generateWebhook;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
|
+
const debug = (0, debug_1.default)('telegraf:webhook');
|
|
9
|
+
function generateWebhook(filter, updateHandler) {
|
|
10
|
+
return async (req, res, next = () => {
|
|
11
|
+
res.statusCode = 403;
|
|
12
|
+
debug('Replying with status code', res.statusCode);
|
|
13
|
+
res.end();
|
|
14
|
+
}) => {
|
|
15
|
+
debug('Incoming request', req.method, req.url);
|
|
16
|
+
if (!filter(req)) {
|
|
17
|
+
debug('Webhook filter failed', req.method, req.url);
|
|
18
|
+
return next();
|
|
19
|
+
}
|
|
20
|
+
let update;
|
|
21
|
+
try {
|
|
22
|
+
if (req.body != null) {
|
|
23
|
+
/* If req.body is already set, we expect it to be the parsed
|
|
24
|
+
request body (update object) received from Telegram
|
|
25
|
+
However, some libraries such as `serverless-http` set req.body to the
|
|
26
|
+
raw buffer, so we'll handle that additionally */
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
let body = req.body;
|
|
29
|
+
// if body is Buffer, parse it into string
|
|
30
|
+
if (body instanceof Buffer)
|
|
31
|
+
body = String(req.body);
|
|
32
|
+
// if body is string, parse it into object
|
|
33
|
+
if (typeof body === 'string')
|
|
34
|
+
body = JSON.parse(body);
|
|
35
|
+
update = body;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
let body = '';
|
|
39
|
+
// parse each buffer to string and append to body
|
|
40
|
+
for await (const chunk of req)
|
|
41
|
+
body += String(chunk);
|
|
42
|
+
// parse body to object
|
|
43
|
+
update = JSON.parse(body);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
// if any of the parsing steps fails, give up and respond with error
|
|
48
|
+
res.writeHead(415).end();
|
|
49
|
+
debug('Failed to parse request body:', error);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
return await updateHandler(update, res);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined)
|
|
4
|
+
k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function (o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined)
|
|
12
|
+
k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function (m, exports) {
|
|
16
|
+
for (var p in m)
|
|
17
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
18
|
+
__createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
// internal type provisions
|
|
22
|
+
__exportStar(require("@telegraf/types/api"), exports);
|
|
23
|
+
__exportStar(require("@telegraf/types/inline"), exports);
|
|
24
|
+
__exportStar(require("@telegraf/types/manage"), exports);
|
|
25
|
+
__exportStar(require("@telegraf/types/markup"), exports);
|
|
26
|
+
__exportStar(require("@telegraf/types/message"), exports);
|
|
27
|
+
__exportStar(require("@telegraf/types/methods"), exports);
|
|
28
|
+
__exportStar(require("@telegraf/types/passport"), exports);
|
|
29
|
+
__exportStar(require("@telegraf/types/payment"), exports);
|
|
30
|
+
__exportStar(require("@telegraf/types/settings"), exports);
|
|
31
|
+
__exportStar(require("@telegraf/types/update"), exports);
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined)
|
|
4
|
+
k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function (o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined)
|
|
12
|
+
k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function (o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function (o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o)
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(o, k))
|
|
26
|
+
ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule)
|
|
33
|
+
return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null)
|
|
36
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
37
|
+
if (k[i] !== "default")
|
|
38
|
+
__createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
|
+
};
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.DeffaTelegraf = void 0;
|
|
48
|
+
const crypto = __importStar(require("crypto"));
|
|
49
|
+
const http = __importStar(require("http"));
|
|
50
|
+
const https = __importStar(require("https"));
|
|
51
|
+
const composer_1 = require("./composer");
|
|
52
|
+
const compact_1 = require("./core/helpers/compact");
|
|
53
|
+
const context_1 = __importDefault(require("./context"));
|
|
54
|
+
const debug_1 = __importDefault(require("debug"));
|
|
55
|
+
const webhook_1 = __importDefault(require("./core/network/webhook"));
|
|
56
|
+
const polling_1 = require("./core/network/polling");
|
|
57
|
+
const p_timeout_1 = __importDefault(require("p-timeout"));
|
|
58
|
+
const telegram_1 = __importDefault(require("./telegram"));
|
|
59
|
+
const url_1 = require("url");
|
|
60
|
+
const safeCompare = require("safe-compare");
|
|
61
|
+
const debug = (0, debug_1.default)('telegraf:main');
|
|
62
|
+
const DEFAULT_OPTIONS = {
|
|
63
|
+
telegram: {},
|
|
64
|
+
handlerTimeout: 90000, // 90s in ms
|
|
65
|
+
contextType: context_1.default,
|
|
66
|
+
};
|
|
67
|
+
function always(x) {
|
|
68
|
+
return () => x;
|
|
69
|
+
}
|
|
70
|
+
const anoop = always(Promise.resolve());
|
|
71
|
+
const TOKEN_HEADER = 'x-telegram-bot-api-secret-token';
|
|
72
|
+
class DeffaTelegraf extends composer_1.Composer {
|
|
73
|
+
constructor(token, options) {
|
|
74
|
+
super();
|
|
75
|
+
this.context = {};
|
|
76
|
+
/** Assign to this to customise the webhook filter middleware.
|
|
77
|
+
* `{ path, secretToken }` will be bound to this rather than the Telegraf instance.
|
|
78
|
+
* Remember to assign a regular function and not an arrow function so it's bindable.
|
|
79
|
+
*/
|
|
80
|
+
this.webhookFilter = function (req) {
|
|
81
|
+
const debug = (0, debug_1.default)('telegraf:webhook');
|
|
82
|
+
if (req.method === 'POST') {
|
|
83
|
+
if (safeCompare(this.path, req.url)) {
|
|
84
|
+
// no need to check if secret_token was not set
|
|
85
|
+
if (!this.secretToken)
|
|
86
|
+
return true;
|
|
87
|
+
else {
|
|
88
|
+
const token = req.headers[TOKEN_HEADER];
|
|
89
|
+
if (safeCompare(this.secretToken, token))
|
|
90
|
+
return true;
|
|
91
|
+
else
|
|
92
|
+
debug('Secret token does not match:', token, this.secretToken);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
debug('Path does not match:', req.url, this.path);
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
debug('Unexpected request method, not POST. Received:', req.method);
|
|
100
|
+
return false;
|
|
101
|
+
};
|
|
102
|
+
this.handleError = (err, ctx) => {
|
|
103
|
+
// set exit code to emulate `warn-with-error-code` behavior of
|
|
104
|
+
// https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode
|
|
105
|
+
// to prevent a clean exit despite an error being thrown
|
|
106
|
+
process.exitCode = 1;
|
|
107
|
+
console.error('Unhandled error while processing', ctx.update);
|
|
108
|
+
throw err;
|
|
109
|
+
};
|
|
110
|
+
// @ts-expect-error Trust me, TS
|
|
111
|
+
this.options = {
|
|
112
|
+
...DEFAULT_OPTIONS,
|
|
113
|
+
...(0, compact_1.compactOptions)(options),
|
|
114
|
+
};
|
|
115
|
+
this.telegram = new telegram_1.default(token, this.options.telegram);
|
|
116
|
+
debug('Created a `Telegraf` instance');
|
|
117
|
+
}
|
|
118
|
+
get token() {
|
|
119
|
+
return this.telegram.token;
|
|
120
|
+
}
|
|
121
|
+
/** @deprecated use `ctx.telegram.webhookReply` */
|
|
122
|
+
set webhookReply(webhookReply) {
|
|
123
|
+
this.telegram.webhookReply = webhookReply;
|
|
124
|
+
}
|
|
125
|
+
/** @deprecated use `ctx.telegram.webhookReply` */
|
|
126
|
+
get webhookReply() {
|
|
127
|
+
return this.telegram.webhookReply;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* _Override_ error handling
|
|
131
|
+
*/
|
|
132
|
+
catch(handler) {
|
|
133
|
+
this.handleError = handler;
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* You must call `bot.telegram.setWebhook` for this to work.
|
|
138
|
+
* You should probably use {@link Telegraf.createWebhook} instead.
|
|
139
|
+
*/
|
|
140
|
+
webhookCallback(path = '/', opts = {}) {
|
|
141
|
+
const { secretToken } = opts;
|
|
142
|
+
return (0, webhook_1.default)(this.webhookFilter.bind({ hookPath: path, path, secretToken }), (update, res) => this.handleUpdate(update, res));
|
|
143
|
+
}
|
|
144
|
+
getDomainOpts(opts) {
|
|
145
|
+
var _a;
|
|
146
|
+
const protocol = opts.domain.startsWith('https://') || opts.domain.startsWith('http://');
|
|
147
|
+
if (protocol)
|
|
148
|
+
debug('Unexpected protocol in domain, telegraf will use https:', opts.domain);
|
|
149
|
+
const domain = protocol ? new url_1.URL(opts.domain).host : opts.domain;
|
|
150
|
+
const path = (_a = opts.path) !== null && _a !== void 0 ? _a : `/telegraf/${this.secretPathComponent()}`;
|
|
151
|
+
const url = `https://${domain}${path}`;
|
|
152
|
+
return { domain, path, url };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Specify a url to receive incoming updates via webhook.
|
|
156
|
+
* Returns an Express-style middleware you can pass to app.use()
|
|
157
|
+
*/
|
|
158
|
+
async createWebhook(opts) {
|
|
159
|
+
const { domain, path, ...extra } = opts;
|
|
160
|
+
const domainOpts = this.getDomainOpts({ domain, path });
|
|
161
|
+
await this.telegram.setWebhook(domainOpts.url, extra);
|
|
162
|
+
debug(`Webhook set to ${domainOpts.url}`);
|
|
163
|
+
return this.webhookCallback(domainOpts.path, {
|
|
164
|
+
secretToken: extra.secret_token,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
startPolling(allowedUpdates = []) {
|
|
168
|
+
this.polling = new polling_1.Polling(this.telegram, allowedUpdates);
|
|
169
|
+
return this.polling.loop(async (update) => {
|
|
170
|
+
await this.handleUpdate(update);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
startWebhook(path, tlsOptions, port, host, cb, secretToken) {
|
|
174
|
+
const webhookCb = this.webhookCallback(path, { secretToken });
|
|
175
|
+
const callback = typeof cb === 'function'
|
|
176
|
+
? (req, res) => webhookCb(req, res, () => cb(req, res))
|
|
177
|
+
: webhookCb;
|
|
178
|
+
this.webhookServer =
|
|
179
|
+
tlsOptions != null
|
|
180
|
+
? https.createServer(tlsOptions, callback)
|
|
181
|
+
: http.createServer(callback);
|
|
182
|
+
this.webhookServer.listen(port, host, () => {
|
|
183
|
+
debug('Webhook listening on port: %s', port);
|
|
184
|
+
});
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
secretPathComponent() {
|
|
188
|
+
return crypto
|
|
189
|
+
.createHash('sha3-256')
|
|
190
|
+
.update(this.token)
|
|
191
|
+
.update(process.version) // salt
|
|
192
|
+
.digest('hex');
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @see https://github.com/telegraf/telegraf/discussions/1344#discussioncomment-335700
|
|
196
|
+
*/
|
|
197
|
+
async launch(config = {},
|
|
198
|
+
/** @experimental */
|
|
199
|
+
onLaunch) {
|
|
200
|
+
var _a, _b;
|
|
201
|
+
const [cfg, onMe] = typeof config === 'function' ? [{}, config] : [config, onLaunch];
|
|
202
|
+
const drop_pending_updates = cfg.dropPendingUpdates;
|
|
203
|
+
const allowed_updates = cfg.allowedUpdates;
|
|
204
|
+
const webhook = cfg.webhook;
|
|
205
|
+
debug('Connecting to Telegram');
|
|
206
|
+
(_a = this.botInfo) !== null && _a !== void 0 ? _a : (this.botInfo = await this.telegram.getMe());
|
|
207
|
+
onMe === null || onMe === void 0 ? void 0 : onMe();
|
|
208
|
+
debug(`Launching @${this.botInfo.username}`);
|
|
209
|
+
if (webhook === undefined) {
|
|
210
|
+
await this.telegram.deleteWebhook({ drop_pending_updates });
|
|
211
|
+
debug('Bot started with long polling');
|
|
212
|
+
await this.startPolling(allowed_updates);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const domainOpts = this.getDomainOpts({
|
|
216
|
+
domain: webhook.domain,
|
|
217
|
+
path: (_b = webhook.path) !== null && _b !== void 0 ? _b : webhook.hookPath,
|
|
218
|
+
});
|
|
219
|
+
const { tlsOptions, port, host, cb, secretToken } = webhook;
|
|
220
|
+
this.startWebhook(domainOpts.path, tlsOptions, port, host, cb, secretToken);
|
|
221
|
+
await this.telegram.setWebhook(domainOpts.url, {
|
|
222
|
+
drop_pending_updates: drop_pending_updates,
|
|
223
|
+
allowed_updates: allowed_updates,
|
|
224
|
+
ip_address: webhook.ipAddress,
|
|
225
|
+
max_connections: webhook.maxConnections,
|
|
226
|
+
secret_token: webhook.secretToken,
|
|
227
|
+
certificate: webhook.certificate,
|
|
228
|
+
});
|
|
229
|
+
debug(`Bot started with webhook @ ${domainOpts.url}`);
|
|
230
|
+
}
|
|
231
|
+
stop(reason = 'unspecified') {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
debug('Stopping bot... Reason:', reason);
|
|
234
|
+
// https://github.com/telegraf/telegraf/pull/1224#issuecomment-742693770
|
|
235
|
+
if (this.polling === undefined && this.webhookServer === undefined) {
|
|
236
|
+
throw new Error('Bot is not running!');
|
|
237
|
+
}
|
|
238
|
+
(_a = this.webhookServer) === null || _a === void 0 ? void 0 : _a.close();
|
|
239
|
+
(_b = this.polling) === null || _b === void 0 ? void 0 : _b.stop();
|
|
240
|
+
}
|
|
241
|
+
async handleUpdate(update, webhookResponse) {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
(_a = this.botInfo) !== null && _a !== void 0 ? _a : (this.botInfo = (debug('Update %d is waiting for `botInfo` to be initialized', update.update_id),
|
|
244
|
+
await ((_b = this.botInfoCall) !== null && _b !== void 0 ? _b : (this.botInfoCall = this.telegram.getMe()))));
|
|
245
|
+
debug('Processing update', update.update_id);
|
|
246
|
+
const tg = new telegram_1.default(this.token, this.telegram.options, webhookResponse);
|
|
247
|
+
const TelegrafContext = this.options.contextType;
|
|
248
|
+
const ctx = new TelegrafContext(update, tg, this.botInfo);
|
|
249
|
+
Object.assign(ctx, this.context);
|
|
250
|
+
try {
|
|
251
|
+
await (0, p_timeout_1.default)(Promise.resolve(this.middleware()(ctx, anoop)), this.options.handlerTimeout);
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
return await this.handleError(err, ctx);
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
if ((webhookResponse === null || webhookResponse === void 0 ? void 0 : webhookResponse.writableEnded) === false) {
|
|
258
|
+
webhookResponse.end();
|
|
259
|
+
}
|
|
260
|
+
debug('Finished processing update', update.update_id);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.DeffaTelegraf = DeffaTelegraf;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TelegramButton = exports.Scenes = exports.Format = exports.Input = exports.Markup = exports.Types = exports.deunionize = exports.MemorySessionStore = exports.session = exports.TelegramError = exports.Telegram = exports.Router = exports.Context = exports.Composer = exports.DeffaTelegraf = void 0;
|
|
4
|
+
// ESM bridge — wraps CJS telegraf compiled output untuk deffa-baileys (ESM)
|
|
5
|
+
const tg = require('./index.cjs');
|
|
6
|
+
exports.DeffaTelegraf = tg.DeffaTelegraf;
|
|
7
|
+
exports.Composer = tg.Composer;
|
|
8
|
+
exports.Context = tg.Context;
|
|
9
|
+
exports.Router = tg.Router;
|
|
10
|
+
exports.Telegram = tg.Telegram;
|
|
11
|
+
exports.TelegramError = tg.TelegramError;
|
|
12
|
+
exports.session = tg.session;
|
|
13
|
+
exports.MemorySessionStore = tg.MemorySessionStore;
|
|
14
|
+
exports.deunionize = tg.deunionize;
|
|
15
|
+
exports.Types = tg.Types;
|
|
16
|
+
exports.Markup = tg.Markup;
|
|
17
|
+
exports.Input = tg.Input;
|
|
18
|
+
exports.Format = tg.Format;
|
|
19
|
+
exports.Scenes = tg.Scenes;
|
|
20
|
+
exports.TelegramButton = tg.TelegramButton;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allOf = exports.anyOf = exports.callbackQuery = exports.editedChannelPost = exports.channelPost = exports.editedMessage = exports.message = void 0;
|
|
4
|
+
const message = (...keys) => (update) => {
|
|
5
|
+
if (!('message' in update))
|
|
6
|
+
return false;
|
|
7
|
+
for (const key of keys) {
|
|
8
|
+
if (!(key in update.message))
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
exports.message = message;
|
|
14
|
+
const editedMessage = (...keys) => (update) => {
|
|
15
|
+
if (!('edited_message' in update))
|
|
16
|
+
return false;
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
if (!(key in update.edited_message))
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
exports.editedMessage = editedMessage;
|
|
24
|
+
const channelPost = (...keys) => (update) => {
|
|
25
|
+
if (!('channel_post' in update))
|
|
26
|
+
return false;
|
|
27
|
+
for (const key of keys) {
|
|
28
|
+
if (!(key in update.channel_post))
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
exports.channelPost = channelPost;
|
|
34
|
+
const editedChannelPost = (...keys) => (update) => {
|
|
35
|
+
if (!('edited_channel_post' in update))
|
|
36
|
+
return false;
|
|
37
|
+
for (const key of keys) {
|
|
38
|
+
if (!(key in update.edited_channel_post))
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
exports.editedChannelPost = editedChannelPost;
|
|
44
|
+
const callbackQuery = (...keys) => (update) => {
|
|
45
|
+
if (!('callback_query' in update))
|
|
46
|
+
return false;
|
|
47
|
+
for (const key of keys) {
|
|
48
|
+
if (!(key in update.callback_query))
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
exports.callbackQuery = callbackQuery;
|
|
54
|
+
/** Any of the provided filters must match */
|
|
55
|
+
const anyOf = (...filters) => (update) => {
|
|
56
|
+
for (const filter of filters)
|
|
57
|
+
if (filter(update))
|
|
58
|
+
return true;
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
exports.anyOf = anyOf;
|
|
62
|
+
/** All of the provided filters must match */
|
|
63
|
+
const allOf = (...filters) => (update) => {
|
|
64
|
+
for (const filter of filters)
|
|
65
|
+
if (!filter(update))
|
|
66
|
+
return false;
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
exports.allOf = allOf;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mention = exports.link = exports.pre = exports.code = exports.quote = exports.underline = exports.strikethrough = exports.spoiler = exports.italic = exports.bold = exports.fmt = exports.join = exports.FmtString = void 0;
|
|
4
|
+
exports.richTextPlain = exports.richTextBold = exports.richTextItalic = exports.richTextUnderline = exports.richTextStrikethrough = exports.richTextSpoiler = exports.richTextCode = exports.richTextCustomEmoji = exports.richTextUrl = exports.richTextEmailAddress = exports.richTextDateTime = exports.richTextTextMention = exports.richTextSubscript = exports.richTextSuperscript = exports.richTextMarked = exports.richTextMathematicalExpression = void 0;
|
|
5
|
+
const formatting_1 = require("./core/helpers/formatting");
|
|
6
|
+
Object.defineProperty(exports, "FmtString", { enumerable: true, get: function () { return formatting_1.FmtString; } });
|
|
7
|
+
exports.join = formatting_1.join;
|
|
8
|
+
exports.fmt = (0, formatting_1.createFmt)();
|
|
9
|
+
exports.bold = (0, formatting_1.createFmt)('bold');
|
|
10
|
+
exports.italic = (0, formatting_1.createFmt)('italic');
|
|
11
|
+
exports.spoiler = (0, formatting_1.createFmt)('spoiler');
|
|
12
|
+
exports.strikethrough = (0, formatting_1.createFmt)('strikethrough');
|
|
13
|
+
exports.underline = (0, formatting_1.createFmt)('underline');
|
|
14
|
+
exports.quote = (0, formatting_1.createFmt)('blockquote');
|
|
15
|
+
exports.code = (0, formatting_1.createFmt)('code');
|
|
16
|
+
const pre = (language) => (0, formatting_1.createFmt)('pre', { language });
|
|
17
|
+
exports.pre = pre;
|
|
18
|
+
const link = (content, url) => (0, formatting_1.linkOrMention)(content, { type: 'text_link', url });
|
|
19
|
+
exports.link = link;
|
|
20
|
+
const mention = (name, user) => typeof user === 'number'
|
|
21
|
+
? (0, exports.link)(name, 'tg://user?id=' + user)
|
|
22
|
+
: (0, formatting_1.linkOrMention)(name, {
|
|
23
|
+
type: 'text_mention',
|
|
24
|
+
user,
|
|
25
|
+
});
|
|
26
|
+
exports.mention = mention;
|
|
27
|
+
const richTextPlain = (text) => ({ type: "plain", text });
|
|
28
|
+
exports.richTextPlain = richTextPlain;
|
|
29
|
+
const richTextBold = (text) => ({ type: "bold", text });
|
|
30
|
+
exports.richTextBold = richTextBold;
|
|
31
|
+
const richTextItalic = (text) => ({ type: "italic", text });
|
|
32
|
+
exports.richTextItalic = richTextItalic;
|
|
33
|
+
const richTextUnderline = (text) => ({ type: "underline", text });
|
|
34
|
+
exports.richTextUnderline = richTextUnderline;
|
|
35
|
+
const richTextStrikethrough = (text) => ({ type: "strikethrough", text });
|
|
36
|
+
exports.richTextStrikethrough = richTextStrikethrough;
|
|
37
|
+
const richTextSpoiler = (text) => ({ type: "spoiler", text });
|
|
38
|
+
exports.richTextSpoiler = richTextSpoiler;
|
|
39
|
+
const richTextCode = (text) => ({ type: "code", text });
|
|
40
|
+
exports.richTextCode = richTextCode;
|
|
41
|
+
const richTextCustomEmoji = (text, custom_emoji_id) => ({ type: "custom_emoji", text, custom_emoji_id });
|
|
42
|
+
exports.richTextCustomEmoji = richTextCustomEmoji;
|
|
43
|
+
const richTextUrl = (text, url) => ({ type: "url", text, url });
|
|
44
|
+
exports.richTextUrl = richTextUrl;
|
|
45
|
+
const richTextEmailAddress = (text, email_address) => ({ type: "email_address", text, email_address });
|
|
46
|
+
exports.richTextEmailAddress = richTextEmailAddress;
|
|
47
|
+
const richTextDateTime = (text, unix_time, date_time_format) => ({ type: "date_time", text, unix_time, date_time_format });
|
|
48
|
+
exports.richTextDateTime = richTextDateTime;
|
|
49
|
+
const richTextTextMention = (text, user) => ({ type: "text_mention", text, user });
|
|
50
|
+
exports.richTextTextMention = richTextTextMention;
|
|
51
|
+
const richTextSubscript = (text) => ({ type: "subscript", text });
|
|
52
|
+
exports.richTextSubscript = richTextSubscript;
|
|
53
|
+
const richTextSuperscript = (text) => ({ type: "superscript", text });
|
|
54
|
+
exports.richTextSuperscript = richTextSuperscript;
|
|
55
|
+
const richTextMarked = (text) => ({ type: "marked", text });
|
|
56
|
+
exports.richTextMarked = richTextMarked;
|
|
57
|
+
const richTextMathematicalExpression = (text, mathematical_expression) => ({ type: "mathematical_expression", text, mathematical_expression });
|
|
58
|
+
exports.richTextMathematicalExpression = richTextMathematicalExpression;
|