@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,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNewReplies = useNewReplies;
|
|
4
|
+
function makeReply(ctx, extra) {
|
|
5
|
+
if (ctx.msgId)
|
|
6
|
+
return {
|
|
7
|
+
reply_parameters: {
|
|
8
|
+
message_id: ctx.msgId,
|
|
9
|
+
...extra === null || extra === void 0 ? void 0 : extra.reply_parameters,
|
|
10
|
+
},
|
|
11
|
+
...extra,
|
|
12
|
+
};
|
|
13
|
+
else
|
|
14
|
+
return extra;
|
|
15
|
+
}
|
|
16
|
+
const replyContext = {
|
|
17
|
+
replyWithChatAction: function () {
|
|
18
|
+
throw new TypeError('ctx.replyWithChatAction has been removed, use ctx.sendChatAction instead');
|
|
19
|
+
},
|
|
20
|
+
reply(text, extra) {
|
|
21
|
+
this.assert(this.chat, 'reply');
|
|
22
|
+
return this.telegram.sendMessage(this.chat.id, text, makeReply(this, extra));
|
|
23
|
+
},
|
|
24
|
+
replyWithAnimation(animation, extra) {
|
|
25
|
+
this.assert(this.chat, 'replyWithAnimation');
|
|
26
|
+
return this.telegram.sendAnimation(this.chat.id, animation, makeReply(this, extra));
|
|
27
|
+
},
|
|
28
|
+
replyWithAudio(audio, extra) {
|
|
29
|
+
this.assert(this.chat, 'replyWithAudio');
|
|
30
|
+
return this.telegram.sendAudio(this.chat.id, audio, makeReply(this, extra));
|
|
31
|
+
},
|
|
32
|
+
replyWithContact(phoneNumber, firstName, extra) {
|
|
33
|
+
this.assert(this.chat, 'replyWithContact');
|
|
34
|
+
return this.telegram.sendContact(this.chat.id, phoneNumber, firstName, makeReply(this, extra));
|
|
35
|
+
},
|
|
36
|
+
replyWithDice(extra) {
|
|
37
|
+
this.assert(this.chat, 'replyWithDice');
|
|
38
|
+
return this.telegram.sendDice(this.chat.id, makeReply(this, extra));
|
|
39
|
+
},
|
|
40
|
+
replyWithDocument(document, extra) {
|
|
41
|
+
this.assert(this.chat, 'replyWithDocument');
|
|
42
|
+
return this.telegram.sendDocument(this.chat.id, document, makeReply(this, extra));
|
|
43
|
+
},
|
|
44
|
+
replyWithGame(gameName, extra) {
|
|
45
|
+
this.assert(this.chat, 'replyWithGame');
|
|
46
|
+
return this.telegram.sendGame(this.chat.id, gameName, makeReply(this, extra));
|
|
47
|
+
},
|
|
48
|
+
replyWithHTML(html, extra) {
|
|
49
|
+
this.assert(this.chat, 'replyWithHTML');
|
|
50
|
+
return this.telegram.sendMessage(this.chat.id, html, {
|
|
51
|
+
parse_mode: 'HTML',
|
|
52
|
+
...makeReply(this, extra),
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
replyWithInvoice(invoice, extra) {
|
|
56
|
+
this.assert(this.chat, 'replyWithInvoice');
|
|
57
|
+
return this.telegram.sendInvoice(this.chat.id, invoice, makeReply(this, extra));
|
|
58
|
+
},
|
|
59
|
+
replyWithLocation(latitude, longitude, extra) {
|
|
60
|
+
this.assert(this.chat, 'replyWithLocation');
|
|
61
|
+
return this.telegram.sendLocation(this.chat.id, latitude, longitude, makeReply(this, extra));
|
|
62
|
+
},
|
|
63
|
+
replyWithMarkdown(markdown, extra) {
|
|
64
|
+
this.assert(this.chat, 'replyWithMarkdown');
|
|
65
|
+
return this.telegram.sendMessage(this.chat.id, markdown, {
|
|
66
|
+
parse_mode: 'Markdown',
|
|
67
|
+
...makeReply(this, extra),
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
replyWithMarkdownV2(markdown, extra) {
|
|
71
|
+
this.assert(this.chat, 'replyWithMarkdownV2');
|
|
72
|
+
return this.telegram.sendMessage(this.chat.id, markdown, {
|
|
73
|
+
parse_mode: 'MarkdownV2',
|
|
74
|
+
...makeReply(this, extra),
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
replyWithMediaGroup(media, extra) {
|
|
78
|
+
this.assert(this.chat, 'replyWithMediaGroup');
|
|
79
|
+
return this.telegram.sendMediaGroup(this.chat.id, media, makeReply(this, extra));
|
|
80
|
+
},
|
|
81
|
+
replyWithPhoto(photo, extra) {
|
|
82
|
+
this.assert(this.chat, 'replyWithPhoto');
|
|
83
|
+
return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra));
|
|
84
|
+
},
|
|
85
|
+
replyWithPoll(question, options, extra) {
|
|
86
|
+
this.assert(this.chat, 'replyWithPoll');
|
|
87
|
+
return this.telegram.sendPoll(this.chat.id, question, options, makeReply(this, extra));
|
|
88
|
+
},
|
|
89
|
+
replyWithQuiz(question, options, extra) {
|
|
90
|
+
this.assert(this.chat, 'replyWithQuiz');
|
|
91
|
+
return this.telegram.sendQuiz(this.chat.id, question, options, makeReply(this, extra));
|
|
92
|
+
},
|
|
93
|
+
replyWithSticker(sticker, extra) {
|
|
94
|
+
this.assert(this.chat, 'replyWithSticker');
|
|
95
|
+
return this.telegram.sendSticker(this.chat.id, sticker, makeReply(this, extra));
|
|
96
|
+
},
|
|
97
|
+
replyWithVenue(latitude, longitude, title, address, extra) {
|
|
98
|
+
this.assert(this.chat, 'replyWithVenue');
|
|
99
|
+
return this.telegram.sendVenue(this.chat.id, latitude, longitude, title, address, makeReply(this, extra));
|
|
100
|
+
},
|
|
101
|
+
replyWithVideo(video, extra) {
|
|
102
|
+
this.assert(this.chat, 'replyWithVideo');
|
|
103
|
+
return this.telegram.sendVideo(this.chat.id, video, makeReply(this, extra));
|
|
104
|
+
},
|
|
105
|
+
replyWithVideoNote(videoNote, extra) {
|
|
106
|
+
this.assert(this.chat, 'replyWithVideoNote');
|
|
107
|
+
return this.telegram.sendVideoNote(this.chat.id, videoNote, makeReply(this, extra));
|
|
108
|
+
},
|
|
109
|
+
replyWithVoice(voice, extra) {
|
|
110
|
+
this.assert(this.chat, 'replyWithVoice');
|
|
111
|
+
return this.telegram.sendVoice(this.chat.id, voice, makeReply(this, extra));
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
function useNewReplies() {
|
|
115
|
+
return (ctx, next) => {
|
|
116
|
+
ctx.reply = replyContext.reply;
|
|
117
|
+
ctx.replyWithPhoto = replyContext.replyWithPhoto;
|
|
118
|
+
ctx.replyWithMediaGroup = replyContext.replyWithMediaGroup;
|
|
119
|
+
ctx.replyWithAudio = replyContext.replyWithAudio;
|
|
120
|
+
ctx.replyWithDice = replyContext.replyWithDice;
|
|
121
|
+
ctx.replyWithDocument = replyContext.replyWithDocument;
|
|
122
|
+
ctx.replyWithSticker = replyContext.replyWithSticker;
|
|
123
|
+
ctx.replyWithVideo = replyContext.replyWithVideo;
|
|
124
|
+
ctx.replyWithAnimation = replyContext.replyWithAnimation;
|
|
125
|
+
ctx.replyWithVideoNote = replyContext.replyWithVideoNote;
|
|
126
|
+
ctx.replyWithInvoice = replyContext.replyWithInvoice;
|
|
127
|
+
ctx.replyWithGame = replyContext.replyWithGame;
|
|
128
|
+
ctx.replyWithVoice = replyContext.replyWithVoice;
|
|
129
|
+
ctx.replyWithPoll = replyContext.replyWithPoll;
|
|
130
|
+
ctx.replyWithQuiz = replyContext.replyWithQuiz;
|
|
131
|
+
ctx.replyWithChatAction = replyContext.replyWithChatAction;
|
|
132
|
+
ctx.replyWithLocation = replyContext.replyWithLocation;
|
|
133
|
+
ctx.replyWithVenue = replyContext.replyWithVenue;
|
|
134
|
+
ctx.replyWithContact = replyContext.replyWithContact;
|
|
135
|
+
ctx.replyWithMarkdown = replyContext.replyWithMarkdown;
|
|
136
|
+
ctx.replyWithMarkdownV2 = replyContext.replyWithMarkdownV2;
|
|
137
|
+
ctx.replyWithHTML = replyContext.replyWithHTML;
|
|
138
|
+
return next();
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.Scenes = exports.MemorySessionStore = exports.session = exports.deunionize = exports.Format = exports.Input = exports.Markup = exports.Types = exports.Telegram = exports.TelegramError = exports.Router = exports.Composer = exports.Context = exports.DeffaTelegraf = exports.TelegramButton = void 0;
|
|
45
|
+
var deffa_telegraf_1 = require("./deffa-telegraf.cjs");
|
|
46
|
+
Object.defineProperty(exports, "DeffaTelegraf", { enumerable: true, get: function () { return deffa_telegraf_1.DeffaTelegraf; } });
|
|
47
|
+
var context_1 = require("./context.cjs");
|
|
48
|
+
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_1.Context; } });
|
|
49
|
+
var composer_1 = require("./composer.cjs");
|
|
50
|
+
Object.defineProperty(exports, "Composer", { enumerable: true, get: function () { return composer_1.Composer; } });
|
|
51
|
+
var router_1 = require("./router.cjs");
|
|
52
|
+
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_1.Router; } });
|
|
53
|
+
var error_1 = require("./core/network/error.cjs");
|
|
54
|
+
Object.defineProperty(exports, "TelegramError", { enumerable: true, get: function () { return error_1.TelegramError; } });
|
|
55
|
+
var telegram_1 = require("./telegram.cjs");
|
|
56
|
+
Object.defineProperty(exports, "Telegram", { enumerable: true, get: function () { return telegram_1.Telegram; } });
|
|
57
|
+
exports.Types = __importStar(require("./telegram-types.cjs"));
|
|
58
|
+
exports.Markup = __importStar(require("./markup.cjs"));
|
|
59
|
+
exports.Input = __importStar(require("./input.cjs"));
|
|
60
|
+
exports.Format = __importStar(require("./format.cjs"));
|
|
61
|
+
var deunionize_1 = require("./core/helpers/deunionize.cjs");
|
|
62
|
+
Object.defineProperty(exports, "deunionize", { enumerable: true, get: function () { return deunionize_1.deunionize; } });
|
|
63
|
+
var session_1 = require("./session.cjs");
|
|
64
|
+
Object.defineProperty(exports, "session", { enumerable: true, get: function () { return session_1.session; } });
|
|
65
|
+
Object.defineProperty(exports, "MemorySessionStore", { enumerable: true, get: function () { return session_1.MemorySessionStore; } });
|
|
66
|
+
exports.Scenes = __importStar(require("./scenes.cjs"));
|
|
67
|
+
exports.TelegramButton = __importStar(require("./button.cjs"));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromFileId = exports.fromURL = exports.fromURLStream = exports.fromReadableStream = exports.fromBuffer = exports.fromLocalFile = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The local file specified by path will be uploaded to Telegram using multipart/form-data.
|
|
6
|
+
*
|
|
7
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
8
|
+
*/
|
|
9
|
+
// prettier-ignore
|
|
10
|
+
const fromLocalFile = (path, filename) => ({ source: path, filename });
|
|
11
|
+
exports.fromLocalFile = fromLocalFile;
|
|
12
|
+
/**
|
|
13
|
+
* The buffer will be uploaded as file to Telegram using multipart/form-data.
|
|
14
|
+
*
|
|
15
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
16
|
+
*/
|
|
17
|
+
// prettier-ignore
|
|
18
|
+
const fromBuffer = (buffer, filename) => ({ source: buffer, filename });
|
|
19
|
+
exports.fromBuffer = fromBuffer;
|
|
20
|
+
/**
|
|
21
|
+
* Contents of the stream will be uploaded as file to Telegram using multipart/form-data.
|
|
22
|
+
*
|
|
23
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
24
|
+
*/
|
|
25
|
+
// prettier-ignore
|
|
26
|
+
const fromReadableStream = (stream, filename) => ({ source: stream, filename });
|
|
27
|
+
exports.fromReadableStream = fromReadableStream;
|
|
28
|
+
/**
|
|
29
|
+
* Contents of the URL will be streamed to Telegram.
|
|
30
|
+
*
|
|
31
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
32
|
+
*/
|
|
33
|
+
// prettier-ignore
|
|
34
|
+
const fromURLStream = (url, filename) => ({ url: url.toString(), filename });
|
|
35
|
+
exports.fromURLStream = fromURLStream;
|
|
36
|
+
/**
|
|
37
|
+
* Provide Telegram with an HTTP URL for the file to be sent.
|
|
38
|
+
* Telegram will download and send the file.
|
|
39
|
+
*
|
|
40
|
+
* * The target file must have the correct MIME type (e.g., audio/mpeg for `sendAudio`, etc.).
|
|
41
|
+
* * `sendDocument` with URL will currently only work for GIF, PDF and ZIP files.
|
|
42
|
+
* * To use `sendVoice`, the file must have the type audio/ogg and be no more than 1MB in size.
|
|
43
|
+
* 1-20MB voice notes will be sent as files.
|
|
44
|
+
*
|
|
45
|
+
* 5 MB max size for photos and 20 MB max for other types of content.
|
|
46
|
+
*/
|
|
47
|
+
const fromURL = (url) => url.toString();
|
|
48
|
+
exports.fromURL = fromURL;
|
|
49
|
+
/**
|
|
50
|
+
* If the file is already stored somewhere on the Telegram servers, you don't need to reupload it:
|
|
51
|
+
* each file object has a file_id field, simply pass this file_id as a parameter instead of uploading.
|
|
52
|
+
*
|
|
53
|
+
* It is not possible to change the file type when resending by file_id.
|
|
54
|
+
*
|
|
55
|
+
* It is not possible to resend thumbnails using file_id.
|
|
56
|
+
* They have to be uploaded using one of the other Input methods.
|
|
57
|
+
*
|
|
58
|
+
* There are no limits for files sent this way.
|
|
59
|
+
*/
|
|
60
|
+
const fromFileId = (fileId) => fileId;
|
|
61
|
+
exports.fromFileId = fromFileId;
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.button = exports.Markup = void 0;
|
|
45
|
+
exports.removeKeyboard = removeKeyboard;
|
|
46
|
+
exports.forceReply = forceReply;
|
|
47
|
+
exports.keyboard = keyboard;
|
|
48
|
+
exports.inlineKeyboard = inlineKeyboard;
|
|
49
|
+
const check_1 = require("./core/helpers/check.cjs");
|
|
50
|
+
class Markup {
|
|
51
|
+
constructor(reply_markup) {
|
|
52
|
+
this.reply_markup = reply_markup;
|
|
53
|
+
}
|
|
54
|
+
selective(value = true) {
|
|
55
|
+
return new Markup({ ...this.reply_markup, selective: value });
|
|
56
|
+
}
|
|
57
|
+
placeholder(placeholder) {
|
|
58
|
+
return new Markup({
|
|
59
|
+
...this.reply_markup,
|
|
60
|
+
input_field_placeholder: placeholder,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
resize(value = true) {
|
|
64
|
+
return new Markup({
|
|
65
|
+
...this.reply_markup,
|
|
66
|
+
resize_keyboard: value,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
oneTime(value = true) {
|
|
70
|
+
return new Markup({
|
|
71
|
+
...this.reply_markup,
|
|
72
|
+
one_time_keyboard: value,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
persistent(value = true) {
|
|
76
|
+
return new Markup({
|
|
77
|
+
...this.reply_markup,
|
|
78
|
+
is_persistent: value,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.Markup = Markup;
|
|
83
|
+
exports.button = __importStar(require("./button.cjs"));
|
|
84
|
+
function removeKeyboard() {
|
|
85
|
+
return new Markup({ remove_keyboard: true });
|
|
86
|
+
}
|
|
87
|
+
function forceReply() {
|
|
88
|
+
return new Markup({ force_reply: true });
|
|
89
|
+
}
|
|
90
|
+
function keyboard(buttons, options) {
|
|
91
|
+
const keyboard = buildKeyboard(buttons, {
|
|
92
|
+
columns: 1,
|
|
93
|
+
...options,
|
|
94
|
+
});
|
|
95
|
+
return new Markup({ keyboard });
|
|
96
|
+
}
|
|
97
|
+
function inlineKeyboard(buttons, options) {
|
|
98
|
+
const inlineKeyboard = buildKeyboard(buttons, {
|
|
99
|
+
columns: buttons.length,
|
|
100
|
+
...options,
|
|
101
|
+
});
|
|
102
|
+
return new Markup({ inline_keyboard: inlineKeyboard });
|
|
103
|
+
}
|
|
104
|
+
function buildKeyboard(buttons, options) {
|
|
105
|
+
const result = [];
|
|
106
|
+
if (!Array.isArray(buttons)) {
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
if ((0, check_1.is2D)(buttons)) {
|
|
110
|
+
return buttons.map((row) => row.filter((button) => !button.hide));
|
|
111
|
+
}
|
|
112
|
+
const wrapFn = options.wrap !== undefined
|
|
113
|
+
? options.wrap
|
|
114
|
+
: (_btn, _index, currentRow) => currentRow.length >= options.columns;
|
|
115
|
+
let currentRow = [];
|
|
116
|
+
let index = 0;
|
|
117
|
+
for (const btn of buttons.filter((button) => !button.hide)) {
|
|
118
|
+
if (wrapFn(btn, index, currentRow) && currentRow.length > 0) {
|
|
119
|
+
result.push(currentRow);
|
|
120
|
+
currentRow = [];
|
|
121
|
+
}
|
|
122
|
+
currentRow.push(btn);
|
|
123
|
+
index++;
|
|
124
|
+
}
|
|
125
|
+
if (currentRow.length > 0) {
|
|
126
|
+
result.push(currentRow);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageReactions = exports.ReactionList = exports.Digit = void 0;
|
|
4
|
+
const util_1 = require("./core/helpers/util.cjs");
|
|
5
|
+
exports.Digit = new Set(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']);
|
|
6
|
+
const inspectReaction = (reaction) => {
|
|
7
|
+
if (reaction.type === 'custom_emoji')
|
|
8
|
+
return `Custom(${reaction.custom_emoji_id})`;
|
|
9
|
+
else
|
|
10
|
+
return reaction.emoji;
|
|
11
|
+
};
|
|
12
|
+
class ReactionList {
|
|
13
|
+
constructor(list) {
|
|
14
|
+
this.list = list;
|
|
15
|
+
}
|
|
16
|
+
static fromArray(list = []) {
|
|
17
|
+
return (0, util_1.indexed)(new ReactionList(list), function (index) {
|
|
18
|
+
return this.list[index];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
static has(reactions, reaction) {
|
|
22
|
+
if (typeof reaction === 'string')
|
|
23
|
+
if (exports.Digit.has(reaction[0]))
|
|
24
|
+
return reactions.some((r) => r.custom_emoji_id === reaction);
|
|
25
|
+
else
|
|
26
|
+
return reactions.some((r) => r.emoji === reaction);
|
|
27
|
+
return reactions.some((r) => {
|
|
28
|
+
if (r.type === 'custom_emoji')
|
|
29
|
+
return r.custom_emoji_id === reaction.custom_emoji_id;
|
|
30
|
+
else if (r.type === 'emoji')
|
|
31
|
+
return r.emoji === reaction.emoji;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
toArray() {
|
|
35
|
+
return [...this.list];
|
|
36
|
+
}
|
|
37
|
+
filter(filterFn) {
|
|
38
|
+
return ReactionList.fromArray(this.list.filter(filterFn));
|
|
39
|
+
}
|
|
40
|
+
has(reaction) {
|
|
41
|
+
return ReactionList.has(this.list, reaction);
|
|
42
|
+
}
|
|
43
|
+
get count() {
|
|
44
|
+
return this.list.length;
|
|
45
|
+
}
|
|
46
|
+
[Symbol.iterator]() {
|
|
47
|
+
return this.list[Symbol.iterator]();
|
|
48
|
+
}
|
|
49
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
50
|
+
const flattened = this.list.map(inspectReaction).join(', ');
|
|
51
|
+
return ['ReactionList {', flattened, '}'].join(' ');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.ReactionList = ReactionList;
|
|
55
|
+
class MessageReactions extends ReactionList {
|
|
56
|
+
constructor(ctx) {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
super((_b = (_a = ctx.update.message_reaction) === null || _a === void 0 ? void 0 : _a.new_reaction) !== null && _b !== void 0 ? _b : []);
|
|
59
|
+
this.ctx = ctx;
|
|
60
|
+
}
|
|
61
|
+
static from(ctx) {
|
|
62
|
+
return (0, util_1.indexed)(new MessageReactions(ctx), function (index) {
|
|
63
|
+
return this.list[index];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
get old() {
|
|
67
|
+
var _a;
|
|
68
|
+
return ReactionList.fromArray((_a = this.ctx.update.message_reaction) === null || _a === void 0 ? void 0 : _a.old_reaction);
|
|
69
|
+
}
|
|
70
|
+
get new() {
|
|
71
|
+
var _a;
|
|
72
|
+
return ReactionList.fromArray((_a = this.ctx.update.message_reaction) === null || _a === void 0 ? void 0 : _a.new_reaction);
|
|
73
|
+
}
|
|
74
|
+
get added() {
|
|
75
|
+
return this.new.filter((reaction) => !this.old.has(reaction));
|
|
76
|
+
}
|
|
77
|
+
get removed() {
|
|
78
|
+
return this.old.filter((reaction) => !this.new.has(reaction));
|
|
79
|
+
}
|
|
80
|
+
get kept() {
|
|
81
|
+
return this.new.filter((reaction) => this.old.has(reaction));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.MessageReactions = MessageReactions;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @format */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Router = void 0;
|
|
8
|
+
const composer_1 = __importDefault(require("./composer.cjs"));
|
|
9
|
+
/** @deprecated in favor of {@link Composer.dispatch} */
|
|
10
|
+
class Router {
|
|
11
|
+
constructor(routeFn, handlers = new Map()) {
|
|
12
|
+
this.routeFn = routeFn;
|
|
13
|
+
this.handlers = handlers;
|
|
14
|
+
this.otherwiseHandler = composer_1.default.passThru();
|
|
15
|
+
if (typeof routeFn !== 'function') {
|
|
16
|
+
throw new Error('Missing routing function');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
on(route, ...fns) {
|
|
20
|
+
if (fns.length === 0) {
|
|
21
|
+
throw new TypeError('At least one handler must be provided');
|
|
22
|
+
}
|
|
23
|
+
this.handlers.set(route, composer_1.default.compose(fns));
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
otherwise(...fns) {
|
|
27
|
+
if (fns.length === 0) {
|
|
28
|
+
throw new TypeError('At least one otherwise handler must be provided');
|
|
29
|
+
}
|
|
30
|
+
this.otherwiseHandler = composer_1.default.compose(fns);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
middleware() {
|
|
34
|
+
return composer_1.default.lazy((ctx) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const result = this.routeFn(ctx);
|
|
37
|
+
if (result == null) {
|
|
38
|
+
return this.otherwiseHandler;
|
|
39
|
+
}
|
|
40
|
+
Object.assign(ctx, result.context);
|
|
41
|
+
Object.assign(ctx.state, result.state);
|
|
42
|
+
return (_a = this.handlers.get(result.route)) !== null && _a !== void 0 ? _a : this.otherwiseHandler;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Router = Router;
|
|
@@ -0,0 +1,39 @@
|
|
|
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.BaseScene = void 0;
|
|
7
|
+
const composer_1 = __importDefault(require("../composer.cjs"));
|
|
8
|
+
const { compose } = composer_1.default;
|
|
9
|
+
class BaseScene extends composer_1.default {
|
|
10
|
+
constructor(id, options) {
|
|
11
|
+
const opts = {
|
|
12
|
+
handlers: [],
|
|
13
|
+
enterHandlers: [],
|
|
14
|
+
leaveHandlers: [],
|
|
15
|
+
...options,
|
|
16
|
+
};
|
|
17
|
+
super(...opts.handlers);
|
|
18
|
+
this.id = id;
|
|
19
|
+
this.ttl = opts.ttl;
|
|
20
|
+
this.enterHandler = compose(opts.enterHandlers);
|
|
21
|
+
this.leaveHandler = compose(opts.leaveHandlers);
|
|
22
|
+
}
|
|
23
|
+
enter(...fns) {
|
|
24
|
+
this.enterHandler = compose([this.enterHandler, ...fns]);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
leave(...fns) {
|
|
28
|
+
this.leaveHandler = compose([this.leaveHandler, ...fns]);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
enterMiddleware() {
|
|
32
|
+
return this.enterHandler;
|
|
33
|
+
}
|
|
34
|
+
leaveMiddleware() {
|
|
35
|
+
return this.leaveHandler;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.BaseScene = BaseScene;
|
|
39
|
+
exports.default = BaseScene;
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
const composer_1 = __importDefault(require("../composer.cjs"));
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
|
+
const debug = (0, debug_1.default)('telegraf:scenes:context');
|
|
9
|
+
const noop = () => Promise.resolve();
|
|
10
|
+
const now = () => Math.floor(Date.now() / 1000);
|
|
11
|
+
class SceneContextScene {
|
|
12
|
+
constructor(ctx, scenes, options) {
|
|
13
|
+
this.ctx = ctx;
|
|
14
|
+
this.scenes = scenes;
|
|
15
|
+
this.leaving = false;
|
|
16
|
+
// @ts-expect-error {} might not be assignable to D
|
|
17
|
+
const fallbackSessionDefault = {};
|
|
18
|
+
this.options = { defaultSession: fallbackSessionDefault, ...options };
|
|
19
|
+
}
|
|
20
|
+
get session() {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const defaultSession = Object.assign({}, this.options.defaultSession);
|
|
23
|
+
let session = (_b = (_a = this.ctx.session) === null || _a === void 0 ? void 0 : _a.__scenes) !== null && _b !== void 0 ? _b : defaultSession;
|
|
24
|
+
if (session.expires !== undefined && session.expires < now()) {
|
|
25
|
+
session = defaultSession;
|
|
26
|
+
}
|
|
27
|
+
if (this.ctx.session === undefined) {
|
|
28
|
+
this.ctx.session = { __scenes: session };
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.ctx.session.__scenes = session;
|
|
32
|
+
}
|
|
33
|
+
return session;
|
|
34
|
+
}
|
|
35
|
+
get state() {
|
|
36
|
+
var _a;
|
|
37
|
+
var _b;
|
|
38
|
+
return ((_a = (_b = this.session).state) !== null && _a !== void 0 ? _a : (_b.state = {}));
|
|
39
|
+
}
|
|
40
|
+
set state(value) {
|
|
41
|
+
this.session.state = { ...value };
|
|
42
|
+
}
|
|
43
|
+
get current() {
|
|
44
|
+
var _a;
|
|
45
|
+
const sceneId = (_a = this.session.current) !== null && _a !== void 0 ? _a : this.options.default;
|
|
46
|
+
return sceneId === undefined || !this.scenes.has(sceneId)
|
|
47
|
+
? undefined
|
|
48
|
+
: this.scenes.get(sceneId);
|
|
49
|
+
}
|
|
50
|
+
reset() {
|
|
51
|
+
if (this.ctx.session !== undefined)
|
|
52
|
+
this.ctx.session.__scenes = Object.assign({}, this.options.defaultSession);
|
|
53
|
+
}
|
|
54
|
+
async enter(sceneId, initialState = {}, silent = false) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (!this.scenes.has(sceneId)) {
|
|
57
|
+
throw new Error(`Can't find scene: ${sceneId}`);
|
|
58
|
+
}
|
|
59
|
+
if (!silent) {
|
|
60
|
+
await this.leave();
|
|
61
|
+
}
|
|
62
|
+
debug('Entering scene', sceneId, initialState, silent);
|
|
63
|
+
this.session.current = sceneId;
|
|
64
|
+
this.state = initialState;
|
|
65
|
+
const ttl = (_b = (_a = this.current) === null || _a === void 0 ? void 0 : _a.ttl) !== null && _b !== void 0 ? _b : this.options.ttl;
|
|
66
|
+
if (ttl !== undefined) {
|
|
67
|
+
this.session.expires = now() + ttl;
|
|
68
|
+
}
|
|
69
|
+
if (this.current === undefined || silent) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const handler = 'enterMiddleware' in this.current &&
|
|
73
|
+
typeof this.current.enterMiddleware === 'function'
|
|
74
|
+
? this.current.enterMiddleware()
|
|
75
|
+
: this.current.middleware();
|
|
76
|
+
return await handler(this.ctx, noop);
|
|
77
|
+
}
|
|
78
|
+
reenter() {
|
|
79
|
+
return this.session.current === undefined
|
|
80
|
+
? undefined
|
|
81
|
+
: this.enter(this.session.current, this.state);
|
|
82
|
+
}
|
|
83
|
+
async leave() {
|
|
84
|
+
if (this.leaving)
|
|
85
|
+
return;
|
|
86
|
+
debug('Leaving scene');
|
|
87
|
+
try {
|
|
88
|
+
this.leaving = true;
|
|
89
|
+
if (this.current === undefined) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const handler = 'leaveMiddleware' in this.current &&
|
|
93
|
+
typeof this.current.leaveMiddleware === 'function'
|
|
94
|
+
? this.current.leaveMiddleware()
|
|
95
|
+
: composer_1.default.passThru();
|
|
96
|
+
await handler(this.ctx, noop);
|
|
97
|
+
return this.reset();
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
this.leaving = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.default = SceneContextScene;
|