@effect-ak/tg-bot-client 0.4.1 → 0.5.0
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/dist/index.d.ts +57 -50
- package/dist/index.js +317 -233
- package/dist/index.mjs +312 -227
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as effect_Cause from 'effect/Cause';
|
|
2
2
|
import * as effect_Types from 'effect/Types';
|
|
3
|
+
import * as Data from 'effect/Data';
|
|
3
4
|
import * as Micro from 'effect/Micro';
|
|
4
5
|
import * as Context from 'effect/Context';
|
|
5
6
|
|
|
@@ -38,6 +39,14 @@ declare class TgBotClientError extends TgBotClientError_base<{
|
|
|
38
39
|
static readonly missingSuccess: TgBotClientError;
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
declare const FetchUpdatesError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
|
|
43
|
+
readonly _tag: "FetchUpdatesError";
|
|
44
|
+
} & Readonly<A>;
|
|
45
|
+
declare class FetchUpdatesError extends FetchUpdatesError_base<{
|
|
46
|
+
name: "TooManyEmptyResponses" | "NoUpdatesToCommit";
|
|
47
|
+
}> {
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
interface AffiliateInfo {
|
|
42
51
|
commission_per_mille: number;
|
|
43
52
|
amount: number;
|
|
@@ -2752,7 +2761,6 @@ interface VerifyUserInput {
|
|
|
2752
2761
|
}
|
|
2753
2762
|
|
|
2754
2763
|
type AvailableUpdateTypes = Exclude<keyof Update, 'update_id'>;
|
|
2755
|
-
type LogLevel = "info" | "debug";
|
|
2756
2764
|
type BotResult = {
|
|
2757
2765
|
[K in keyof Api]: K extends `send_${infer R}` ? {
|
|
2758
2766
|
type: R;
|
|
@@ -2762,75 +2770,74 @@ declare const BotResponse_base: new <A extends Record<string, any> = {}>(args: e
|
|
|
2762
2770
|
readonly _tag: "BotResponse";
|
|
2763
2771
|
};
|
|
2764
2772
|
declare class BotResponse extends BotResponse_base<{
|
|
2765
|
-
|
|
2773
|
+
response?: BotResult;
|
|
2766
2774
|
}> {
|
|
2767
2775
|
static make(result: BotResult): BotResponse;
|
|
2768
2776
|
static readonly ignore: BotResponse;
|
|
2769
2777
|
}
|
|
2770
2778
|
type HandleUpdateFunction<U> = (update: U) => BotResponse | PromiseLike<BotResponse>;
|
|
2771
|
-
type
|
|
2779
|
+
type BotUpdatesHandlers = {
|
|
2772
2780
|
readonly [K in AvailableUpdateTypes as `on_${K}`]?: HandleUpdateFunction<NonNullable<Update[K]>>;
|
|
2773
2781
|
};
|
|
2774
|
-
|
|
2782
|
+
type HandleBatchUpdateFunction = {
|
|
2783
|
+
readonly on_batch: (update: Update[]) => boolean | PromiseLike<boolean>;
|
|
2784
|
+
};
|
|
2785
|
+
interface BotSingleMode extends BotUpdatesHandlers {
|
|
2786
|
+
type: "single";
|
|
2775
2787
|
}
|
|
2776
|
-
|
|
2777
|
-
type
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
max_empty_responses?: number;
|
|
2783
|
-
on_error?: "stop" | "continue";
|
|
2784
|
-
}> & BotMessageHandlers>;
|
|
2785
|
-
declare class BotMessageHandler extends BotMessageHandler_base {
|
|
2788
|
+
interface BotBatchMode extends HandleBatchUpdateFunction {
|
|
2789
|
+
type: "batch";
|
|
2790
|
+
}
|
|
2791
|
+
type BotMode = BotSingleMode | BotBatchMode;
|
|
2792
|
+
declare const BotUpdateHandlersTag_base: Context.TagClass<BotUpdateHandlersTag, "BotUpdateHandlers", BotMode>;
|
|
2793
|
+
declare class BotUpdateHandlersTag extends BotUpdateHandlersTag_base {
|
|
2786
2794
|
}
|
|
2787
2795
|
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2796
|
+
type PollSettings = {
|
|
2797
|
+
log_level: "info" | "debug";
|
|
2798
|
+
on_error: "stop" | "continue";
|
|
2799
|
+
batch_size: number;
|
|
2800
|
+
poll_timeout: number;
|
|
2801
|
+
max_empty_responses: number | undefined;
|
|
2802
|
+
};
|
|
2803
|
+
|
|
2804
|
+
declare class BatchUpdateResult extends Data.Class<{
|
|
2805
|
+
hasErrors: boolean;
|
|
2806
|
+
updates: Update[];
|
|
2795
2807
|
}> {
|
|
2796
2808
|
}
|
|
2797
2809
|
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
declare class BotFactoryService extends BotFactoryService_base {
|
|
2810
|
+
/**
|
|
2811
|
+
* This module provides utility functions for input configuration
|
|
2812
|
+
*/
|
|
2813
|
+
|
|
2814
|
+
interface RunBotInputBase {
|
|
2815
|
+
mode: BotMode;
|
|
2816
|
+
poll?: Partial<PollSettings>;
|
|
2806
2817
|
}
|
|
2807
|
-
|
|
2818
|
+
interface RunBotInputFromJsonFile extends RunBotInputBase {
|
|
2808
2819
|
type: "fromJsonFile";
|
|
2809
|
-
}
|
|
2820
|
+
}
|
|
2821
|
+
interface RunBotInputConfig extends RunBotInputBase, TgBotClientSettingsInput {
|
|
2810
2822
|
type: "config";
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
}
|
|
2823
|
+
}
|
|
2824
|
+
type RunBotInput = RunBotInputFromJsonFile | RunBotInputConfig;
|
|
2825
|
+
|
|
2826
|
+
declare const launchBot: (input: RunBotInput) => Micro.Micro<{
|
|
2827
|
+
readonly reload: (mode: BotMode) => Promise<void>;
|
|
2828
|
+
readonly fiber: () => Micro.MicroFiber<BatchUpdateResult, TgBotClientError | FetchUpdatesError> | undefined;
|
|
2829
|
+
}, string, never>;
|
|
2818
2830
|
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
readonly
|
|
2822
|
-
readonly getFiber: () => Micro.MicroFiber<unknown, TgBotClientError | HandleUpdateError> | undefined;
|
|
2831
|
+
declare const BotRunService_base: Context.ReferenceClass<BotRunService, "BotRunService", {
|
|
2832
|
+
readonly runBotInBackground: Micro.Micro<void, never, TgBotClientConfig | BotUpdateHandlersTag>;
|
|
2833
|
+
readonly getFiber: () => Micro.MicroFiber<BatchUpdateResult, TgBotClientError | FetchUpdatesError> | undefined;
|
|
2823
2834
|
}>;
|
|
2824
|
-
declare class
|
|
2835
|
+
declare class BotRunService extends BotRunService_base {
|
|
2825
2836
|
}
|
|
2826
|
-
declare const BotUpdatesPollerServiceDefault: Micro.Micro<{
|
|
2827
|
-
readonly runBot: Micro.Micro<void, never, BotMessageHandler | TgBotClientConfig>;
|
|
2828
|
-
readonly getFiber: () => Micro.MicroFiber<unknown, TgBotClientError | HandleUpdateError> | undefined;
|
|
2829
|
-
}, never, never>;
|
|
2830
2837
|
|
|
2831
2838
|
declare const runTgChatBot: (input: RunBotInput) => Promise<{
|
|
2832
|
-
readonly reload: (
|
|
2833
|
-
readonly fiber: () => Micro.MicroFiber<
|
|
2839
|
+
readonly reload: (mode: BotMode) => Promise<void>;
|
|
2840
|
+
readonly fiber: () => Micro.MicroFiber<BatchUpdateResult, TgBotClientError | FetchUpdatesError> | undefined;
|
|
2834
2841
|
}>;
|
|
2835
2842
|
|
|
2836
2843
|
declare const getFile: (fileId: string) => Micro.Micro<File, TgBotClientError, TgBotClientConfig>;
|
|
@@ -2863,4 +2870,4 @@ type MessageEffect = keyof typeof MESSAGE_EFFECTS;
|
|
|
2863
2870
|
declare const messageEffectIdCodes: MessageEffect[];
|
|
2864
2871
|
declare const isMessageEffect: (input: unknown) => input is MessageEffect;
|
|
2865
2872
|
|
|
2866
|
-
export { type AddStickerToSetInput, type AffiliateInfo, type Animation, type AnswerCallbackQueryInput, type AnswerInlineQueryInput, type AnswerPreCheckoutQueryInput, type AnswerShippingQueryInput, type AnswerWebAppQueryInput, type Api, type ApproveChatJoinRequestInput, type Audio, type AvailableUpdateTypes, type BackgroundFill, type BackgroundFillFreeformGradient, type BackgroundFillGradient, type BackgroundFillSolid, type BackgroundType, type BackgroundTypeChatTheme, type BackgroundTypeFill, type BackgroundTypePattern, type BackgroundTypeWallpaper, type BanChatMemberInput, type BanChatSenderChatInput, type Birthdate, type BotCommand, type BotCommandScope, type BotCommandScopeAllChatAdministrators, type BotCommandScopeAllGroupChats, type BotCommandScopeAllPrivateChats, type BotCommandScopeChat, type BotCommandScopeChatAdministrators, type BotCommandScopeChatMember, type BotCommandScopeDefault, type BotDescription,
|
|
2873
|
+
export { type AddStickerToSetInput, type AffiliateInfo, type Animation, type AnswerCallbackQueryInput, type AnswerInlineQueryInput, type AnswerPreCheckoutQueryInput, type AnswerShippingQueryInput, type AnswerWebAppQueryInput, type Api, type ApproveChatJoinRequestInput, type Audio, type AvailableUpdateTypes, type BackgroundFill, type BackgroundFillFreeformGradient, type BackgroundFillGradient, type BackgroundFillSolid, type BackgroundType, type BackgroundTypeChatTheme, type BackgroundTypeFill, type BackgroundTypePattern, type BackgroundTypeWallpaper, type BanChatMemberInput, type BanChatSenderChatInput, type Birthdate, type BotBatchMode, type BotCommand, type BotCommandScope, type BotCommandScopeAllChatAdministrators, type BotCommandScopeAllGroupChats, type BotCommandScopeAllPrivateChats, type BotCommandScopeChat, type BotCommandScopeChatAdministrators, type BotCommandScopeChatMember, type BotCommandScopeDefault, type BotDescription, type BotMode, type BotName, BotResponse, BotRunService, type BotShortDescription, type BotSingleMode, BotUpdateHandlersTag, type BotUpdatesHandlers, type BusinessConnection, type BusinessIntro, type BusinessLocation, type BusinessMessagesDeleted, type BusinessOpeningHours, type BusinessOpeningHoursInterval, type CallbackGame, type CallbackQuery, type Chat, type ChatAdministratorRights, type ChatBackground, type ChatBoost, type ChatBoostAdded, type ChatBoostRemoved, type ChatBoostSource, type ChatBoostSourceGiftCode, type ChatBoostSourceGiveaway, type ChatBoostSourcePremium, type ChatBoostUpdated, type ChatFullInfo, type ChatInviteLink, type ChatJoinRequest, type ChatLocation, type ChatMember, type ChatMemberAdministrator, type ChatMemberBanned, type ChatMemberLeft, type ChatMemberMember, type ChatMemberOwner, type ChatMemberRestricted, type ChatMemberUpdated, type ChatPermissions, type ChatPhoto, type ChatShared, type ChosenInlineResult, type CloseForumTopicInput, type CloseGeneralForumTopicInput, type CloseInput, type Contact, type CopyMessageInput, type CopyMessagesInput, type CopyTextButton, type CreateChatInviteLinkInput, type CreateChatSubscriptionInviteLinkInput, type CreateForumTopicInput, type CreateInvoiceLinkInput, type CreateNewStickerSetInput, type DeclineChatJoinRequestInput, type DeleteChatPhotoInput, type DeleteChatStickerSetInput, type DeleteForumTopicInput, type DeleteMessageInput, type DeleteMessagesInput, type DeleteMyCommandsInput, type DeleteStickerFromSetInput, type DeleteStickerSetInput, type DeleteWebhookInput, type Dice, type Document, type EditChatInviteLinkInput, type EditChatSubscriptionInviteLinkInput, type EditForumTopicInput, type EditGeneralForumTopicInput, type EditMessageCaptionInput, type EditMessageLiveLocationInput, type EditMessageMediaInput, type EditMessageReplyMarkupInput, type EditMessageTextInput, type EditUserStarSubscriptionInput, type EncryptedCredentials, type EncryptedPassportElement, type ExportChatInviteLinkInput, type ExternalReplyInfo, type File$1 as File, type ForceReply, type ForumTopic, type ForumTopicClosed, type ForumTopicCreated, type ForumTopicEdited, type ForumTopicReopened, type ForwardMessageInput, type ForwardMessagesInput, type Game, type GameHighScore, type GeneralForumTopicHidden, type GeneralForumTopicUnhidden, type GetAvailableGiftsInput, type GetBusinessConnectionInput, type GetChatAdministratorsInput, type GetChatInput, type GetChatMemberCountInput, type GetChatMemberInput, type GetChatMenuButtonInput, type GetCustomEmojiStickersInput, type GetFileInput, type GetForumTopicIconStickersInput, type GetGameHighScoresInput, type GetMeInput, type GetMyCommandsInput, type GetMyDefaultAdministratorRightsInput, type GetMyDescriptionInput, type GetMyNameInput, type GetMyShortDescriptionInput, type GetStarTransactionsInput, type GetStickerSetInput, type GetUpdatesInput, type GetUserChatBoostsInput, type GetUserProfilePhotosInput, type GetWebhookInfoInput, type Gift, type Gifts, type Giveaway, type GiveawayCompleted, type GiveawayCreated, type GiveawayWinners, type HandleBatchUpdateFunction, type HandleUpdateFunction, type HideGeneralForumTopicInput, type InaccessibleMessage, type InlineKeyboardButton, type InlineKeyboardMarkup, type InlineQuery, type InlineQueryResult, type InlineQueryResultArticle, type InlineQueryResultAudio, type InlineQueryResultCachedAudio, type InlineQueryResultCachedDocument, type InlineQueryResultCachedGif, type InlineQueryResultCachedMpeg4Gif, type InlineQueryResultCachedPhoto, type InlineQueryResultCachedSticker, type InlineQueryResultCachedVideo, type InlineQueryResultCachedVoice, type InlineQueryResultContact, type InlineQueryResultDocument, type InlineQueryResultGame, type InlineQueryResultGif, type InlineQueryResultLocation, type InlineQueryResultMpeg4Gif, type InlineQueryResultPhoto, type InlineQueryResultVenue, type InlineQueryResultVideo, type InlineQueryResultVoice, type InlineQueryResultsButton, type InputContactMessageContent, type InputFile, type InputInvoiceMessageContent, type InputLocationMessageContent, type InputMedia, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputMessageContent, type InputPaidMedia, type InputPaidMediaPhoto, type InputPaidMediaVideo, type InputPollOption, type InputSticker, type InputTextMessageContent, type InputVenueMessageContent, type Invoice, type KeyboardButton, type KeyboardButtonPollType, type KeyboardButtonRequestChat, type KeyboardButtonRequestUsers, type LabeledPrice, type LeaveChatInput, type LinkPreviewOptions, type Location, type LogOutInput, type LoginUrl, MESSAGE_EFFECTS, type MaskPosition, type MaybeInaccessibleMessage, type MenuButton, type MenuButtonCommands, type MenuButtonDefault, type MenuButtonWebApp, type Message, type MessageAutoDeleteTimerChanged, type MessageEffect, type MessageEntity, type MessageId, type MessageOrigin, type MessageOriginChannel, type MessageOriginChat, type MessageOriginHiddenUser, type MessageOriginUser, type MessageReactionCountUpdated, type MessageReactionUpdated, type OrderInfo, type PaidMedia, type PaidMediaInfo, type PaidMediaPhoto, type PaidMediaPreview, type PaidMediaPurchased, type PaidMediaVideo, type PassportData, type PassportElementError, type PassportElementErrorDataField, type PassportElementErrorFile, type PassportElementErrorFiles, type PassportElementErrorFrontSide, type PassportElementErrorReverseSide, type PassportElementErrorSelfie, type PassportElementErrorTranslationFile, type PassportElementErrorTranslationFiles, type PassportElementErrorUnspecified, type PassportFile, type PhotoSize, type PinChatMessageInput, type Poll, type PollAnswer, type PollOption, type PreCheckoutQuery, type PreparedInlineMessage, type PromoteChatMemberInput, type ProximityAlertTriggered, type ReactionCount, type ReactionType, type ReactionTypeCustomEmoji, type ReactionTypeEmoji, type ReactionTypePaid, type RefundStarPaymentInput, type RefundedPayment, type RemoveChatVerificationInput, type RemoveUserVerificationInput, type ReopenForumTopicInput, type ReopenGeneralForumTopicInput, type ReplaceStickerInSetInput, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyParameters, type ResponseParameters, type RestrictChatMemberInput, type RevenueWithdrawalState, type RevenueWithdrawalStateFailed, type RevenueWithdrawalStatePending, type RevenueWithdrawalStateSucceeded, type RevokeChatInviteLinkInput, type SavePreparedInlineMessageInput, type SendAnimationInput, type SendAudioInput, type SendChatActionInput, type SendContactInput, type SendDiceInput, type SendDocumentInput, type SendGameInput, type SendGiftInput, type SendInvoiceInput, type SendLocationInput, type SendMediaGroupInput, type SendMessageInput, type SendPaidMediaInput, type SendPhotoInput, type SendPollInput, type SendStickerInput, type SendVenueInput, type SendVideoInput, type SendVideoNoteInput, type SendVoiceInput, type SentWebAppMessage, type SetChatAdministratorCustomTitleInput, type SetChatDescriptionInput, type SetChatMenuButtonInput, type SetChatPermissionsInput, type SetChatPhotoInput, type SetChatStickerSetInput, type SetChatTitleInput, type SetCustomEmojiStickerSetThumbnailInput, type SetGameScoreInput, type SetMessageReactionInput, type SetMyCommandsInput, type SetMyDefaultAdministratorRightsInput, type SetMyDescriptionInput, type SetMyNameInput, type SetMyShortDescriptionInput, type SetPassportDataErrorsInput, type SetStickerEmojiListInput, type SetStickerKeywordsInput, type SetStickerMaskPositionInput, type SetStickerPositionInSetInput, type SetStickerSetThumbnailInput, type SetStickerSetTitleInput, type SetUserEmojiStatusInput, type SetWebhookInput, type SharedUser, type ShippingAddress, type ShippingOption, type ShippingQuery, type StarTransaction, type StarTransactions, type Sticker, type StickerSet, type StopMessageLiveLocationInput, type StopPollInput, type Story, type SuccessfulPayment, type SwitchInlineQueryChosenChat, type TextQuote, type TgBotClient, type TransactionPartner, type TransactionPartnerAffiliateProgram, type TransactionPartnerFragment, type TransactionPartnerOther, type TransactionPartnerTelegramAds, type TransactionPartnerTelegramApi, type TransactionPartnerUser, type UnbanChatMemberInput, type UnbanChatSenderChatInput, type UnhideGeneralForumTopicInput, type UnpinAllChatMessagesInput, type UnpinAllForumTopicMessagesInput, type UnpinAllGeneralForumTopicMessagesInput, type UnpinChatMessageInput, type Update, type UploadStickerFileInput, type User, type UserChatBoosts, type UserProfilePhotos, type UsersShared, type Venue, type VerifyChatInput, type VerifyUserInput, type Video, type VideoChatEnded, type VideoChatParticipantsInvited, type VideoChatScheduled, type VideoChatStarted, type VideoNote, type Voice, type WebAppData, type WebAppInfo, type WebhookInfo, type WriteAccessAllowed, defaultBaseUrl, isMessageEffect, launchBot, makeTgBotClient, messageEffectIdCodes, runTgChatBot };
|