diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb3f26a57..8f639ae97d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # TelegramBotAPI changelog +## 22.0.0 + +**THIS UPDATE CONTAINS BREAKING CHANGES** + +**IN THIS UPDATE HAS BEEN REWORKED EVENTS API IN WEBAPPS** + +**THIS UPDATE ADDING SUPPORT OF [BOT API 8.0](https://core.telegram.org/bots/api-changelog#november-17-2024) AND [BOT API 8.1](https://core.telegram.org/bots/api-changelog#december-4-2024)** + +* `Version`: + * `MicroUtils`: `0.23.1` -> `0.23.2` + * `Ktor`: `3.0.1` -> `3.0.2` + ## 21.0.1 * `Core`: @@ -20,9 +32,9 @@ due to its redundancy * `BehaviourBuilder`: * Add special `val data: BehaviourContextData` into all realizations of `BehaviourContext` * Add `CombinedSubcontextInitialAction` and functions -`buildSubcontextInitialAction`/`buildSubcontextInitialActionWithSubActions` + `buildSubcontextInitialAction`/`buildSubcontextInitialActionWithSubActions` * Add `subcontextInitialAction` for all the functions-builders of `BehaviourContext` and -`additionalSubcontextInitialAction` to all triggers + `additionalSubcontextInitialAction` to all triggers ## 20.0.1 diff --git a/README.md b/README.md index e4cfc7c1be..da1c8b76dc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-7.11-blue)](https://core.telegram.org/bots/api-changelog#october-31-2024) +# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-8.1-blue)](https://core.telegram.org/bots/api-changelog#december-4-2024) | Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) | |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| diff --git a/gradle.properties b/gradle.properties index 3e918646fa..b667fe95a8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=21.0.1 +library_version=22.0.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ef820c34f7..60fc0aa380 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,12 +8,12 @@ javax-activation = "1.1.1" korlibs = "5.4.0" uuid = "0.8.4" -ktor = "3.0.1" +ktor = "3.0.2" ksp = "2.1.0-1.0.29" kotlin-poet = "1.18.1" -microutils = "0.23.1" +microutils = "0.23.2" kslog = "1.3.6" versions = "0.51.0" @@ -57,6 +57,8 @@ microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" } microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" } microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" } +microutils-ksp-sealed = { module = "dev.inmo:micro_utils.ksp.sealed", version.ref = "microutils" } +microutils-ksp-sealed-generator = { module = "dev.inmo:micro_utils.ksp.sealed.generator", version.ref = "microutils" } kslog = { module = "dev.inmo:kslog", version.ref = "kslog" } diff --git a/tgbotapi.api/api/tgbotapi.api.api b/tgbotapi.api/api/tgbotapi.api.api index bf30a52565..411a87a9ed 100644 --- a/tgbotapi.api/api/tgbotapi.api.api +++ b/tgbotapi.api/api/tgbotapi.api.api @@ -898,6 +898,15 @@ public final class dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessage public static synthetic fun editMessageMedia-FrLM24I$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/media/TelegramFreeMedia;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } +public final class dev/inmo/tgbotapi/extensions/api/edit/payments/EditUserStarSubscriptionKt { + public static final fun cancelUserStarSubscription-0SkZb-I (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun cancelUserStarSubscription-AASCvMI (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun editUserStarSubscription-0x-hEcU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun editUserStarSubscription-TFuYNzM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun enableUserStarSubscription-0SkZb-I (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun enableUserStarSubscription-AASCvMI (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public final class dev/inmo/tgbotapi/extensions/api/edit/reply_markup/EditChatMessageReplyMarkupKt { public static final fun editMessageReplyMarkup-iJMbh4A (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Ljava/lang/String;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun editMessageReplyMarkup-iJMbh4A$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Ljava/lang/String;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; @@ -1076,6 +1085,28 @@ public final class dev/inmo/tgbotapi/extensions/api/get/GetUserProfilePhotosKt { public static synthetic fun getUserProfilePhotos-4iNBclM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/Integer;Ljava/lang/Integer;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } +public final class dev/inmo/tgbotapi/extensions/api/gifts/GetAvailableGiftsKt { + public static final fun getAvailableGifts (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftKt { + public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun sendGift-1FWvrZc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun sendGift-4iNBclM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun sendGift-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun sendGift-WnQQACc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun sendGift-xkmhVIQ (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun sendGift-ySMgKnk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/inmo/tgbotapi/extensions/api/inline/SavePreparedInlineMessageKt { + public static final fun savePreparedInlineMessage (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun savePreparedInlineMessage$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun savePreparedInlineMessage-W2FzMBY (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun savePreparedInlineMessage-W2FzMBY$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + public final class dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrorsKt { public static final fun setPassportDataErrors (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/passport/PassportData;Ldev/inmo/tgbotapi/utils/passport/Decryptor;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun setPassportDataErrors (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -2121,9 +2152,9 @@ public final class dev/inmo/tgbotapi/extensions/api/send/media/SendVoiceKt { public final class dev/inmo/tgbotapi/extensions/api/send/payments/CreateInvoiceLinkKt { public static final fun createInvoiceLink (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZLkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun createInvoiceLink (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun createInvoiceLink$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public static synthetic fun createInvoiceLink$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun createInvoiceLink-1vVIECE (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Lkotlin/time/Duration;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun createInvoiceLink-1vVIECE$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Lkotlin/time/Duration;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } public final class dev/inmo/tgbotapi/extensions/api/send/payments/RefundStarPaymentKt { @@ -2172,6 +2203,15 @@ public final class dev/inmo/tgbotapi/extensions/api/send/polls/SendRegularPollKt public static synthetic fun sendRegularPoll-smr50Sk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/util/List;Ljava/util/List;Ldev/inmo/tgbotapi/types/polls/ScheduledCloseInfo;ZZZLdev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZZLjava/lang/String;Ldev/inmo/tgbotapi/types/ReplyParameters;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } +public final class dev/inmo/tgbotapi/extensions/api/set/SetUserEmojiStatusKt { + public static final fun setUserEmojiStatus-8OHYyMQ (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;DLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun setUserEmojiStatus-OZgzbMQ (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;DLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun setUserEmojiStatus-SrqJ0BM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun setUserEmojiStatus-SrqJ0BM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun setUserEmojiStatus-bic5Y5o (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun setUserEmojiStatus-bic5Y5o$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + public final class dev/inmo/tgbotapi/extensions/api/stickers/AddStickerToSetKt { public static final fun addStickerToSet (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/CommonUser;Ldev/inmo/tgbotapi/types/stickers/StickerSet;Ldev/inmo/tgbotapi/requests/abstracts/InputFile;Ldev/inmo/tgbotapi/types/StickerFormat;Ljava/util/List;Ldev/inmo/tgbotapi/types/stickers/MaskPosition;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun addStickerToSet (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/CommonUser;Ldev/inmo/tgbotapi/types/stickers/StickerSet;Ldev/inmo/tgbotapi/requests/abstracts/InputFile;Ldev/inmo/tgbotapi/types/StickerFormat;Ljava/util/List;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/payments/EditUserStarSubscription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/payments/EditUserStarSubscription.kt new file mode 100644 index 0000000000..78fa515333 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/payments/EditUserStarSubscription.kt @@ -0,0 +1,65 @@ +package dev.inmo.tgbotapi.extensions.api.edit.payments + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.edit.payments.EditUserStarSubscription +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.payments.abstracts.TelegramPaymentChargeId + +public suspend fun TelegramBot.editUserStarSubscription( + userId: UserId, + telegramPaymentChargeId: TelegramPaymentChargeId, + isCanceled: Boolean +): Boolean = execute( + EditUserStarSubscription( + userId = userId, + telegramPaymentChargeId = telegramPaymentChargeId, + isCanceled = isCanceled + ) +) + +public suspend fun TelegramBot.editUserStarSubscription( + user: User, + telegramPaymentChargeId: TelegramPaymentChargeId, + isCanceled: Boolean +): Boolean = editUserStarSubscription( + userId = user.id, + telegramPaymentChargeId = telegramPaymentChargeId, + isCanceled = isCanceled +) + +public suspend fun TelegramBot.cancelUserStarSubscription( + userId: UserId, + telegramPaymentChargeId: TelegramPaymentChargeId, +): Boolean = editUserStarSubscription( + userId = userId, + telegramPaymentChargeId = telegramPaymentChargeId, + isCanceled = true +) + +public suspend fun TelegramBot.cancelUserStarSubscription( + user: User, + telegramPaymentChargeId: TelegramPaymentChargeId, +): Boolean = editUserStarSubscription( + user = user, + telegramPaymentChargeId = telegramPaymentChargeId, + isCanceled = true +) + +public suspend fun TelegramBot.enableUserStarSubscription( + userId: UserId, + telegramPaymentChargeId: TelegramPaymentChargeId, +): Boolean = editUserStarSubscription( + userId = userId, + telegramPaymentChargeId = telegramPaymentChargeId, + isCanceled = false +) + +public suspend fun TelegramBot.enableUserStarSubscription( + user: User, + telegramPaymentChargeId: TelegramPaymentChargeId, +): Boolean = editUserStarSubscription( + user = user, + telegramPaymentChargeId = telegramPaymentChargeId, + isCanceled = false +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/GetAvailableGifts.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/GetAvailableGifts.kt new file mode 100644 index 0000000000..722384f185 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/GetAvailableGifts.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.extensions.api.gifts + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.gifts.GetAvailableGifts +import dev.inmo.tgbotapi.types.gifts.Gifts + +public suspend fun TelegramBot.getAvailableGifts(): Gifts = execute(GetAvailableGifts) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt new file mode 100644 index 0000000000..5f044bcbe0 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/gifts/SendGift.kt @@ -0,0 +1,103 @@ +package dev.inmo.tgbotapi.extensions.api.gifts + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.gifts.SendGift +import dev.inmo.tgbotapi.types.GiftId +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.gifts.Gift +import dev.inmo.tgbotapi.types.message.ParseMode +import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList + +public suspend fun TelegramBot.sendGift( + userId: UserId, + giftId: GiftId, + text: String, + parseMode: ParseMode? +): Boolean = execute( + SendGift( + userId, + giftId, + text, + parseMode + ) +) + +public suspend fun TelegramBot.sendGift( + userId: UserId, + giftId: GiftId, + textSources: TextSourcesList, +): Boolean = execute( + SendGift( + userId, + giftId, + textSources + ) +) + +public suspend fun TelegramBot.sendGift( + user: User, + giftId: GiftId, + text: String, + parseMode: ParseMode? +): Boolean = sendGift( + user.id, + giftId, + text, + parseMode +) + +public suspend fun TelegramBot.sendGift( + user: User, + giftId: GiftId, + textSources: TextSourcesList, +): Boolean = sendGift( + user.id, + giftId, + textSources +) + +public suspend fun TelegramBot.sendGift( + user: UserId, + gift: Gift, + text: String, + parseMode: ParseMode? +): Boolean = sendGift( + user, + gift.id, + text, + parseMode +) + +public suspend fun TelegramBot.sendGift( + user: UserId, + gift: Gift, + textSources: TextSourcesList, +): Boolean = sendGift( + user, + gift.id, + textSources +) + + +public suspend fun TelegramBot.sendGift( + user: User, + gift: Gift, + text: String, + parseMode: ParseMode? +): Boolean = sendGift( + user.id, + gift.id, + text, + parseMode +) + +public suspend fun TelegramBot.sendGift( + user: User, + gift: Gift, + textSources: TextSourcesList, +): Boolean = sendGift( + user.id, + gift.id, + textSources +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/inline/SavePreparedInlineMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/inline/SavePreparedInlineMessage.kt new file mode 100644 index 0000000000..4358140cdc --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/inline/SavePreparedInlineMessage.kt @@ -0,0 +1,45 @@ +package dev.inmo.tgbotapi.extensions.api.inline + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.answers.InlineQueryAnswersResultsSerializer +import dev.inmo.tgbotapi.requests.inline.SavePreparedInlineMessage +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult +import dev.inmo.tgbotapi.types.InlineQueries.prepared.PreparedInlineMessage +import dev.inmo.tgbotapi.types.chat.User +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +public suspend fun TelegramBot.savePreparedInlineMessage( + userId: UserId, + result: InlineQueryResult, + allowSendToUsers: Boolean = false, + allowSendToBots: Boolean = false, + allowSendToGroups: Boolean = false, + allowSendToChannels: Boolean = false, +): PreparedInlineMessage = execute( + SavePreparedInlineMessage( + userId = userId, + result = result, + allowSendToUsers = allowSendToUsers, + allowSendToBots = allowSendToBots, + allowSendToGroups = allowSendToGroups, + allowSendToChannels = allowSendToChannels + ) +) + +public suspend fun TelegramBot.savePreparedInlineMessage( + user: User, + result: InlineQueryResult, + allowSendToUsers: Boolean = false, + allowSendToBots: Boolean = false, + allowSendToGroups: Boolean = false, + allowSendToChannels: Boolean = false, +): PreparedInlineMessage = savePreparedInlineMessage( + userId = user.id, + result = result, + allowSendToUsers = allowSendToUsers, + allowSendToBots = allowSendToBots, + allowSendToGroups = allowSendToGroups, + allowSendToChannels = allowSendToChannels +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/CreateInvoiceLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/CreateInvoiceLink.kt index 2430043d91..6aaa6b1fe0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/CreateInvoiceLink.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/CreateInvoiceLink.kt @@ -2,9 +2,11 @@ package dev.inmo.tgbotapi.extensions.api.send.payments import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink +import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.XTR +import korlibs.time.TimeSpan public suspend fun TelegramBot.createInvoiceLink( title: String, @@ -24,7 +26,25 @@ public suspend fun TelegramBot.createInvoiceLink( shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false ): String = execute( - CreateInvoiceLink(title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress) + CreateInvoiceLink( + title = title, + description = description, + payload = payload, + providerToken = providerToken, + currency = currency, + prices = prices, + subscriptionPeriod = null, + maxTipAmount = maxTipAmount, + suggestedTipAmounts = suggestedTipAmounts ?.sorted(), + providerData = providerData, + requireName = requireName, + requirePhoneNumber = requirePhoneNumber, + requireEmail = requireEmail, + requireShippingAddress = requireShippingAddress, + shouldSendPhoneNumberToProvider = shouldSendPhoneNumberToProvider, + shouldSendEmailToProvider = shouldSendEmailToProvider, + priceDependOnShipAddress = priceDependOnShipAddress + ) ) /** @@ -35,6 +55,8 @@ public suspend fun TelegramBot.createInvoiceLink( description: String, payload: String, prices: List, + businessConnectionId: BusinessConnectionId? = null, + subscriptionPeriod: TimeSpan? = null, maxTipAmount: Int? = null, suggestedTipAmounts: List? = null, providerData: String? = null, @@ -46,5 +68,24 @@ public suspend fun TelegramBot.createInvoiceLink( shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false ): String = execute( - CreateInvoiceLink(title, description, payload, null, Currency.XTR, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress) + CreateInvoiceLink( + title = title, + description = description, + payload = payload, + providerToken = null, + currency = Currency.XTR, + businessConnectionId = businessConnectionId, + prices = prices, + subscriptionPeriod = subscriptionPeriod, + maxTipAmount = maxTipAmount, + suggestedTipAmounts = suggestedTipAmounts ?.sorted(), + providerData = providerData, + requireName = requireName, + requirePhoneNumber = requirePhoneNumber, + requireEmail = requireEmail, + requireShippingAddress = requireShippingAddress, + shouldSendPhoneNumberToProvider = shouldSendPhoneNumberToProvider, + shouldSendEmailToProvider = shouldSendEmailToProvider, + priceDependOnShipAddress = priceDependOnShipAddress + ) ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/set/SetUserEmojiStatus.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/set/SetUserEmojiStatus.kt new file mode 100644 index 0000000000..bc507bdbed --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/set/SetUserEmojiStatus.kt @@ -0,0 +1,50 @@ +package dev.inmo.tgbotapi.extensions.api.set + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.set.SetUserEmojiStatus +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.User +import korlibs.time.DateTime + +public suspend fun TelegramBot.setUserEmojiStatus( + userId: UserId, + customEmojiId: CustomEmojiId, + expirationDate: TelegramDate? = null +): Boolean = execute( + SetUserEmojiStatus( + userId = userId, + customEmojiId = customEmojiId, + expirationDate = expirationDate + ) +) + +public suspend fun TelegramBot.setUserEmojiStatus( + user: User, + customEmojiId: CustomEmojiId, + expirationDate: TelegramDate? = null +): Boolean = setUserEmojiStatus( + user.id, + customEmojiId, + expirationDate +) + + +public suspend fun TelegramBot.setUserEmojiStatus( + userId: UserId, + customEmojiId: CustomEmojiId, + expirationDate: DateTime +): Boolean = setUserEmojiStatus( + userId, + customEmojiId, + expirationDate.toTelegramDate() +) + +public suspend fun TelegramBot.setUserEmojiStatus( + user: User, + customEmojiId: CustomEmojiId, + expirationDate: DateTime +): Boolean = setUserEmojiStatus( + user.id, + customEmojiId, + expirationDate +) diff --git a/tgbotapi.core/api/tgbotapi.core.api b/tgbotapi.core/api/tgbotapi.core.api index e03366dacb..681361e16a 100644 --- a/tgbotapi.core/api/tgbotapi.core.api +++ b/tgbotapi.core/api/tgbotapi.core.api @@ -196,6 +196,14 @@ public abstract interface class dev/inmo/tgbotapi/abstracts/types/ProtectContent public abstract fun getProtectContent ()Z } +public abstract interface class dev/inmo/tgbotapi/abstracts/types/SubscriptionInfo : dev/inmo/tgbotapi/abstracts/types/SubscriptionPeriodInfo { + public abstract fun getSubscriptionPrice-0hXNFcg ()Lkotlin/UInt; +} + +public abstract interface class dev/inmo/tgbotapi/abstracts/types/SubscriptionPeriodInfo { + public abstract fun getSubscriptionPeriod-FghU774 ()Lkotlin/time/Duration; +} + public abstract interface class dev/inmo/tgbotapi/abstracts/types/UntilDate { public abstract fun getUntilDate ()Ldev/inmo/tgbotapi/types/TelegramDate; } @@ -2551,7 +2559,7 @@ public final class dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInvite public static fun method (Ldev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink;)Ljava/lang/String; } -public abstract interface class dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink$Subscription : dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink { +public abstract interface class dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink$Subscription : dev/inmo/tgbotapi/abstracts/types/SubscriptionInfo, dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink { public abstract fun getSubscriptionPeriod-UwyO8pc ()J public abstract fun getSubscriptionPrice-pVg5ArA ()I public abstract fun method ()Ljava/lang/String; @@ -2690,7 +2698,9 @@ public final class dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatSubscr public fun getName ()Ljava/lang/String; public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public synthetic fun getSubscriptionPeriod-FghU774 ()Lkotlin/time/Duration; public fun getSubscriptionPeriod-UwyO8pc ()J + public synthetic fun getSubscriptionPrice-0hXNFcg ()Lkotlin/UInt; public fun getSubscriptionPrice-pVg5ArA ()I public fun hashCode ()I public fun method ()Ljava/lang/String; @@ -4032,6 +4042,40 @@ public final class dev/inmo/tgbotapi/requests/edit/media/EditInlineMessageMedia$ public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { + public static final field Companion Ldev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription$Companion; + public synthetic fun (JLjava/lang/String;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-tHkBKVM ()J + public final fun component2-voYifgM ()Ljava/lang/String; + public final fun component3 ()Z + public final fun copy-7eyeMX4 (JLjava/lang/String;Z)Ldev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription; + public static synthetic fun copy-7eyeMX4$default (Ldev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription;JLjava/lang/String;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription; + public fun equals (Ljava/lang/Object;)Z + public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; + public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public final fun getTelegramPaymentChargeId-voYifgM ()Ljava/lang/String; + public final fun getUserId-tHkBKVM ()J + public fun hashCode ()I + public final fun isCanceled ()Z + public fun method ()Ljava/lang/String; + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/requests/edit/reply_markup/EditChatMessageReplyMarkup : dev/inmo/tgbotapi/requests/edit/abstracts/EditChatMessage, dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage { public static final field Companion Ldev/inmo/tgbotapi/requests/edit/reply_markup/EditChatMessageReplyMarkup$Companion; public synthetic fun (Ldev/inmo/tgbotapi/types/ChatIdentifier;JLjava/lang/String;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -4617,6 +4661,98 @@ public final class dev/inmo/tgbotapi/requests/get/GetUserProfilePhotos$Companion public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/requests/gifts/GetAvailableGifts : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { + public static final field INSTANCE Ldev/inmo/tgbotapi/requests/gifts/GetAvailableGifts; + public fun equals (Ljava/lang/Object;)Z + public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; + public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public fun hashCode ()I + public fun method ()Ljava/lang/String; + public final fun serializer ()Lkotlinx/serialization/KSerializer; + public fun toString ()Ljava/lang/String; +} + +public final class dev/inmo/tgbotapi/requests/gifts/SendGift : dev/inmo/tgbotapi/abstracts/TextedOutput, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { + public static final field Companion Ldev/inmo/tgbotapi/requests/gifts/SendGift$Companion; + public synthetic fun (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLjava/lang/String;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-tHkBKVM ()J + public final fun component2-OyCYJok ()Ljava/lang/String; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Ldev/inmo/tgbotapi/types/message/ParseMode; + public final fun copy-LbrZz8c (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;)Ldev/inmo/tgbotapi/requests/gifts/SendGift; + public static synthetic fun copy-LbrZz8c$default (Ldev/inmo/tgbotapi/requests/gifts/SendGift;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/gifts/SendGift; + public fun equals (Ljava/lang/Object;)Z + public fun getEntities ()Ljava/util/List; + public final fun getGiftId-OyCYJok ()Ljava/lang/String; + public fun getParseMode ()Ldev/inmo/tgbotapi/types/message/ParseMode; + public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; + public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public fun getText ()Ljava/lang/String; + public fun getTextSources ()Ljava/util/List; + public final fun getUserId-tHkBKVM ()J + public fun hashCode ()I + public fun method ()Ljava/lang/String; + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/requests/gifts/SendGift$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/requests/gifts/SendGift$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/gifts/SendGift; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/gifts/SendGift;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/gifts/SendGift$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { + public static final field Companion Ldev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage$Companion; + public synthetic fun (JLdev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLdev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZLkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-tHkBKVM ()J + public final fun component2 ()Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult; + public final fun component3 ()Z + public final fun component4 ()Z + public final fun component5 ()Z + public final fun component6 ()Z + public final fun copy-hWD7qso (JLdev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZ)Ldev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage; + public static synthetic fun copy-hWD7qso$default (Ldev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage;JLdev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage; + public fun equals (Ljava/lang/Object;)Z + public final fun getAllowSendToBots ()Z + public final fun getAllowSendToChannels ()Z + public final fun getAllowSendToGroups ()Z + public final fun getAllowSendToUsers ()Z + public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; + public final fun getResult ()Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult; + public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public final fun getUserId-tHkBKVM ()J + public fun hashCode ()I + public fun method ()Ljava/lang/String; + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/requests/local/Close : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { public static final field INSTANCE Ldev/inmo/tgbotapi/requests/local/Close; public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; @@ -6492,31 +6628,35 @@ public final class dev/inmo/tgbotapi/requests/send/media/base/MultipartRequestIm public fun method ()Ljava/lang/String; } -public final class dev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink : dev/inmo/tgbotapi/abstracts/CommonSendInvoiceData, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { +public final class dev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink : dev/inmo/tgbotapi/abstracts/CommonSendInvoiceData, dev/inmo/tgbotapi/abstracts/types/SubscriptionPeriodInfo, dev/inmo/tgbotapi/abstracts/types/WithOptionalBusinessConnectionId, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { public static final field Companion Ldev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink$Companion; - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZ)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public static final field DEFAULT I + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/time/Duration;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/time/Duration;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZLkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZ)V public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; - public final fun component10 ()Z - public final fun component11 ()Z + public final fun component10 ()Ljava/util/List; + public final fun component11 ()Ljava/lang/String; public final fun component12 ()Z public final fun component13 ()Z public final fun component14 ()Z public final fun component15 ()Z public final fun component16 ()Z + public final fun component17 ()Z + public final fun component18 ()Z public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ljava/lang/String; public final fun component4 ()Ljava/lang/String; public final fun component5 ()Ljava/lang/String; - public final fun component6 ()Ljava/util/List; - public final fun component7 ()Ljava/lang/Integer; - public final fun component8 ()Ljava/util/List; - public final fun component9 ()Ljava/lang/String; - public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZ)Ldev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink; - public static synthetic fun copy$default (Ldev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink; + public final fun component6-nXr5wdE ()Ljava/lang/String; + public final fun component7 ()Ljava/util/List; + public final fun component8-FghU774 ()Lkotlin/time/Duration; + public final fun component9 ()Ljava/lang/Integer; + public final fun copy-_iI5a48 (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/time/Duration;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZ)Ldev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink; + public static synthetic fun copy-_iI5a48$default (Ldev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/time/Duration;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/String;ZZZZZZZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink; public fun equals (Ljava/lang/Object;)Z + public fun getBusinessConnectionId-nXr5wdE ()Ljava/lang/String; public fun getCurrency ()Ljava/lang/String; public fun getDescription ()Ljava/lang/String; public fun getMaxTipAmount ()Ljava/lang/Integer; @@ -6537,6 +6677,7 @@ public final class dev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink : public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; public fun getShouldSendEmailToProvider ()Z public fun getShouldSendPhoneNumberToProvider ()Z + public fun getSubscriptionPeriod-FghU774 ()Lkotlin/time/Duration; public fun getSuggestedTipAmounts ()Ljava/util/List; public fun getTitle ()Ljava/lang/String; public fun hashCode ()I @@ -6819,6 +6960,41 @@ public final class dev/inmo/tgbotapi/requests/send/polls/SendRegularPollKt { public static synthetic fun SendRegularPoll-ZyXwLsU$default (Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/util/List;Ldev/inmo/tgbotapi/types/polls/ScheduledCloseInfo;Ldev/inmo/tgbotapi/types/message/ParseMode;ZZZLdev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZZLjava/lang/String;Ldev/inmo/tgbotapi/types/ReplyParameters;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;ILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/send/polls/SendRegularPoll; } +public final class dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { + public static final field Companion Ldev/inmo/tgbotapi/requests/set/SetUserEmojiStatus$Companion; + public synthetic fun (JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-tHkBKVM ()J + public final fun component2-dDnjveI ()Ljava/lang/String; + public final fun component3 ()Ldev/inmo/tgbotapi/types/TelegramDate; + public final fun copy-ydfbW08 (JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;)Ldev/inmo/tgbotapi/requests/set/SetUserEmojiStatus; + public static synthetic fun copy-ydfbW08$default (Ldev/inmo/tgbotapi/requests/set/SetUserEmojiStatus;JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/set/SetUserEmojiStatus; + public fun equals (Ljava/lang/Object;)Z + public final fun getCustomEmojiId-dDnjveI ()Ljava/lang/String; + public final fun getExpirationDate ()Ldev/inmo/tgbotapi/types/TelegramDate; + public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; + public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public final fun getUserId-tHkBKVM ()J + public fun hashCode ()I + public fun method ()Ljava/lang/String; + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/requests/set/SetUserEmojiStatus$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/set/SetUserEmojiStatus; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/set/SetUserEmojiStatus;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/requests/stickers/AddStickerToSetData : dev/inmo/tgbotapi/requests/stickers/abstracts/StandardStickerSetAction { public static final field Companion Ldev/inmo/tgbotapi/requests/stickers/AddStickerToSetData$Companion; public final fun component1-tHkBKVM ()J @@ -8446,19 +8622,23 @@ public final class dev/inmo/tgbotapi/types/ChatInviteLinkSerializer : kotlinx/se public final class dev/inmo/tgbotapi/types/ChatInviteLinkUnlimited : dev/inmo/tgbotapi/types/SecondaryChatInviteLink { public static final field Companion Ldev/inmo/tgbotapi/types/ChatInviteLinkUnlimited$Companion; - public fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;)V - public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ldev/inmo/tgbotapi/types/chat/User; public final fun component3 ()Ljava/lang/String; public final fun component4 ()Z - public final fun copy (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;)Ldev/inmo/tgbotapi/types/ChatInviteLinkUnlimited; - public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/ChatInviteLinkUnlimited;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/ChatInviteLinkUnlimited; + public final fun component6-FghU774 ()Lkotlin/time/Duration; + public final fun component7-0hXNFcg ()Lkotlin/UInt; + public final fun copy-Z8am-TE (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;)Ldev/inmo/tgbotapi/types/ChatInviteLinkUnlimited; + public static synthetic fun copy-Z8am-TE$default (Ldev/inmo/tgbotapi/types/ChatInviteLinkUnlimited;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/ChatInviteLinkUnlimited; public fun equals (Ljava/lang/Object;)Z public fun getCreator ()Ldev/inmo/tgbotapi/types/chat/User; public fun getExpirationDateTime-Ivn3T5g ()Lkorlibs/time/DateTime; public fun getInviteLink ()Ljava/lang/String; public fun getName ()Ljava/lang/String; + public fun getSubscriptionPeriod-FghU774 ()Lkotlin/time/Duration; + public fun getSubscriptionPrice-0hXNFcg ()Lkotlin/UInt; public fun getUser ()Ldev/inmo/tgbotapi/types/chat/User; public fun hashCode ()I public fun isPrimary ()Z @@ -8483,21 +8663,25 @@ public final class dev/inmo/tgbotapi/types/ChatInviteLinkUnlimited$Companion { public final class dev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest : dev/inmo/tgbotapi/types/SecondaryChatInviteLink { public static final field Companion Ldev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest$Companion; - public fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;)V - public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ldev/inmo/tgbotapi/types/chat/User; public final fun component3 ()Ljava/lang/String; public final fun component4 ()I public final fun component5 ()Z - public final fun copy (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest; - public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest; + public final fun component7-FghU774 ()Lkotlin/time/Duration; + public final fun component8-0hXNFcg ()Lkotlin/UInt; + public final fun copy-EXBVRkk (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest; + public static synthetic fun copy-EXBVRkk$default (Ldev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest; public fun equals (Ljava/lang/Object;)Z public fun getCreator ()Ldev/inmo/tgbotapi/types/chat/User; public fun getExpirationDateTime-Ivn3T5g ()Lkorlibs/time/DateTime; public fun getInviteLink ()Ljava/lang/String; public final fun getLeftToReview ()I public fun getName ()Ljava/lang/String; + public fun getSubscriptionPeriod-FghU774 ()Lkotlin/time/Duration; + public fun getSubscriptionPrice-0hXNFcg ()Lkotlin/UInt; public fun getUser ()Ldev/inmo/tgbotapi/types/chat/User; public fun hashCode ()I public fun isPrimary ()Z @@ -8522,21 +8706,25 @@ public final class dev/inmo/tgbotapi/types/ChatInviteLinkWithJoinRequest$Compani public final class dev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers : dev/inmo/tgbotapi/types/SecondaryChatInviteLink { public static final field Companion Ldev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers$Companion; - public fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;)V - public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ldev/inmo/tgbotapi/types/chat/User; public final fun component3 ()Ljava/lang/String; public final fun component4 ()I public final fun component5 ()Z - public final fun copy (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers; - public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers; + public final fun component7-FghU774 ()Lkotlin/time/Duration; + public final fun component8-0hXNFcg ()Lkotlin/UInt; + public final fun copy-EXBVRkk (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers; + public static synthetic fun copy-EXBVRkk$default (Ldev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;IZLdev/inmo/tgbotapi/types/TelegramDate;Lkotlin/time/Duration;Lkotlin/UInt;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/ChatInviteLinkWithLimitedMembers; public fun equals (Ljava/lang/Object;)Z public fun getCreator ()Ldev/inmo/tgbotapi/types/chat/User; public fun getExpirationDateTime-Ivn3T5g ()Lkorlibs/time/DateTime; public fun getInviteLink ()Ljava/lang/String; public final fun getMembersLimit ()I public fun getName ()Ljava/lang/String; + public fun getSubscriptionPeriod-FghU774 ()Lkotlin/time/Duration; + public fun getSubscriptionPrice-0hXNFcg ()Lkotlin/UInt; public fun getUser ()Ldev/inmo/tgbotapi/types/chat/User; public fun hashCode ()I public fun isPrimary ()Z @@ -8630,6 +8818,9 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field addedToAttachmentMenuField Ljava/lang/String; public static final field additionalChatCountField Ljava/lang/String; public static final field addressField Ljava/lang/String; + public static final field affiliateChatField Ljava/lang/String; + public static final field affiliateField Ljava/lang/String; + public static final field affiliateUserField Ljava/lang/String; public static final field allowBotChatsField Ljava/lang/String; public static final field allowChannelChatsField Ljava/lang/String; public static final field allowGroupChatsField Ljava/lang/String; @@ -8722,6 +8913,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field closingMinuteField Ljava/lang/String; public static final field colorField Ljava/lang/String; public static final field colorsField Ljava/lang/String; + public static final field commissionPerMilleField Ljava/lang/String; public static final field containsMasksField Ljava/lang/String; public static final field copyTextField Ljava/lang/String; public static final field correctOptionIdField Ljava/lang/String; @@ -8796,6 +8988,9 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field gifHeightField Ljava/lang/String; public static final field gifUrlField Ljava/lang/String; public static final field gifWidthField Ljava/lang/String; + public static final field giftField Ljava/lang/String; + public static final field giftIdField Ljava/lang/String; + public static final field giftsField Ljava/lang/String; public static final field giveawayMessageField Ljava/lang/String; public static final field giveawayMessageIdField Ljava/lang/String; public static final field googlePlaceIdField Ljava/lang/String; @@ -8833,9 +9028,11 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field isBigField Ljava/lang/String; public static final field isBlurredField Ljava/lang/String; public static final field isBotField Ljava/lang/String; + public static final field isCanceledField Ljava/lang/String; public static final field isClosedField Ljava/lang/String; public static final field isDisabledField Ljava/lang/String; public static final field isEnabledField Ljava/lang/String; + public static final field isFirstRecurringField Ljava/lang/String; public static final field isForumField Ljava/lang/String; public static final field isInvertedField Ljava/lang/String; public static final field isManualField Ljava/lang/String; @@ -8845,6 +9042,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field isPersonalField Ljava/lang/String; public static final field isPremiumField Ljava/lang/String; public static final field isPrimaryField Ljava/lang/String; + public static final field isRecurringField Ljava/lang/String; public static final field isRevokedField Ljava/lang/String; public static final field isStarGiveawayField Ljava/lang/String; public static final field isUnclaimedField Ljava/lang/String; @@ -8891,6 +9089,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field mpeg4GifUrlField Ljava/lang/String; public static final field mpeg4GifWidthField Ljava/lang/String; public static final field nameField Ljava/lang/String; + public static final field nanostarAmountField Ljava/lang/String; public static final field needsRepaintingField Ljava/lang/String; public static final field newChatMemberField Ljava/lang/String; public static final field newReactionField Ljava/lang/String; @@ -8965,6 +9164,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field reactionsField Ljava/lang/String; public static final field receiverField Ljava/lang/String; public static final field regularPollType Ljava/lang/String; + public static final field remainingCountField Ljava/lang/String; public static final field removeCaptionField Ljava/lang/String; public static final field removeDateField Ljava/lang/String; public static final field rentalAgreementField Ljava/lang/String; @@ -9022,6 +9222,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field smallFileIdField Ljava/lang/String; public static final field smallFileUniqueIdField Ljava/lang/String; public static final field sourceField Ljava/lang/String; + public static final field sponsorUserField Ljava/lang/String; public static final field starCountField Ljava/lang/String; public static final field startDateField Ljava/lang/String; public static final field startParameterField Ljava/lang/String; @@ -9034,6 +9235,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field stickerSetNameFullField Ljava/lang/String; public static final field stickerTypeField Ljava/lang/String; public static final field stickersField Ljava/lang/String; + public static final field subscriptionExpirationDateField Ljava/lang/String; public static final field subscriptionPeriodField Ljava/lang/String; public static final field subscriptionPriceField Ljava/lang/String; public static final field suggestedTipAmountsField Ljava/lang/String; @@ -9311,6 +9513,36 @@ public final class dev/inmo/tgbotapi/types/FullChatIdentifierSerializer : kotlin public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } +public final class dev/inmo/tgbotapi/types/GiftId { + public static final field Companion Ldev/inmo/tgbotapi/types/GiftId$Companion; + public static final synthetic fun box-impl (Ljava/lang/String;)Ldev/inmo/tgbotapi/types/GiftId; + public static fun constructor-impl (Ljava/lang/String;)Ljava/lang/String; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z + public final fun getString ()Ljava/lang/String; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/lang/String;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/GiftId$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/GiftId$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun deserialize-lyRR9js (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/String; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public final fun serialize-igZVhu4 (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/String;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/GiftId$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public abstract interface class dev/inmo/tgbotapi/types/IdChatIdentifier : dev/inmo/tgbotapi/types/ChatIdentifier { public static final field Companion Ldev/inmo/tgbotapi/types/IdChatIdentifier$Companion; public abstract fun getBusinessConnectionId-nXr5wdE ()Ljava/lang/String; @@ -10917,6 +11149,35 @@ public final class dev/inmo/tgbotapi/types/InlineQueries/InputMessageContentSeri public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } +public final class dev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage { + public static final field Companion Ldev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage$Companion; + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-Bcl8nMw ()Ljava/lang/String; + public final fun component2 ()Ldev/inmo/tgbotapi/types/TelegramDate; + public final fun copy-EtYkLw0 (Ljava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;)Ldev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage; + public static synthetic fun copy-EtYkLw0$default (Ldev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage;Ljava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage; + public fun equals (Ljava/lang/Object;)Z + public final fun getExpirationDate ()Ldev/inmo/tgbotapi/types/TelegramDate; + public final fun getId-Bcl8nMw ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery : dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery { public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/CommonUser;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/ChatType;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1-5UnZwr4 ()Ljava/lang/String; @@ -11428,6 +11689,36 @@ public final class dev/inmo/tgbotapi/types/PreCheckoutQueryId$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/types/PreparedMessageId { + public static final field Companion Ldev/inmo/tgbotapi/types/PreparedMessageId$Companion; + public static final synthetic fun box-impl (Ljava/lang/String;)Ldev/inmo/tgbotapi/types/PreparedMessageId; + public static fun constructor-impl (Ljava/lang/String;)Ljava/lang/String; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z + public final fun getString ()Ljava/lang/String; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/lang/String;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/PreparedMessageId$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/PreparedMessageId$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun deserialize-V2spmfg (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/String; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public final fun serialize-TKwuVJ8 (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/String;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/PreparedMessageId$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/PrimaryInviteLink : dev/inmo/tgbotapi/types/ChatInviteLink { public static final field Companion Ldev/inmo/tgbotapi/types/PrimaryInviteLink$Companion; public fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;ZLdev/inmo/tgbotapi/types/TelegramDate;)V @@ -11810,7 +12101,7 @@ public final class dev/inmo/tgbotapi/types/RetryAfterError : dev/inmo/tgbotapi/t public fun toString ()Ljava/lang/String; } -public abstract interface class dev/inmo/tgbotapi/types/SecondaryChatInviteLink : dev/inmo/tgbotapi/types/ChatInviteLink { +public abstract interface class dev/inmo/tgbotapi/types/SecondaryChatInviteLink : dev/inmo/tgbotapi/abstracts/types/SubscriptionInfo, dev/inmo/tgbotapi/types/ChatInviteLink { public static final field Companion Ldev/inmo/tgbotapi/types/SecondaryChatInviteLink$Companion; public abstract fun isPrimary ()Z } @@ -18047,6 +18338,119 @@ public final class dev/inmo/tgbotapi/types/games/GameHighScore$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public abstract interface class dev/inmo/tgbotapi/types/gifts/Gift { + public static final field Companion Ldev/inmo/tgbotapi/types/gifts/Gift$Companion; + public abstract fun getId-OyCYJok ()Ljava/lang/String; + public abstract fun getRemainingCount ()Ljava/lang/Integer; + public abstract fun getStarCount ()I + public abstract fun getSticker ()Ldev/inmo/tgbotapi/types/files/Sticker; + public abstract fun getTotalCount ()Ljava/lang/Integer; +} + +public final class dev/inmo/tgbotapi/types/gifts/Gift$Companion : kotlinx/serialization/KSerializer { + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/gifts/Gift; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/gifts/Gift;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/gifts/Gift$Limited : dev/inmo/tgbotapi/types/gifts/Gift { + public static final field Companion Ldev/inmo/tgbotapi/types/gifts/Gift$Limited$Companion; + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/files/Sticker;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-OyCYJok ()Ljava/lang/String; + public final fun component2 ()Ldev/inmo/tgbotapi/types/files/Sticker; + public final fun component3 ()I + public final fun component4 ()I + public final fun component5 ()I + public final fun copy-dAh8QC0 (Ljava/lang/String;Ldev/inmo/tgbotapi/types/files/Sticker;III)Ldev/inmo/tgbotapi/types/gifts/Gift$Limited; + public static synthetic fun copy-dAh8QC0$default (Ldev/inmo/tgbotapi/types/gifts/Gift$Limited;Ljava/lang/String;Ldev/inmo/tgbotapi/types/files/Sticker;IIIILjava/lang/Object;)Ldev/inmo/tgbotapi/types/gifts/Gift$Limited; + public fun equals (Ljava/lang/Object;)Z + public fun getId-OyCYJok ()Ljava/lang/String; + public fun getRemainingCount ()Ljava/lang/Integer; + public fun getStarCount ()I + public fun getSticker ()Ldev/inmo/tgbotapi/types/files/Sticker; + public fun getTotalCount ()Ljava/lang/Integer; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/gifts/Gift$Limited$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/gifts/Gift$Limited$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/gifts/Gift$Limited; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/gifts/Gift$Limited;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/gifts/Gift$Limited$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/gifts/Gift$Unlimited : dev/inmo/tgbotapi/types/gifts/Gift { + public static final field Companion Ldev/inmo/tgbotapi/types/gifts/Gift$Unlimited$Companion; + public synthetic fun (Ljava/lang/String;Ldev/inmo/tgbotapi/types/files/Sticker;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-OyCYJok ()Ljava/lang/String; + public final fun component2 ()Ldev/inmo/tgbotapi/types/files/Sticker; + public final fun component3 ()I + public final fun copy-IqAKj4o (Ljava/lang/String;Ldev/inmo/tgbotapi/types/files/Sticker;I)Ldev/inmo/tgbotapi/types/gifts/Gift$Unlimited; + public static synthetic fun copy-IqAKj4o$default (Ldev/inmo/tgbotapi/types/gifts/Gift$Unlimited;Ljava/lang/String;Ldev/inmo/tgbotapi/types/files/Sticker;IILjava/lang/Object;)Ldev/inmo/tgbotapi/types/gifts/Gift$Unlimited; + public fun equals (Ljava/lang/Object;)Z + public fun getId-OyCYJok ()Ljava/lang/String; + public fun getRemainingCount ()Ljava/lang/Integer; + public fun getStarCount ()I + public fun getSticker ()Ldev/inmo/tgbotapi/types/files/Sticker; + public fun getTotalCount ()Ljava/lang/Integer; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/gifts/Gift$Unlimited$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/gifts/Gift$Unlimited$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/gifts/Gift$Unlimited; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/gifts/Gift$Unlimited;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/gifts/Gift$Unlimited$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/gifts/Gifts { + public static final field Companion Ldev/inmo/tgbotapi/types/gifts/Gifts$Companion; + public fun (Ljava/util/List;)V + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/inmo/tgbotapi/types/gifts/Gifts; + public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/gifts/Gifts;Ljava/util/List;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/gifts/Gifts; + public fun equals (Ljava/lang/Object;)Z + public final fun getGifts ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/gifts/Gifts$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/gifts/Gifts$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/gifts/Gifts; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/gifts/Gifts;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/gifts/Gifts$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/giveaway/Giveaway : dev/inmo/tgbotapi/types/ReplyInfo$External$ContentVariant, dev/inmo/tgbotapi/types/giveaway/GiveawayInfo$OptionallyPremium, dev/inmo/tgbotapi/types/giveaway/GiveawayInfo$OptionallyStars { public static final field Companion Ldev/inmo/tgbotapi/types/giveaway/Giveaway$Companion; public fun (Ljava/util/List;Ldev/inmo/tgbotapi/types/TelegramDate;IZZLjava/lang/String;Ljava/util/List;Ljava/lang/Integer;Ljava/lang/Integer;)V @@ -24321,6 +24725,43 @@ public final class dev/inmo/tgbotapi/types/passport/encrypted/abstracts/UnknownE public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/types/payments/AffiliateInfo : dev/inmo/tgbotapi/types/payments/abstracts/Amounted { + public static final field Companion Ldev/inmo/tgbotapi/types/payments/AffiliateInfo$Companion; + public fun (IJJLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewChat;)V + public synthetic fun (IJJLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewChat;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()I + public final fun component2 ()J + public final fun component3 ()J + public final fun component4 ()Ldev/inmo/tgbotapi/types/chat/User; + public final fun component5 ()Ldev/inmo/tgbotapi/types/chat/PreviewChat; + public final fun copy (IJJLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewChat;)Ldev/inmo/tgbotapi/types/payments/AffiliateInfo; + public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/payments/AffiliateInfo;IJJLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewChat;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/AffiliateInfo; + public fun equals (Ljava/lang/Object;)Z + public fun getAdaptedMajorityTotalAmount ()D + public final fun getAffiliateChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChat; + public final fun getAffiliateUser ()Ldev/inmo/tgbotapi/types/chat/User; + public fun getAmount ()J + public final fun getCommissionPerMille ()I + public final fun getNanostarAmount ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/payments/AffiliateInfo$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/payments/AffiliateInfo$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/payments/AffiliateInfo; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/payments/AffiliateInfo;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/payments/AffiliateInfo$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/payments/CurrenciedKt { public static final fun javaCurrency (Ldev/inmo/tgbotapi/types/payments/abstracts/Currencied;)Ljava/util/Currency; } @@ -24475,6 +24916,35 @@ public final class dev/inmo/tgbotapi/types/payments/PreCheckoutQuery$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/types/payments/RecurringInfo { + public static final field Companion Ldev/inmo/tgbotapi/types/payments/RecurringInfo$Companion; + public fun (Ldev/inmo/tgbotapi/types/TelegramDate;Z)V + public final fun component1 ()Ldev/inmo/tgbotapi/types/TelegramDate; + public final fun component2 ()Z + public final fun copy (Ldev/inmo/tgbotapi/types/TelegramDate;Z)Ldev/inmo/tgbotapi/types/payments/RecurringInfo; + public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/payments/RecurringInfo;Ldev/inmo/tgbotapi/types/TelegramDate;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/RecurringInfo; + public fun equals (Ljava/lang/Object;)Z + public final fun getFirstSubscriptionPeriod ()Z + public final fun getSubscriptionExpirationDate ()Ldev/inmo/tgbotapi/types/TelegramDate; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public synthetic class dev/inmo/tgbotapi/types/payments/RecurringInfo$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/payments/RecurringInfo$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/payments/RecurringInfo; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/payments/RecurringInfo;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/payments/RecurringInfo$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/payments/RefundedPayment : dev/inmo/tgbotapi/types/payments/abstracts/Amounted, dev/inmo/tgbotapi/types/payments/abstracts/Currencied { public static final field Companion Ldev/inmo/tgbotapi/types/payments/RefundedPayment$Companion; public synthetic fun (Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -24617,17 +25087,20 @@ public final class dev/inmo/tgbotapi/types/payments/ShippingQuery$Companion { public final class dev/inmo/tgbotapi/types/payments/SuccessfulPayment : dev/inmo/tgbotapi/types/payments/abstracts/Amounted, dev/inmo/tgbotapi/types/payments/abstracts/Currencied { public static final field Companion Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment$Companion; - public synthetic fun (Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; + public final fun component10 ()Ldev/inmo/tgbotapi/types/payments/OrderInfo; public final fun component2 ()J public final fun component3 ()Ljava/lang/String; - public final fun component4-voYifgM ()Ljava/lang/String; - public final fun component5 ()Ljava/lang/String; - public final fun component6 ()Ljava/lang/String; - public final fun component7 ()Ldev/inmo/tgbotapi/types/payments/OrderInfo; - public final fun copy-KG1siBE (Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;)Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment; - public static synthetic fun copy-KG1siBE$default (Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment;Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment; + public final fun component4 ()Ldev/inmo/tgbotapi/types/TelegramDate; + public final fun component5 ()Ljava/lang/Boolean; + public final fun component6 ()Ljava/lang/Boolean; + public final fun component7-voYifgM ()Ljava/lang/String; + public final fun component8 ()Ljava/lang/String; + public final fun component9 ()Ljava/lang/String; + public final fun copy-Brov4uQ (Ljava/lang/String;JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;)Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment; + public static synthetic fun copy-Brov4uQ$default (Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment;Ljava/lang/String;JLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/payments/OrderInfo;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment; public fun equals (Ljava/lang/Object;)Z public fun getAdaptedMajorityTotalAmount ()D public fun getAmount ()J @@ -24635,9 +25108,13 @@ public final class dev/inmo/tgbotapi/types/payments/SuccessfulPayment : dev/inmo public final fun getInvoicePayload ()Ljava/lang/String; public final fun getOrderInfo ()Ldev/inmo/tgbotapi/types/payments/OrderInfo; public final fun getProviderPaymentChargeId ()Ljava/lang/String; + public final fun getRecurringInfo ()Ldev/inmo/tgbotapi/types/payments/RecurringInfo; public final fun getShippingOptionId ()Ljava/lang/String; + public final fun getSubscriptionExpirationDate ()Ldev/inmo/tgbotapi/types/TelegramDate; public final fun getTelegramPaymentChargeId-voYifgM ()Ljava/lang/String; public fun hashCode ()I + public final fun isFirstPeriodPayment ()Ljava/lang/Boolean; + public final fun isSubscriptionPayment ()Ljava/lang/Boolean; public fun toString ()Ljava/lang/String; } @@ -24777,11 +25254,11 @@ public final class dev/inmo/tgbotapi/types/payments/stars/RevenueWithdrawalState public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public abstract interface class dev/inmo/tgbotapi/types/payments/stars/StarTransaction { +public abstract interface class dev/inmo/tgbotapi/types/payments/stars/StarTransaction : dev/inmo/tgbotapi/types/payments/abstracts/Amounted { public static final field Companion Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Companion; - public abstract fun getAmount ()I public abstract fun getDate ()Ldev/inmo/tgbotapi/types/TelegramDate; public abstract fun getId-xINTbLo ()Ljava/lang/String; + public abstract fun getNanostarAmount ()I public abstract fun getPartner ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public abstract fun getReceiver ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public abstract fun getSource ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; @@ -24796,19 +25273,26 @@ public final class dev/inmo/tgbotapi/types/payments/stars/StarTransaction$Compan public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/types/payments/stars/StarTransaction$DefaultImpls { + public static fun getAdaptedMajorityTotalAmount (Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction;)D +} + public final class dev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming : dev/inmo/tgbotapi/types/payments/stars/StarTransaction { public static final field Companion Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming$Companion; - public synthetic fun (Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1-xINTbLo ()Ljava/lang/String; - public final fun component2 ()I - public final fun component3 ()Ldev/inmo/tgbotapi/types/TelegramDate; - public final fun component4 ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; - public final fun copy-39qJ92g (Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming; - public static synthetic fun copy-39qJ92g$default (Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming;Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming; + public final fun component2 ()J + public final fun component3 ()I + public final fun component4 ()Ldev/inmo/tgbotapi/types/TelegramDate; + public final fun component5 ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; + public final fun copy-UiV6LeQ (Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming; + public static synthetic fun copy-UiV6LeQ$default (Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming;Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incoming; public fun equals (Ljava/lang/Object;)Z - public fun getAmount ()I + public fun getAdaptedMajorityTotalAmount ()D + public fun getAmount ()J public fun getDate ()Ldev/inmo/tgbotapi/types/TelegramDate; public fun getId-xINTbLo ()Ljava/lang/String; + public fun getNanostarAmount ()I public fun getPartner ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public fun getReceiver ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public fun getSource ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; @@ -24822,17 +25306,20 @@ public final class dev/inmo/tgbotapi/types/payments/stars/StarTransaction$Incomi public final class dev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing : dev/inmo/tgbotapi/types/payments/stars/StarTransaction { public static final field Companion Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing$Companion; - public synthetic fun (Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1-xINTbLo ()Ljava/lang/String; - public final fun component2 ()I - public final fun component3 ()Ldev/inmo/tgbotapi/types/TelegramDate; - public final fun component4 ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; - public final fun copy-39qJ92g (Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing; - public static synthetic fun copy-39qJ92g$default (Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing;Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing; + public final fun component2 ()J + public final fun component3 ()I + public final fun component4 ()Ldev/inmo/tgbotapi/types/TelegramDate; + public final fun component5 ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; + public final fun copy-UiV6LeQ (Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing; + public static synthetic fun copy-UiV6LeQ$default (Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing;Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoing; public fun equals (Ljava/lang/Object;)Z - public fun getAmount ()I + public fun getAdaptedMajorityTotalAmount ()D + public fun getAmount ()J public fun getDate ()Ldev/inmo/tgbotapi/types/TelegramDate; public fun getId-xINTbLo ()Ljava/lang/String; + public fun getNanostarAmount ()I public fun getPartner ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public fun getReceiver ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public fun getSource ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; @@ -24846,19 +25333,22 @@ public final class dev/inmo/tgbotapi/types/payments/stars/StarTransaction$Outgoi public final class dev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown : dev/inmo/tgbotapi/types/payments/stars/StarTransaction { public static final field Companion Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown$Companion; - public synthetic fun (Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlinx/serialization/json/JsonElement;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlinx/serialization/json/JsonElement;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1-xINTbLo ()Ljava/lang/String; - public final fun component2 ()I - public final fun component3 ()Ldev/inmo/tgbotapi/types/TelegramDate; - public final fun component4 ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; + public final fun component2 ()J + public final fun component3 ()I + public final fun component4 ()Ldev/inmo/tgbotapi/types/TelegramDate; public final fun component5 ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; - public final fun component6 ()Lkotlinx/serialization/json/JsonElement; - public final fun copy-XW4r_4I (Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlinx/serialization/json/JsonElement;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown; - public static synthetic fun copy-XW4r_4I$default (Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown;Ljava/lang/String;ILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlinx/serialization/json/JsonElement;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown; + public final fun component6 ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; + public final fun component7 ()Lkotlinx/serialization/json/JsonElement; + public final fun copy-58pZDbM (Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlinx/serialization/json/JsonElement;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown; + public static synthetic fun copy-58pZDbM$default (Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown;Ljava/lang/String;JILdev/inmo/tgbotapi/types/TelegramDate;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlinx/serialization/json/JsonElement;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/StarTransaction$Unknown; public fun equals (Ljava/lang/Object;)Z - public fun getAmount ()I + public fun getAdaptedMajorityTotalAmount ()D + public fun getAmount ()J public fun getDate ()Ldev/inmo/tgbotapi/types/TelegramDate; public fun getId-xINTbLo ()Ljava/lang/String; + public fun getNanostarAmount ()I public fun getPartner ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public final fun getRaw ()Lkotlinx/serialization/json/JsonElement; public fun getReceiver ()Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; @@ -24912,6 +25402,26 @@ public final class dev/inmo/tgbotapi/types/payments/stars/TransactionPartner$Ads public fun toString ()Ljava/lang/String; } +public final class dev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram : dev/inmo/tgbotapi/types/payments/stars/TransactionPartner { + public static final field Companion Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram$Companion; + public static final field type Ljava/lang/String; + public fun (Ldev/inmo/tgbotapi/types/chat/PreviewBot;I)V + public final fun component1 ()Ldev/inmo/tgbotapi/types/chat/PreviewBot; + public final fun component2 ()I + public final fun copy (Ldev/inmo/tgbotapi/types/chat/PreviewBot;I)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram; + public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram;Ldev/inmo/tgbotapi/types/chat/PreviewBot;IILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram; + public fun equals (Ljava/lang/Object;)Z + public final fun getCommissionPerMille ()I + public final fun getSponsorUser ()Ldev/inmo/tgbotapi/types/chat/PreviewBot; + public fun getType ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/payments/stars/TransactionPartner$Companion : kotlinx/serialization/KSerializer { public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; @@ -24984,21 +25494,27 @@ public final class dev/inmo/tgbotapi/types/payments/stars/TransactionPartner$Unk public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class dev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User : dev/inmo/tgbotapi/types/payments/stars/TransactionPartner { +public final class dev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User : dev/inmo/tgbotapi/abstracts/types/SubscriptionPeriodInfo, dev/inmo/tgbotapi/types/payments/stars/TransactionPartner { public static final field Companion Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User$Companion; public static final field type Ljava/lang/String; - public synthetic fun (Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ldev/inmo/tgbotapi/types/payments/AffiliateInfo;Ljava/lang/String;Lkotlin/time/Duration;Ljava/util/List;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ldev/inmo/tgbotapi/types/payments/AffiliateInfo;Ljava/lang/String;Lkotlin/time/Duration;Ljava/util/List;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/inmo/tgbotapi/types/chat/PreviewUser; - public final fun component2 ()Ljava/lang/String; - public final fun component3 ()Ljava/util/List; - public final fun component4-Y25QJn4 ()Ljava/lang/String; - public final fun copy-0EfpaBE (Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User; - public static synthetic fun copy-0EfpaBE$default (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User;Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User; + public final fun component2 ()Ldev/inmo/tgbotapi/types/payments/AffiliateInfo; + public final fun component3 ()Ljava/lang/String; + public final fun component4-FghU774 ()Lkotlin/time/Duration; + public final fun component5 ()Ljava/util/List; + public final fun component6-Y25QJn4 ()Ljava/lang/String; + public final fun component7 ()Ldev/inmo/tgbotapi/types/gifts/Gift; + public final fun copy-13OOIVY (Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ldev/inmo/tgbotapi/types/payments/AffiliateInfo;Ljava/lang/String;Lkotlin/time/Duration;Ljava/util/List;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User; + public static synthetic fun copy-13OOIVY$default (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User;Ldev/inmo/tgbotapi/types/chat/PreviewUser;Ldev/inmo/tgbotapi/types/payments/AffiliateInfo;Ljava/lang/String;Lkotlin/time/Duration;Ljava/util/List;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$User; public fun equals (Ljava/lang/Object;)Z + public final fun getAffiliate ()Ldev/inmo/tgbotapi/types/payments/AffiliateInfo; + public final fun getGift ()Ldev/inmo/tgbotapi/types/gifts/Gift; public final fun getInvoicePayload ()Ljava/lang/String; public final fun getPaidMedia ()Ljava/util/List; public final fun getPaidMediaPayload-Y25QJn4 ()Ljava/lang/String; + public fun getSubscriptionPeriod-FghU774 ()Lkotlin/time/Duration; public fun getType ()Ljava/lang/String; public final fun getUser ()Ldev/inmo/tgbotapi/types/chat/PreviewUser; public fun hashCode ()I @@ -27211,6 +27727,12 @@ public final class dev/inmo/tgbotapi/utils/TimeSpanAsSecondsSerializer : kotlinx public fun serialize-HG0u8IE (Lkotlinx/serialization/encoding/Encoder;J)V } +public final class dev/inmo/tgbotapi/utils/crypto/Ed25519TelegramKeys { + public static final field INSTANCE Ldev/inmo/tgbotapi/utils/crypto/Ed25519TelegramKeys; + public static final field Production Ljava/lang/String; + public static final field TestEnvironment Ljava/lang/String; +} + public final class dev/inmo/tgbotapi/utils/extensions/AsReferenceKt { public static final fun asReference (Ljava/lang/Object;)Ljava/lang/ref/WeakReference; } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/SubscriptionInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/SubscriptionInfo.kt new file mode 100644 index 0000000000..826f4a0ed0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/SubscriptionInfo.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.abstracts.types + +import korlibs.time.TimeSpan + +interface SubscriptionInfo : SubscriptionPeriodInfo { + val subscriptionPrice: UInt? +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/SubscriptionPeriodInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/SubscriptionPeriodInfo.kt new file mode 100644 index 0000000000..1eb6e77718 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/SubscriptionPeriodInfo.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.abstracts.types + +import korlibs.time.TimeSpan + +interface SubscriptionPeriodInfo { + val subscriptionPeriod: TimeSpan? +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt index d49a98df05..4b50b7b8df 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt @@ -1,5 +1,7 @@ package dev.inmo.tgbotapi.requests.chat.invite_links +import dev.inmo.tgbotapi.abstracts.types.SubscriptionInfo +import dev.inmo.tgbotapi.abstracts.types.SubscriptionPeriodInfo import korlibs.time.DateTime import dev.inmo.tgbotapi.requests.chat.abstracts.* import dev.inmo.tgbotapi.types.* @@ -15,9 +17,9 @@ sealed interface CreateChatInviteLink : EditChatInv override fun method(): String = "createChatInviteLink" - sealed interface Subscription : CreateChatInviteLink { - val subscriptionPeriod: TimeSpan - val subscriptionPrice: UInt + sealed interface Subscription : CreateChatInviteLink, SubscriptionInfo { + override val subscriptionPeriod: TimeSpan + override val subscriptionPrice: UInt override fun method(): String = "createChatSubscriptionInviteLink" } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription.kt new file mode 100644 index 0000000000..960e4b2f5b --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/payments/EditUserStarSubscription.kt @@ -0,0 +1,32 @@ +package dev.inmo.tgbotapi.requests.edit.payments + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.isCanceledField +import dev.inmo.tgbotapi.types.payments.abstracts.TelegramPaymentChargeId +import dev.inmo.tgbotapi.types.telegramPaymentChargeIdField +import dev.inmo.tgbotapi.types.userIdField +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy +import kotlinx.serialization.builtins.serializer + +@Serializable +data class EditUserStarSubscription( + @SerialName(userIdField) + val userId: UserId, + @SerialName(telegramPaymentChargeIdField) + val telegramPaymentChargeId: TelegramPaymentChargeId, + @SerialName(isCanceledField) + val isCanceled: Boolean +) : SimpleRequest { + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "editUserStarSubscription" + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/gifts/GetAvailableGifts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/gifts/GetAvailableGifts.kt new file mode 100644 index 0000000000..7f0a8434c9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/gifts/GetAvailableGifts.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.requests.gifts + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.gifts.Gifts +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy + +@Serializable +data object GetAvailableGifts : SimpleRequest { + override fun method(): String = "getAvailableGifts" + + override val resultDeserializer: DeserializationStrategy + get() = Gifts.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/gifts/SendGift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/gifts/SendGift.kt new file mode 100644 index 0000000000..b411fd8c0c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/gifts/SendGift.kt @@ -0,0 +1,57 @@ +package dev.inmo.tgbotapi.requests.gifts + +import dev.inmo.tgbotapi.abstracts.TextedOutput +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.ParseMode +import dev.inmo.tgbotapi.types.message.RawMessageEntity +import dev.inmo.tgbotapi.types.message.asTextSources +import dev.inmo.tgbotapi.types.message.textsources.TextSource +import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.message.toRawMessageEntities +import dev.inmo.tgbotapi.utils.extensions.makeSourceString +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy +import kotlinx.serialization.builtins.serializer + +@Serializable +data class SendGift internal constructor( + @SerialName(userIdField) + val userId: UserId, + @SerialName(giftIdField) + val giftId: GiftId, + @SerialName(textField) + override val text: String, + @SerialName(textParseModeField) + override val parseMode: ParseMode?, + @SerialName(textEntitiesField) + private val rawEntities: List? = null, +) : SimpleRequest, TextedOutput { + override val textSources: TextSourcesList? by lazy { + rawEntities ?.asTextSources(text) + } + + override fun method(): String = "sendGift" + + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + + constructor( + userId: UserId, + giftId: GiftId, + text: String, + parseMode: ParseMode? + ) : this(userId, giftId, text, parseMode, null) + + constructor( + userId: UserId, + giftId: GiftId, + textSources: TextSourcesList, + ) : this(userId, giftId, textSources.makeSourceString(), null, textSources.toRawMessageEntities()) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage.kt new file mode 100644 index 0000000000..85f6d85437 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage.kt @@ -0,0 +1,35 @@ +package dev.inmo.tgbotapi.requests.inline + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer +import dev.inmo.tgbotapi.types.InlineQueries.prepared.PreparedInlineMessage +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy + +@Serializable +data class SavePreparedInlineMessage( + @SerialName(userIdField) + val userId: UserId, + @Serializable(InlineQueryResultSerializer::class) + @SerialName(resultField) + val result: InlineQueryResult, + @SerialName(allowUserChatsField) + val allowSendToUsers: Boolean = false, + @SerialName(allowBotChatsField) + val allowSendToBots: Boolean = false, + @SerialName(allowGroupChatsField) + val allowSendToGroups: Boolean = false, + @SerialName(allowChannelChatsField) + val allowSendToChannels: Boolean = false, +) : SimpleRequest { + override fun method(): String = "savePreparedInlineMessage" + + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + override val resultDeserializer: DeserializationStrategy + get() = PreparedInlineMessage.serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink.kt index f1114a47f4..eda5157e5e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/CreateInvoiceLink.kt @@ -3,8 +3,8 @@ package dev.inmo.tgbotapi.requests.send.payments import dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData import dev.inmo.tgbotapi.abstracts.types.* import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest -import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.InvoiceContent @@ -12,6 +12,8 @@ import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.LabeledPricesSerializer import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.XTR +import dev.inmo.tgbotapi.utils.TimeSpanAsSecondsSerializer +import korlibs.time.TimeSpan import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer @@ -30,9 +32,14 @@ data class CreateInvoiceLink( override val providerToken: String?, @SerialName(currencyField) override val currency: Currency, + @SerialName(businessConnectionIdField) + override val businessConnectionId: BusinessConnectionId? = null, @Serializable(LabeledPricesSerializer::class) @SerialName(pricesField) override val prices: List, + @SerialName(subscriptionPeriodField) + @Serializable(TimeSpanAsSecondsSerializer::class) + override val subscriptionPeriod: TimeSpan? = null, @SerialName(maxTipAmountField) override val maxTipAmount: Int? = null, @SerialName(suggestedTipAmountsField) @@ -53,7 +60,7 @@ data class CreateInvoiceLink( override val shouldSendEmailToProvider: Boolean = false, @SerialName(priceDependOnShipAddressField) override val priceDependOnShipAddress: Boolean = false -) : CommonSendInvoiceData, SimpleRequest { +) : CommonSendInvoiceData, SimpleRequest, WithOptionalBusinessConnectionId, SubscriptionPeriodInfo { override fun method(): String = "createInvoiceLink" override val resultDeserializer: DeserializationStrategy get() = String.serializer() @@ -137,4 +144,8 @@ data class CreateInvoiceLink( photoWidth = null photoHeight = null } + + companion object { + const val DEFAULT: Seconds = 2592000 // 30 days + } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus.kt new file mode 100644 index 0000000000..60af40bdee --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus.kt @@ -0,0 +1,28 @@ +package dev.inmo.tgbotapi.requests.set + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy +import kotlinx.serialization.builtins.serializer + +@Serializable +data class SetUserEmojiStatus( + @SerialName(userIdField) + val userId: UserId, + @SerialName(emojiStatusCustomEmojiIdField) + val customEmojiId: CustomEmojiId, + @Serializable(TelegramDateSerializer::class) + @SerialName(emojiStatusExpirationDateField) + val expirationDate: TelegramDate? = null +) : SimpleRequest { + override fun method(): String = "setUserEmojiStatus" + + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt index eab0f0349d..9a1f7f0ec6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt @@ -2,8 +2,12 @@ package dev.inmo.tgbotapi.types import korlibs.time.DateTime import dev.inmo.tgbotapi.abstracts.WithUser +import dev.inmo.tgbotapi.abstracts.types.SubscriptionInfo +import dev.inmo.tgbotapi.abstracts.types.SubscriptionPeriodInfo import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.TimeSpanAsSecondsSerializer +import korlibs.time.TimeSpan import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder @@ -64,7 +68,7 @@ sealed interface ChatInviteLink : WithUser { * Base interface for all [ChatInviteLink]s which are NOT [PrimaryInviteLink] */ @Serializable(ChatInviteLinkSerializer::class) -sealed interface SecondaryChatInviteLink : ChatInviteLink { +sealed interface SecondaryChatInviteLink : ChatInviteLink, SubscriptionInfo { override val isPrimary: Boolean get() = false } @@ -108,7 +112,12 @@ data class ChatInviteLinkWithJoinRequest( @SerialName(isRevokedField) override val isRevoked: Boolean = false, @SerialName(expireDateField) - private val expireDate: TelegramDate? = null + private val expireDate: TelegramDate? = null, + @SerialName(subscriptionPeriodField) + @Serializable(TimeSpanAsSecondsSerializer::class) + override val subscriptionPeriod: TimeSpan? = null, + @SerialName(subscriptionPriceField) + override val subscriptionPrice: UInt? = null ) : SecondaryChatInviteLink { override val expirationDateTime: DateTime? get() = expireDate ?.asDate @@ -131,6 +140,11 @@ data class ChatInviteLinkWithLimitedMembers( override val isRevoked: Boolean = false, @SerialName(expireDateField) private val expireDate: TelegramDate? = null, + @SerialName(subscriptionPeriodField) + @Serializable(TimeSpanAsSecondsSerializer::class) + override val subscriptionPeriod: TimeSpan? = null, + @SerialName(subscriptionPriceField) + override val subscriptionPrice: UInt? = null ) : SecondaryChatInviteLink { override val expirationDateTime: DateTime? get() = expireDate ?.asDate @@ -152,6 +166,11 @@ data class ChatInviteLinkUnlimited( override val isRevoked: Boolean = false, @SerialName(expireDateField) private val expireDate: TelegramDate? = null, + @SerialName(subscriptionPeriodField) + @Serializable(TimeSpanAsSecondsSerializer::class) + override val subscriptionPeriod: TimeSpan? = null, + @SerialName(subscriptionPriceField) + override val subscriptionPrice: UInt? = null ) : SecondaryChatInviteLink { override val expirationDateTime: DateTime? get() = expireDate ?.asDate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 324ac6a3a3..61a402d508 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -34,6 +34,18 @@ value class PaidMediaPayload(val string: String) { } } +@Serializable +@JvmInline +value class GiftId( + val string: String +) + +@Serializable +@JvmInline +value class PreparedMessageId( + val string: String +) + val usernameRegex = Regex("@[\\w\\d_]+") val degreesLimit = 1 .. 360 @@ -190,6 +202,7 @@ const val maskPositionField = "mask_position" const val phoneNumberField = "phone_number" const val userIdField = "user_id" const val userIdsField = "user_ids" +const val giftIdField = "gift_id" const val onlyIfBannedField = "only_if_banned" const val containsMasksField = "contains_masks" const val resultIdField = "result_id" @@ -454,6 +467,7 @@ const val actionField = "action" const val positionField = "position" const val labelField = "label" const val amountField = "amount" +const val nanostarAmountField = "nanostar_amount" const val pricesField = "prices" const val payloadField = "payload" const val vcardField = "vcard" @@ -472,6 +486,8 @@ const val creatorField = "creator" const val subscriptionPeriodField = "subscription_period" const val subscriptionPriceField = "subscription_price" const val copyTextField = "copy_text" +const val giftField = "gift" +const val giftsField = "gifts" const val pointField = "point" const val xShiftField = "x_shift" @@ -504,6 +520,11 @@ const val startParameterField = "start_parameter" const val totalAmountField = "total_amount" const val invoicePayloadField = "invoice_payload" const val requestCountField = "request_count" +const val sponsorUserField = "sponsor_user" +const val affiliateUserField = "affiliate_user" +const val affiliateChatField = "affiliate_chat" +const val commissionPerMilleField = "commission_per_mille" +const val affiliateField = "affiliate" const val paidMediaPayloadField = "paid_media_payload" const val shippingOptionIdField = "shipping_option_id" const val shippingQueryIdField = "shipping_query_id" @@ -512,6 +533,7 @@ const val shippingOptionsField = "shipping_options" const val countryCodeField = "country_code" const val countryCodesField = "country_codes" const val totalCountField = "total_count" +const val remainingCountField = "remaining_count" const val stateField = "state" const val cityField = "city" const val firstStreetLineField = "street_line1" @@ -519,7 +541,11 @@ const val secondStreetLineField = "street_line2" const val postCodeField = "post_code" const val shippingAddressField = "shipping_address" const val orderInfoField = "order_info" +const val subscriptionExpirationDateField = "subscription_expiration_date" +const val isRecurringField = "is_recurring" +const val isFirstRecurringField = "is_first_recurring" const val telegramPaymentChargeIdField = "telegram_payment_charge_id" +const val isCanceledField = "is_canceled" const val providerPaymentChargeIdField = "provider_payment_charge_id" const val providerTokenField = "provider_token" const val providerDataField = "provider_data" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage.kt new file mode 100644 index 0000000000..6a1a9a1737 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/prepared/PreparedInlineMessage.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.InlineQueries.prepared + +import dev.inmo.tgbotapi.types.PreparedMessageId +import dev.inmo.tgbotapi.types.TelegramDate +import dev.inmo.tgbotapi.types.expirationDateField +import dev.inmo.tgbotapi.types.idField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class PreparedInlineMessage( + @SerialName(idField) + val id: PreparedMessageId, + @SerialName(expirationDateField) + val expirationDate: TelegramDate, +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt new file mode 100644 index 0000000000..a8398160ab --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gift.kt @@ -0,0 +1,92 @@ +package dev.inmo.tgbotapi.types.gifts + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.files.Sticker +import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +@Serializable(Gift.Companion::class) +sealed interface Gift { + val id: GiftId + val sticker: Sticker + val starCount: Int + val totalCount: Int? + val remainingCount: Int? + + @Serializable + data class Unlimited( + @SerialName(idField) + override val id: GiftId, + @SerialName(stickerField) + override val sticker: Sticker, + @SerialName(starCountField) + override val starCount: Int + ) : Gift { + override val totalCount: Int? + get() = null + override val remainingCount: Int? + get() = null + } + + @Serializable + data class Limited( + @SerialName(idField) + override val id: GiftId, + @SerialName(stickerField) + override val sticker: Sticker, + @SerialName(starCountField) + override val starCount: Int, + @SerialName(totalCountField) + override val totalCount: Int, + @SerialName(remainingCountField) + override val remainingCount: Int, + ) : Gift + + companion object : KSerializer { + @Serializable + private data class GiftSurrogate( + val id: GiftId, + val sticker: Sticker, + val star_count: Int, + val total_count: Int? = null, + val remaining_count: Int? = null, + ) + + override val descriptor: SerialDescriptor + get() = GiftSurrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): Gift { + val surrogate = GiftSurrogate.serializer().deserialize(decoder) + + return if (surrogate.total_count != null && surrogate.remaining_count != null) { + Limited( + surrogate.id, + surrogate.sticker, + surrogate.star_count, + surrogate.total_count, + surrogate.remaining_count + ) + } else { + Unlimited( + surrogate.id, + surrogate.sticker, + surrogate.star_count, + ) + } + } + + override fun serialize(encoder: Encoder, value: Gift) { + val surrogate = GiftSurrogate( + value.id, + value.sticker, + value.starCount, + value.totalCount, + value.remainingCount + ) + } + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt new file mode 100644 index 0000000000..07ae5c6fd1 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/Gifts.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.types.gifts + +import dev.inmo.tgbotapi.types.giftsField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class Gifts( + @SerialName(giftsField) + val gifts: List +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/AffiliateInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/AffiliateInfo.kt new file mode 100644 index 0000000000..fda6153240 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/AffiliateInfo.kt @@ -0,0 +1,24 @@ +package dev.inmo.tgbotapi.types.payments + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.PreviewBot +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.chat.PreviewUser +import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.payments.abstracts.Amounted +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class AffiliateInfo( + @SerialName(commissionPerMilleField) + val commissionPerMille: Int, + @SerialName(amountField) + override val amount: Long, + @SerialName(nanostarAmountField) + val nanostarAmount: Long, + @SerialName(affiliateUserField) + val affiliateUser: User? = null, + @SerialName(affiliateChatField) + val affiliateChat: PreviewChat? = null, +) : Amounted diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/RecurringInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/RecurringInfo.kt new file mode 100644 index 0000000000..7043cc4274 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/RecurringInfo.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.types.payments + +import dev.inmo.tgbotapi.types.TelegramDate +import dev.inmo.tgbotapi.types.isFirstRecurringField +import dev.inmo.tgbotapi.types.subscriptionExpirationDateField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class RecurringInfo( + @SerialName(subscriptionExpirationDateField) + val subscriptionExpirationDate: TelegramDate, + @SerialName(isFirstRecurringField) + val firstSubscriptionPeriod: Boolean +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/SuccessfulPayment.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/SuccessfulPayment.kt index c075f706f8..ebf4d9a2c8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/SuccessfulPayment.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/SuccessfulPayment.kt @@ -13,6 +13,12 @@ data class SuccessfulPayment( override val amount: Long, @SerialName(invoicePayloadField) val invoicePayload: String, + @SerialName(subscriptionExpirationDateField) + val subscriptionExpirationDate: TelegramDate? = null, + @SerialName(isRecurringField) + val isSubscriptionPayment: Boolean? = null, + @SerialName(isFirstRecurringField) + val isFirstPeriodPayment: Boolean? = null, @SerialName(telegramPaymentChargeIdField) val telegramPaymentChargeId: TelegramPaymentChargeId, @SerialName(providerPaymentChargeIdField) @@ -21,4 +27,15 @@ data class SuccessfulPayment( val shippingOptionId: String? = null, @SerialName(orderInfoField) val orderInfo: OrderInfo? = null -) : Amounted, Currencied +) : Amounted, Currencied { + val recurringInfo: RecurringInfo? by lazy { + if (isSubscriptionPayment == true && subscriptionExpirationDate != null) { + RecurringInfo( + subscriptionExpirationDate, + isFirstPeriodPayment == true, + ) + } else { + null + } + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/StarTransaction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/StarTransaction.kt index 65dff97f24..9dc7173a39 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/StarTransaction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/StarTransaction.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.payments.stars import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.PreviewUser +import dev.inmo.tgbotapi.types.payments.abstracts.Amounted import dev.inmo.tgbotapi.utils.decodeDataAndJson import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import kotlinx.serialization.KSerializer @@ -16,9 +17,9 @@ import kotlinx.serialization.json.JsonElement @Suppress("SERIALIZER_TYPE_INCOMPATIBLE") @Serializable(StarTransaction.Companion::class) @ClassCastsIncluded -sealed interface StarTransaction { +sealed interface StarTransaction : Amounted { val id: StarTransactionId - val amount: Int + val nanostarAmount: Int val date: TelegramDate val partner: TransactionPartner val source: TransactionPartner? @@ -29,7 +30,9 @@ sealed interface StarTransaction { @SerialName(idField) override val id: StarTransactionId, @SerialName(amountField) - override val amount: Int, + override val amount: Long, + @SerialName(nanostarAmountField) + override val nanostarAmount: Int, @SerialName(dateField) override val date: TelegramDate, @SerialName(sourceField) @@ -47,7 +50,9 @@ sealed interface StarTransaction { @SerialName(idField) override val id: StarTransactionId, @SerialName(amountField) - override val amount: Int, + override val amount: Long, + @SerialName(nanostarAmountField) + override val nanostarAmount: Int, @SerialName(dateField) override val date: TelegramDate, @SerialName(receiverField) @@ -64,7 +69,9 @@ sealed interface StarTransaction { data class Unknown( @SerialName(idField) override val id: StarTransactionId, - override val amount: Int, + override val amount: Long, + @SerialName(nanostarAmountField) + override val nanostarAmount: Int, override val date: TelegramDate, override val source: TransactionPartner?, override val receiver: TransactionPartner?, @@ -78,7 +85,9 @@ sealed interface StarTransaction { @Serializable private data class Surrogate( val id: StarTransactionId, - val amount: Int, + val amount: Long, + @SerialName(nanostarAmountField) + val nanostarAmount: Int, val date: TelegramDate, val source: TransactionPartner? = null, val receiver: TransactionPartner? = null, @@ -94,6 +103,7 @@ sealed interface StarTransaction { Unknown( id = data.id, amount = data.amount, + nanostarAmount = data.nanostarAmount, date = data.date, source = data.source, receiver = data.receiver, @@ -104,12 +114,14 @@ sealed interface StarTransaction { data.source != null -> Incoming( id = data.id, amount = data.amount, + nanostarAmount = data.nanostarAmount, date = data.date, partner = data.source ) data.receiver != null -> Outgoing( id = data.id, amount = data.amount, + nanostarAmount = data.nanostarAmount, date = data.date, partner = data.receiver ) @@ -126,6 +138,7 @@ sealed interface StarTransaction { val surrogate = Surrogate( id = value.id, amount = value.amount, + nanostarAmount = value.nanostarAmount, date = value.date, source = value.source, receiver = value.receiver, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt index 90cf454d9a..feaf9bd10a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt @@ -2,11 +2,17 @@ package dev.inmo.tgbotapi.types.payments.stars +import dev.inmo.tgbotapi.abstracts.types.SubscriptionPeriodInfo import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.PreviewBot import dev.inmo.tgbotapi.types.chat.PreviewUser +import dev.inmo.tgbotapi.types.gifts.Gift import dev.inmo.tgbotapi.types.message.payments.PaidMedia +import dev.inmo.tgbotapi.types.payments.AffiliateInfo +import dev.inmo.tgbotapi.utils.TimeSpanAsSecondsSerializer import dev.inmo.tgbotapi.utils.decodeDataAndJson import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded +import korlibs.time.TimeSpan import kotlinx.serialization.EncodeDefault import kotlinx.serialization.KSerializer import kotlinx.serialization.SerialName @@ -40,13 +46,20 @@ sealed interface TransactionPartner { data class User( @SerialName(userField) val user: PreviewUser, + @SerialName(affiliateField) + val affiliate: AffiliateInfo? = null, @SerialName(invoicePayloadField) val invoicePayload: InvoicePayload? = null, + @SerialName(subscriptionPeriodField) + @Serializable(TimeSpanAsSecondsSerializer::class) + override val subscriptionPeriod: TimeSpan? = null, @SerialName(paidMediaField) val paidMedia: List? = null, @SerialName(paidMediaPayloadField) - val paidMediaPayload: PaidMediaPayload? = null - ) : TransactionPartner { + val paidMediaPayload: PaidMediaPayload? = null, + @SerialName(giftField) + val gift: Gift? = null + ) : TransactionPartner, SubscriptionPeriodInfo { @EncodeDefault override val type: String = Companion.type @@ -71,6 +84,24 @@ sealed interface TransactionPartner { } } + /** + * Represents [TransactionPartnerAffiliateProgram](https://core.telegram.org/bots/api#transactionpartneraffiliateprogram) + */ + @Serializable(TransactionPartner.Companion::class) + data class AffiliateProgram( + @SerialName(sponsorUserField) + val sponsorUser: PreviewBot?, + @SerialName(commissionPerMilleField) + val commissionPerMille: Int, + ) : TransactionPartner { + @EncodeDefault + override val type: String = Companion.type + + companion object { + const val type: String = "affiliate_program" + } + } + @Serializable(TransactionPartner.Companion::class) data object Ads : TransactionPartner { @EncodeDefault @@ -95,8 +126,17 @@ sealed interface TransactionPartner { val type: String, val withdrawal_state: RevenueWithdrawalState? = null, val user: PreviewUser? = null, + val affiliate: AffiliateInfo? = null, val invoice_payload: InvoicePayload? = null, - val request_count: Int? = null + @Serializable(TimeSpanAsSecondsSerializer::class) + val subscription_period: TimeSpan? = null, + val paid_media: List? = null, + val paid_media_payload: PaidMediaPayload? = null, + val gift: Gift? = null, + val request_count: Int? = null, + val sponsor_user: PreviewBot? = null, + val commission_per_mille: Int? = null, + val invoicePayload: InvoicePayload? = null ) override val descriptor: SerialDescriptor @@ -108,35 +148,63 @@ sealed interface TransactionPartner { val unknown by lazy { Unknown(data.type, json) } - return when (data.type) { - Other.type -> Other - User.type -> User( - data.user ?: return unknown, - ) - TelegramAPI.type -> TelegramAPI( - data.request_count ?: return unknown, - ) - Ads.type -> Ads - Fragment.type -> Fragment( - data.withdrawal_state ?: return unknown, - ) - else -> unknown + return with(data) { + when (data.type) { + Other.type -> Other + User.type -> User( + user = user ?: return unknown, + affiliate = affiliate, + invoicePayload = invoice_payload, + subscriptionPeriod = subscription_period, + paidMedia = paid_media, + paidMediaPayload = paid_media_payload, + gift = gift + ) + TelegramAPI.type -> TelegramAPI( + data.request_count ?: return unknown, + ) + Ads.type -> Ads + Fragment.type -> Fragment( + data.withdrawal_state ?: return unknown, + ) + AffiliateProgram.type -> AffiliateProgram( + data.sponsor_user, + data.commission_per_mille ?: return unknown, + ) + else -> unknown + } } } override fun serialize(encoder: Encoder, value: TransactionPartner) { - val surrogate = when (value) { - Other -> Surrogate(value.type) - Ads -> Surrogate(value.type) - is User -> Surrogate(value.type, user = value.user) - is TelegramAPI -> Surrogate(value.type, request_count = value.requestCount) - is Fragment -> Surrogate( - value.type, - value.withdrawalState - ) - is Unknown -> value.raw ?.let { - return JsonElement.serializer().serialize(encoder, it) - } ?: Surrogate(value.type) + val surrogate = with (value) { + when (this) { + Other -> Surrogate(type = value.type) + Ads -> Surrogate(type = value.type) + is User -> Surrogate( + type = value.type, + user = user, + affiliate = affiliate, + invoice_payload = invoicePayload, + subscription_period = subscriptionPeriod, + paid_media = paidMedia, + paid_media_payload = paidMediaPayload, + gift = gift + ) + is TelegramAPI -> Surrogate(type = value.type, request_count = requestCount) + is Fragment -> Surrogate( + type = value.type, + withdrawal_state = withdrawalState + ) + is AffiliateProgram -> Surrogate( + type = value.type, + sponsor_user = sponsorUser, + commission_per_mille = commissionPerMille + ) + is Unknown -> raw ?.let { + return JsonElement.serializer().serialize(encoder, it) + } ?: Surrogate(type = value.type) + } } Surrogate.serializer().serialize(encoder, surrogate) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/crypto/Ed25519TelegramKeys.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/crypto/Ed25519TelegramKeys.kt new file mode 100644 index 0000000000..34c5c63ece --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/crypto/Ed25519TelegramKeys.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.utils.crypto + +object Ed25519TelegramKeys { + const val TestEnvironment = "40055058a4ee38156a06562e52eece92a771bcd8346a8c4615cb7376eddf72ec" // hex + const val Production = "e7bf03a2fa4602af4580703d88dda5bb59f32ed8b02a56c187fe7d34caed242d" // hex +} \ No newline at end of file diff --git a/tgbotapi.utils/api/tgbotapi.utils.api b/tgbotapi.utils/api/tgbotapi.utils.api index ae493b7ddd..3325a79112 100644 --- a/tgbotapi.utils/api/tgbotapi.utils.api +++ b/tgbotapi.utils/api/tgbotapi.utils.api @@ -1069,6 +1069,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt { public static final fun administratorChatMemberOrThrow (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/chat/member/AdministratorChatMember; public static final fun adsOrNull (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$Ads; public static final fun adsOrThrow (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$Ads; + public static final fun affiliateProgramOrNull (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram; + public static final fun affiliateProgramOrThrow (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;)Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner$AffiliateProgram; public static final fun animatedStickerOrNull (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;)Ldev/inmo/tgbotapi/types/files/AnimatedSticker; public static final fun animatedStickerOrThrow (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;)Ldev/inmo/tgbotapi/types/files/AnimatedSticker; public static final fun animationContentOrNull (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/AnimationContent; @@ -1479,6 +1481,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt { public static final fun ifAddressSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifAdministratorChatMember (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifAds (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun ifAffiliateProgram (Ldev/inmo/tgbotapi/types/payments/stars/TransactionPartner;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifAnimatedSticker (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifAnimationContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifAnimationFile (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index 6cf1b959bd..4f90213436 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -5330,6 +5330,16 @@ public inline fun TransactionPartner.adsOrThrow(): TransactionPartner.Ads = this public inline fun TransactionPartner.ifAds(block: (TransactionPartner.Ads) -> T): T? = adsOrNull() ?.let(block) +public inline fun TransactionPartner.affiliateProgramOrNull(): TransactionPartner.AffiliateProgram? + = this as? dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.AffiliateProgram + +public inline fun TransactionPartner.affiliateProgramOrThrow(): TransactionPartner.AffiliateProgram + = this as dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.AffiliateProgram + +public inline fun + TransactionPartner.ifAffiliateProgram(block: (TransactionPartner.AffiliateProgram) -> T): T? = + affiliateProgramOrNull() ?.let(block) + public inline fun TransactionPartner.fragmentOrNull(): TransactionPartner.Fragment? = this as? dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Fragment diff --git a/tgbotapi.webapps/.templates/generator.kts b/tgbotapi.webapps/.templates/generator.kts new file mode 100755 index 0000000000..32c872dd4f --- /dev/null +++ b/tgbotapi.webapps/.templates/generator.kts @@ -0,0 +1,260 @@ +#!/usr/bin/env kotlin +/** + * Generates files and folders as they have been put in the folder. Envs uses common syntax, but + * values may contains {{${'$'}sampleVariable}} parts, where {{${'$'}sampleVariable}} will be replaced with variable value. + * Example: + * + * .env: + * sampleVariable=${'$'}prompt # require request from command line + * sampleVariable2=just some value + * sampleVariable3=${'$'}{sampleVariable}.${'$'}{sampleVariable2} + * + * Result variables: + * sampleVariable=your input in console # lets imagine you typed it + * sampleVariable2=just some value + * sampleVariable3=your input in console.just some value + * + * To use these variables in template, you will need to write {{${'$'}sampleVariable}}. + * You may use it in text of files as well as in files/folders names. + * + * Usage: kotlin generator.kts [args] folders... + * Args: + * -e, --env: Path to file with args for generation; Use "${'$'}prompt" as values to read variable value from console + * -o, --outputFolder: Folder where templates should be used. Folder of calling by default + * folders: Folders-templates + * -s, --skip: Skip variables setup + * -a, --args: Pass several for several args. Use with syntax `--args a=b` or `-a a=b` to set variable with key `a` to value `b` + * -v, --verbose: Show more verbose output + */ +import java.io.File + +val console = System.console() + +var envFile: File? = null +var outputFolder: File = File("./") // current folder by default +val templatesFolders = mutableListOf() +var extensions: List? = null +var skipPrompts: Boolean = false +val commandLineArgs = mutableMapOf() +val globalEnvs = System.getenv().toMutableMap() +var verboseMode: Boolean = false + +if (args.any { it == "-v" || it == "--verbose" }) { + println(args.joinToString("\n")) +} + +fun String.replaceWithVariables(envs: Map): String { + var currentString = this + var changed = false + + do { + changed = false + envs.forEach { (k, v) -> + val previousString = currentString + currentString = currentString.replace("{{$${k}}}", v) + changed = changed || currentString != previousString + } + } while (changed) + + return currentString +} + +fun requestVariable(variableName: String, defaultValue: String?): String { + console.printf("Enter value for variable $variableName${defaultValue ?.let { " [$it]" } ?: ""}: ") + return console.readLine().ifEmpty { defaultValue } ?: "" +} + +fun readEnvs(content: String, presets: Map?): Map { + val initialEnvs = mutableMapOf() + val contentAsMap = mutableMapOf() + content.split("\n").forEach { + val withoutComment = it.replace(Regex("\\#.*"), "") + + runCatching { + val (key, value) = withoutComment.split("=") + + contentAsMap[key] = value + } + } + + if (skipPrompts) { + initialEnvs.putAll( + contentAsMap + (presets ?: emptyMap()) + globalEnvs + commandLineArgs + ) + } else { + contentAsMap.forEach { (key, value) -> + val existsValue = presets ?.get(key) ?: commandLineArgs[key] ?: globalEnvs[key] + initialEnvs[key] = when { + value == "\$prompt" -> requestVariable(key, existsValue) + else -> requestVariable(key, value.replaceWithVariables(initialEnvs)) + } + } + } + var i = 0 + val readEnvs = initialEnvs.toMutableMap() + while (i < readEnvs.size) { + val key = readEnvs.keys.elementAt(i) + val currentValue = readEnvs.getValue(key) + val withReplaced = currentValue.replaceWithVariables(readEnvs) + var changed = false + if (withReplaced != currentValue) { + i = 0 + readEnvs[key] = withReplaced + } else { + i++ + } + } + return (presets ?: emptyMap()) + readEnvs +} + +val realArgs = args.map { sourceArg -> + if (sourceArg.startsWith("\"") && sourceArg.endsWith("\"")) { + sourceArg.removePrefix("\"").removeSuffix("\"") + } else { + sourceArg + } +} + +fun readParameters() { + var i = 0 + while (i < realArgs.size) { + val arg = realArgs[i] + when (arg) { + "--env", + "-e" -> { + i++ + envFile = File(realArgs[i]) + } + "--skip", + "-s" -> { + skipPrompts = true + } + "--extensions", + "-ex" -> { + i++ + extensions = realArgs[i].split(",") + } + "--outputFolder", + "-o" -> { + i++ + outputFolder = File(realArgs[i]) + } + "--verbose", + "-v" -> { + verboseMode = true + } + "--args", + "-a" -> { + i++ + val subarg = realArgs[i] + val key = subarg.takeWhile { it != '=' } + val value = subarg.dropWhile { it != '=' }.removePrefix("=") + if (verboseMode) { + println("Argument $key=$value") + } + commandLineArgs[key] = value + } + "--help", + "-h" -> { + println(""" + Generates files and folders as the have been put in the folder. Envs uses common syntax, but + values may contains {{${'$'}sampleVariable}} parts, where {{${'$'}sampleVariable}} will be replaced with variable value. + Example: + + .env: + sampleVariable=${'$'}prompt # require request from command line + sampleVariable2=just some value + sampleVariable3=${'$'}{sampleVariable}.${'$'}{sampleVariable2} + + Result variables: + sampleVariable=your input in console # lets imagine you typed it + sampleVariable2=just some value + sampleVariable3=your input in console.just some value + + To use these variables in template, you will need to write {{${'$'}sampleVariable}}. + You may use it in text of files as well as in files/folders names. + + Usage: kotlin generator.kts [args] folders... + Args: + -e, --env: Path to file with args for generation; Use "${'$'}prompt" as values to read variable value from console + -o, --outputFolder: Folder where templates should be used. Folder of calling by default + folders: Folders-templates + -s, --skip: Skip variables setup + -a, --args: Pass several for several args. Use with syntax `--args a=b` or `-a a=b` to set variable with key `a` to value `b` + """.trimIndent()) + Runtime.getRuntime().exit(0) + } + else -> { + println(arg) + val potentialFile = File(arg) + println("Potential file/folder as template: ${potentialFile.absolutePath}") + runCatching { + if (potentialFile.exists()) { + println("Adding file/folder as template: ${potentialFile.absolutePath}") + templatesFolders.add(potentialFile) + } + }.onFailure { e -> + println("Unable to use folder $arg as template folder") + e.printStackTrace() + } + } + } + i++ + } +} + +readParameters() + +val envs: MutableMap = (envFile ?.let { readEnvs(it.readText(), null) } ?: (globalEnvs + commandLineArgs)).toMutableMap() + +println( + """ + Result environments: + ${envs.toList().joinToString("\n ") { (k, v) -> "$k=$v" }} + Result extensions: + ${extensions ?.joinToString()} + Input folders: + ${templatesFolders.joinToString("\n ") { it.absolutePath }} + Output folder: + ${outputFolder.absolutePath} + """.trimIndent() +) + +fun File.handleTemplate(targetFolder: File, envs: Map) { + println("Handling $absolutePath") + val localEnvs = File(absolutePath, ".env").takeIf { it.exists() } ?.let { + println("Reading .env in ${absolutePath}") + readEnvs(it.readText(), envs) + } ?: envs + println( + """ + Local environments: + ${localEnvs.toList().joinToString("\n ") { (k, v) -> "$k=$v" }} + """.trimIndent() + ) + val newName = name.replaceWithVariables(localEnvs) + println("New name $newName") + when { + !exists() -> return + isFile -> { + val content = useLines { + it.map { it.replaceWithVariables(localEnvs) }.toList() + }.joinToString("\n") + val targetFile = File(targetFolder, newName) + targetFile.writeText(content) + println("Target file: ${targetFile.absolutePath}") + } + else -> { + val folder = File(targetFolder, newName) + println("Target folder: ${folder.absolutePath}") + folder.mkdirs() + listFiles() ?.forEach { fileOrFolder -> + fileOrFolder.handleTemplate(folder, localEnvs) + } + } + } +} + +templatesFolders.forEach { folderOrFile -> + folderOrFile.handleTemplate(outputFolder, envs) +} diff --git a/tgbotapi.webapps/.templates/{{$subpackage}}/EventType{{$event_name_uppercase}}.kt b/tgbotapi.webapps/.templates/{{$subpackage}}/EventType{{$event_name_uppercase}}.kt new file mode 100644 index 0000000000..1c6f3908de --- /dev/null +++ b/tgbotapi.webapps/.templates/{{$subpackage}}/EventType{{$event_name_uppercase}}.kt @@ -0,0 +1 @@ +data object {{$event_name_uppercase}} : EventType("{{$event_name}}") \ No newline at end of file diff --git a/tgbotapi.webapps/.templates/{{$subpackage}}/WebApp{{$event_name_uppercase}}.kt b/tgbotapi.webapps/.templates/{{$subpackage}}/WebApp{{$event_name_uppercase}}.kt new file mode 100644 index 0000000000..fe13e7263b --- /dev/null +++ b/tgbotapi.webapps/.templates/{{$subpackage}}/WebApp{{$event_name_uppercase}}.kt @@ -0,0 +1,2 @@ +@JsName("onEvent") +internal fun on{{$event_name_uppercase}}(type: String, callback: ({{$callback_args}}) -> Unit) \ No newline at end of file diff --git a/tgbotapi.webapps/.templates/{{$subpackage}}/{{$event_name_uppercase}}.kt b/tgbotapi.webapps/.templates/{{$subpackage}}/{{$event_name_uppercase}}.kt new file mode 100644 index 0000000000..0f1b4db6f5 --- /dev/null +++ b/tgbotapi.webapps/.templates/{{$subpackage}}/{{$event_name_uppercase}}.kt @@ -0,0 +1,22 @@ +// Part for callback typealias + +typealias {{$callback_typealias_name}} = WebApp.({{$callback_args}}) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.{{$event_name_uppercase}}, eventHandler: {{$callback_typealias_name}}) = { {{$callback_args_definitions}} -> + eventHandler(js("this").unsafeCast(), {{$callback_args_names}}) +}.also { + on{{$event_name_uppercase}}( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.on{{$event_name_uppercase}}(eventHandler: {{$callback_typealias_name}}) = onEvent(EventType.{{$event_name_uppercase}}, eventHandler) diff --git a/tgbotapi.webapps/build.gradle b/tgbotapi.webapps/build.gradle index 9a17703fe8..8a5da2c325 100644 --- a/tgbotapi.webapps/build.gradle +++ b/tgbotapi.webapps/build.gradle @@ -2,6 +2,7 @@ plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" id "org.jetbrains.dokka" + id "com.google.devtools.ksp" } project.description = "Web App bindings for the Telegram Web Apps API" @@ -14,7 +15,15 @@ kotlin { commonMain { dependencies { api project(":tgbotapi.core") + api libs.microutils.ksp.sealed } } } } + +dependencies { + add("kspJs", libs.microutils.ksp.sealed.generator) +} + +ksp {} + diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/ContentSafeAreaInset.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/ContentSafeAreaInset.kt new file mode 100644 index 0000000000..8a12d22e36 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/ContentSafeAreaInset.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.webapps + +external interface ContentSafeAreaInset : SafeAreaInset {} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/DownloadFileParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/DownloadFileParams.kt new file mode 100644 index 0000000000..2bf289f140 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/DownloadFileParams.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.webapps + +import kotlin.js.json + +external interface DownloadFileParams { + val url: String + @JsName("file_name") + val fileName: String +} +fun DownloadFileParams( + url: String, + fileName: String +) = json( + "url" to url, + "file_name" to fileName +).unsafeCast() \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EmojiStatusParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EmojiStatusParams.kt new file mode 100644 index 0000000000..7770bd96bc --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EmojiStatusParams.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.webapps + +import dev.inmo.tgbotapi.types.Seconds +import kotlin.js.json + +external interface EmojiStatusParams { + val duration: Seconds? +} +fun EmojiStatusParams( + duration: Seconds +): EmojiStatusParams = json( + "duration" to duration +).unsafeCast() diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventHandler.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventHandler.kt index 584d54221c..dddbc67cf6 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventHandler.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventHandler.kt @@ -3,11 +3,3 @@ package dev.inmo.tgbotapi.webapps import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo typealias EventHandler = WebApp.() -> Unit -typealias ViewportChangedEventHandler = WebApp.(ViewportChangedData) -> Unit -typealias InvoiceClosedEventHandler = WebApp.(InvoiceClosedInfo) -> Unit -typealias PopupClosedEventHandler = WebApp.(String?) -> Unit -typealias QRTextReceivedEventHandler = WebApp.(String) -> Boolean -typealias TextReceivedEventHandler = WebApp.(String) -> Unit -typealias WriteAccessRequestedHandler = WebApp.(Boolean) -> Unit -typealias ContactRequestedHandler = WebApp.(Boolean) -> Unit -typealias onScanQRPopupClosedHandler = WebApp.() -> Unit diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventType.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventType.kt index 3bc56e0d6b..5c31ace099 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventType.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventType.kt @@ -1,17 +1,53 @@ package dev.inmo.tgbotapi.webapps +import dev.inmo.micro_utils.ksp.sealed.GenerateSealedWorkaround + +@GenerateSealedWorkaround sealed class EventType(val typeName: String) { + data object EmojiStatusAccessRequested : EventType("emojiStatusAccessRequested") + data object AccelerometerChanged : EventType("accelerometerChanged") + data object DeviceOrientationStarted : EventType("deviceOrientationStarted") + data object EmojiStatusFailed : EventType("emojiStatusFailed") + data object Activated : EventType("activated") + data object ShareMessageSent : EventType("shareMessageSent") + data object LocationManagerUpdated : EventType("locationManagerUpdated") + data object BiometricTokenUpdated : EventType("biometricTokenUpdated") + data object DeviceOrientationFailed : EventType("deviceOrientationFailed") + data object SafeAreaChanged : EventType("safeAreaChanged") + data object WriteAccessRequested : EventType("writeAccessRequested") + data object ContentSafeAreaChanged : EventType("contentSafeAreaChanged") + data object AccelerometerStarted : EventType("accelerometerStarted") + data object AccelerometerStopped : EventType("accelerometerStopped") + data object PopupClosed : EventType("popupClosed") + data object GyroscopeStopped : EventType("gyroscopeStopped") + data object BackButtonClicked : EventType("backButtonClicked") + data object HomeScreenAdded : EventType("homeScreenAdded") + data object ShareMessageFailed : EventType("shareMessageFailed") data object ThemeChanged : EventType("themeChanged") + data object BiometricManagerUpdated : EventType("biometricManagerUpdated") + data object ScanQrPopupClosed : EventType("scanQrPopupClosed") + data object BiometricAuthRequested : EventType("biometricAuthRequested") + data object HomeScreenChecked : EventType("homeScreenChecked") + data object LocationRequested : EventType("locationRequested") + data object SecondaryButtonClicked : EventType("secondaryButtonClicked") + data object QrTextReceived : EventType("qrTextReceived") + data object EmojiStatusSet : EventType("emojiStatusSet") + data object FullscreenFailed : EventType("fullscreenFailed") + data object GyroscopeFailed : EventType("gyroscopeFailed") + data object SettingsButtonClicked : EventType("settingsButtonClicked") + data object Deactivated : EventType("deactivated") + data object DeviceOrientationStopped : EventType("deviceOrientationStopped") + data object FullscreenChanged : EventType("fullscreenChanged") data object ViewportChanged : EventType("viewportChanged") data object MainButtonClicked : EventType("mainButtonClicked") - data object SecondaryButtonClicked : EventType("secondaryButtonClicked") - data object BackButtonClicked : EventType("backButtonClicked") - data object SettingsButtonClicked : EventType("settingsButtonClicked") - data object InvoiceClosed : EventType("invoiceClosed") - data object PopupClosed : EventType("popupClosed") - data object QRTextReceived : EventType("qrTextReceived") + data object AccelerometerFailed : EventType("accelerometerFailed") data object ClipboardTextReceived : EventType("clipboardTextReceived") - data object WriteAccessRequested : EventType("writeAccessRequested") + data object FileDownloadRequested : EventType("fileDownloadRequested") data object ContactRequested : EventType("contactRequested") - data object ScanQRPopupClosed : EventType("scanQrPopupClosed") + data object InvoiceClosed : EventType("invoiceClosed") + data object GyroscopeStarted : EventType("gyroscopeStarted") + data object GyroscopeChanged : EventType("gyroscopeChanged") + data object DeviceOrientationChanged : EventType("deviceOrientationChanged") + + companion object } diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventTypeSealedWorkaround.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventTypeSealedWorkaround.kt new file mode 100644 index 0000000000..1c565e15a4 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EventTypeSealedWorkaround.kt @@ -0,0 +1,53 @@ +// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY +// TO REGENERATE IT JUST DELETE FILE +// ORIGINAL FILE: EventType.kt +package dev.inmo.tgbotapi.webapps + +import kotlin.collections.Set + +private val values: Set = setOf(EventType.EmojiStatusAccessRequested, + EventType.AccelerometerChanged, + EventType.DeviceOrientationStarted, + EventType.EmojiStatusFailed, + EventType.Activated, + EventType.ShareMessageSent, + EventType.LocationManagerUpdated, + EventType.BiometricTokenUpdated, + EventType.DeviceOrientationFailed, + EventType.SafeAreaChanged, + EventType.WriteAccessRequested, + EventType.ContentSafeAreaChanged, + EventType.AccelerometerStarted, + EventType.AccelerometerStopped, + EventType.PopupClosed, + EventType.GyroscopeStopped, + EventType.BackButtonClicked, + EventType.HomeScreenAdded, + EventType.ShareMessageFailed, + EventType.ThemeChanged, + EventType.BiometricManagerUpdated, + EventType.ScanQrPopupClosed, + EventType.BiometricAuthRequested, + EventType.HomeScreenChecked, + EventType.LocationRequested, + EventType.SecondaryButtonClicked, + EventType.QrTextReceived, + EventType.EmojiStatusSet, + EventType.FullscreenFailed, + EventType.GyroscopeFailed, + EventType.SettingsButtonClicked, + EventType.Deactivated, + EventType.DeviceOrientationStopped, + EventType.FullscreenChanged, + EventType.ViewportChanged, + EventType.MainButtonClicked, + EventType.AccelerometerFailed, + EventType.ClipboardTextReceived, + EventType.FileDownloadRequested, + EventType.ContactRequested, + EventType.InvoiceClosed, + EventType.GyroscopeStarted, + EventType.GyroscopeChanged, + EventType.DeviceOrientationChanged) + +public fun EventType.Companion.values(): Set = values diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/HomeScreenStatus.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/HomeScreenStatus.kt new file mode 100644 index 0000000000..e39ca9f371 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/HomeScreenStatus.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.webapps + +enum class HomeScreenStatus(val value: String) { + Unsupported("unsupported"), + Unknown("unknown"), + Added("added"), + Missed("missed"), +} diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/RequestStatus.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/RequestStatus.kt index 189b9c1411..56a3ad14a4 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/RequestStatus.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/RequestStatus.kt @@ -11,4 +11,13 @@ inline val RequestStatus.isAllowed: Boolean get() = status == "allowed" inline val RequestStatus.isSent: Boolean + get() = status == "sent" + +inline val dev.inmo.tgbotapi.webapps.args.ArgStatusObject.isCancelled: Boolean + get() = status == "cancelled" + +inline val dev.inmo.tgbotapi.webapps.args.ArgStatusObject.isAllowed: Boolean + get() = status == "allowed" + +inline val dev.inmo.tgbotapi.webapps.args.ArgStatusObject.isSent: Boolean get() = status == "sent" \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/SafeAreaInset.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/SafeAreaInset.kt new file mode 100644 index 0000000000..f02eddc4c0 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/SafeAreaInset.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.webapps + +external interface SafeAreaInset { + val top: Int + val bottom: Int + val left: Int + val right: Int +} + diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt index c782c821cd..41eb003b75 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt @@ -1,10 +1,16 @@ package dev.inmo.tgbotapi.webapps +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.PreparedMessageId import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper +import dev.inmo.tgbotapi.webapps.accelerometer.Accelerometer import dev.inmo.tgbotapi.webapps.biometric.BiometricManager import dev.inmo.tgbotapi.webapps.cloud.CloudStorage +import dev.inmo.tgbotapi.webapps.gyroscope.Gyroscope import dev.inmo.tgbotapi.webapps.haptic.HapticFeedback import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo +import dev.inmo.tgbotapi.webapps.location.LocationManager +import dev.inmo.tgbotapi.webapps.orientation.DeviceOrientation import dev.inmo.tgbotapi.webapps.popup.* import dev.inmo.tgbotapi.webapps.stories.StoryShareParams @@ -52,6 +58,20 @@ external class WebApp { fun closeScanQrPopup() fun readTextFromClipboard(callback: TextReceivedCallback? = definedExternally) + val isActive: Boolean + val isFullscreen: Boolean + val safeAreaInset: SafeAreaInset + val contentSafeAreaInset: ContentSafeAreaInset + fun requestFullscreen() + fun exitFullscreen() + + val isOrientationLocked: Boolean + fun lockOrientation() + fun unlockOrientation() + + fun addToHomeScreen() + fun checkHomeScreenStatus(callback: (HomeScreenStatus) -> Unit = definedExternally) + @JsName("MainButton") val mainButton: BottomButton @JsName("SecondaryButton") @@ -69,28 +89,22 @@ external class WebApp { @JsName("BiometricManager") val biometricManager: BiometricManager + @JsName("Accelerometer") + val accelerometer: Accelerometer + + @JsName("DeviceOrientation") + val deviceOrientation: DeviceOrientation + + @JsName("Gyroscope") + val gyroscope: Gyroscope + + @JsName("LocationManager") + val locationManager: LocationManager + @JsName("SettingsButton") val settingsButton: SettingsButton internal fun onEvent(type: String, callback: () -> Unit) - @JsName("onEvent") - internal fun onEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit) - @JsName("onEvent") - internal fun onEventWithInvoiceClosedInfo(type: String, callback: (InvoiceClosedInfo) -> Unit) - @JsName("onEvent") - internal fun onEventWithPopupClosedInfo(type: String, callback: (String?) -> Unit) - @JsName("onEvent") - internal fun onEventWithQRTextInfo(type: String, callback: (String) -> Boolean) - @JsName("onEvent") - internal fun onEventWithTextInfo(type: String, callback: (String) -> Unit) - @JsName("onEvent") - internal fun onEventWithWriteAccessRequested(type: String, callback: (RequestStatus) -> Unit) - @JsName("onEvent") - internal fun onEventWithContactRequested(type: String, callback: (RequestStatus) -> Unit) - @JsName("onEvent") - internal fun onEventWithSettingsButtonClicked(type: String, callback: () -> Unit) - @JsName("onEvent") - internal fun onEventWithScanQRPopupClosed(type: String, callback: () -> Unit) fun offEvent(type: String, callback: () -> Unit) @JsName("offEvent") @@ -111,8 +125,108 @@ external class WebApp { fun shareToStory(mediaUrl: String, params: StoryShareParams? = definedExternally) + fun shareMessage(messageId: PreparedMessageId, callback: (Boolean) -> Unit = definedExternally) + + fun setEmojiStatus(customEmojiId: CustomEmojiId, params: EmojiStatusParams = definedExternally, callback: (Boolean) -> Unit = definedExternally) + fun requestEmojiStatusAccess(callback: (Boolean) -> Unit = definedExternally) + + fun downloadFile(params: DownloadFileParams, callback: (Boolean) -> Unit = definedExternally) + fun requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally) fun requestContact(callback: ((Boolean) -> Unit)? = definedExternally) + + // Start of generated part + + @JsName("onEvent") + internal fun onEmojiStatusAccessRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit) + @JsName("onEvent") + internal fun onAccelerometerChanged(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onDeviceOrientationStarted(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onEmojiStatusFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit) + @JsName("onEvent") + internal fun onActivated(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onShareMessageSent(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onLocationManagerUpdated(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onBiometricTokenUpdated(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgIsUpdatedObject) -> Unit) + @JsName("onEvent") + internal fun onDeviceOrientationFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit) + @JsName("onEvent") + internal fun onSafeAreaChanged(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onWriteAccessRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit) + @JsName("onEvent") + internal fun onContentSafeAreaChanged(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onAccelerometerStarted(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onAccelerometerStopped(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onPopupClosed(type: String, callback: (dev.inmo.tgbotapi.webapps.popup.PopupClosedEventArg) -> Unit) + @JsName("onEvent") + internal fun onGyroscopeStopped(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onBackButtonClicked(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onHomeScreenAdded(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onShareMessageFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit) + @JsName("onEvent") + internal fun onThemeChanged(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onBiometricManagerUpdated(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onScanQrPopupClosed(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onBiometricAuthRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgBiometricAuthRequested) -> Unit) + @JsName("onEvent") + internal fun onHomeScreenChecked(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit) + @JsName("onEvent") + internal fun onLocationRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgLocationDataObject) -> Unit) + @JsName("onEvent") + internal fun onSecondaryButtonClicked(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onQrTextReceived(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgDataObject) -> Unit) + @JsName("onEvent") + internal fun onEmojiStatusSet(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onFullscreenFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit) + @JsName("onEvent") + internal fun onGyroscopeFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit) + @JsName("onEvent") + internal fun onSettingsButtonClicked(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onDeactivated(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onDeviceOrientationStopped(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onFullscreenChanged(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onViewportChanged(type: String, callback: (Boolean) -> Unit) + @JsName("onEvent") + internal fun onMainButtonClicked(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onAccelerometerFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit) + @JsName("onEvent") + internal fun onClipboardTextReceived(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgDataNullableObject) -> Unit) + @JsName("onEvent") + internal fun onFileDownloadRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit) + @JsName("onEvent") + internal fun onContactRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit) + @JsName("onEvent") + internal fun onInvoiceClosed(type: String, callback: (String, String) -> Unit) + @JsName("onEvent") + internal fun onGyroscopeStarted(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onGyroscopeChanged(type: String, callback: () -> Unit) + @JsName("onEvent") + internal fun onDeviceOrientationChanged(type: String, callback: () -> Unit) + + // End of generated part } val WebApp.colorScheme: ColorScheme @@ -122,178 +236,178 @@ val WebApp.colorScheme: ColorScheme else -> ColorScheme.LIGHT } -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = { - eventHandler(js("this").unsafeCast()) -}.also { - onEvent( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: ViewportChangedData -> - eventHandler(js("this").unsafeCast(), it) -}.also { - onEventWithViewportChangedData( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { it: InvoiceClosedInfo -> - eventHandler(js("this").unsafeCast(), it) -}.also { - onEventWithInvoiceClosedInfo( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHandler) = { it: String? -> - eventHandler(js("this").unsafeCast(), it) -}.also { - onEventWithPopupClosedInfo( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.QRTextReceived, eventHandler: QRTextReceivedEventHandler) = { it: String -> - eventHandler(js("this").unsafeCast(), it) -}.also { - onEventWithQRTextInfo( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: TextReceivedEventHandler) = { it: String -> - eventHandler(js("this").unsafeCast(), it) -}.also { - onEventWithTextInfo( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedHandler) = { it: RequestStatus -> - eventHandler(js("this").unsafeCast(), it.isAllowed) -}.also { - onEventWithWriteAccessRequested( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedHandler) = { it: RequestStatus -> - eventHandler(js("this").unsafeCast(), it.isSent) -}.also { - onEventWithContactRequested( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = { - eventHandler(js("this").unsafeCast()) -}.also { - onEventWithSettingsButtonClicked( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onEvent(type: EventType.ScanQRPopupClosed, eventHandler: EventHandler) = { - eventHandler(js("this").unsafeCast()) -}.also { - onEventWithScanQRPopupClosed( - type.typeName, - callback = it - ) -} - -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onThemeChanged(eventHandler: EventHandler) = onEvent(EventType.ThemeChanged, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onMainButtonClicked(eventHandler: EventHandler) = onEvent(EventType.MainButtonClicked, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onSecondaryButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SecondaryButtonClicked, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onViewportChanged(eventHandler: ViewportChangedEventHandler) = onEvent(EventType.ViewportChanged, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onBackButtonClicked(eventHandler: EventHandler) = onEvent(EventType.BackButtonClicked, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onSettingsButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SettingsButtonClicked, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(EventType.InvoiceClosed, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onPopupClosed(eventHandler: PopupClosedEventHandler) = onEvent(EventType.PopupClosed, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onQRTextReceived(eventHandler: QRTextReceivedEventHandler) = onEvent(EventType.QRTextReceived, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onClipboardTextReceived(eventHandler: TextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onWriteAccessRequested(eventHandler: WriteAccessRequestedHandler) = onEvent(EventType.WriteAccessRequested, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onContactRequested(eventHandler: ContactRequestedHandler) = onEvent(EventType.ContactRequested, eventHandler) -/** - * @return The callback which should be used in case you want to turn off events handling - */ -fun WebApp.onScanQRPopupClosed(eventHandler: onScanQRPopupClosedHandler) = onEvent(EventType.ScanQRPopupClosed, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = { +// eventHandler(js("this").unsafeCast()) +//}.also { +// onEvent( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: ViewportChangedData -> +// eventHandler(js("this").unsafeCast(), it) +//}.also { +// onEventWithViewportChangedData( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { it: InvoiceClosedInfo -> +// eventHandler(js("this").unsafeCast(), it) +//}.also { +// onEventWithInvoiceClosedInfo( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHandler) = { it: String? -> +// eventHandler(js("this").unsafeCast(), it) +//}.also { +// onEventWithPopupClosedInfo( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.QRTextReceived, eventHandler: QRTextReceivedEventHandler) = { it: String -> +// eventHandler(js("this").unsafeCast(), it) +//}.also { +// onEventWithQRTextInfo( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: TextReceivedEventHandler) = { it: String -> +// eventHandler(js("this").unsafeCast(), it) +//}.also { +// onEventWithTextInfo( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedHandler) = { it: RequestStatus -> +// eventHandler(js("this").unsafeCast(), it.isAllowed) +//}.also { +// onEventWithWriteAccessRequested( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedHandler) = { it: RequestStatus -> +// eventHandler(js("this").unsafeCast(), it.isSent) +//}.also { +// onEventWithContactRequested( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = { +// eventHandler(js("this").unsafeCast()) +//}.also { +// onEventWithSettingsButtonClicked( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onEvent(type: EventType.ScanQRPopupClosed, eventHandler: EventHandler) = { +// eventHandler(js("this").unsafeCast()) +//}.also { +// onEventWithScanQRPopupClosed( +// type.typeName, +// callback = it +// ) +//} +// +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onThemeChanged(eventHandler: EventHandler) = onEvent(EventType.ThemeChanged, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onMainButtonClicked(eventHandler: EventHandler) = onEvent(EventType.MainButtonClicked, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onSecondaryButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SecondaryButtonClicked, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onViewportChanged(eventHandler: ViewportChangedEventHandler) = onEvent(EventType.ViewportChanged, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onBackButtonClicked(eventHandler: EventHandler) = onEvent(EventType.BackButtonClicked, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onSettingsButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SettingsButtonClicked, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(EventType.InvoiceClosed, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onPopupClosed(eventHandler: PopupClosedEventHandler) = onEvent(EventType.PopupClosed, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onQRTextReceived(eventHandler: QRTextReceivedEventHandler) = onEvent(EventType.QRTextReceived, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onClipboardTextReceived(eventHandler: TextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onWriteAccessRequested(eventHandler: WriteAccessRequestedHandler) = onEvent(EventType.WriteAccessRequested, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onContactRequested(eventHandler: ContactRequestedHandler) = onEvent(EventType.ContactRequested, eventHandler) +///** +// * @return The callback which should be used in case you want to turn off events handling +// */ +//fun WebApp.onScanQRPopupClosed(eventHandler: onScanQRPopupClosedHandler) = onEvent(EventType.ScanQRPopupClosed, eventHandler) fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData( initData, diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt index 78c7528233..1fe1f572a4 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.webapps import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.ChatType external interface WebAppInitData { @JsName("query_id") @@ -9,6 +10,14 @@ external interface WebAppInitData { val user: WebAppUser? val receiver: WebAppUser? + val chat: WebAppChat? + + @JsName("chat_type") + val chatType: ChatType? + + @JsName("chat_instance") + val chatInstance: String? + @JsName("start_param") val startParam: String? @@ -16,9 +25,9 @@ external interface WebAppInitData { val authDate: MilliSeconds @JsName("can_send_after") - val canSendAfter: MilliSeconds - - val chat: WebAppChat + val canSendAfter: MilliSeconds? val hash: String + + val signature: String } diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/accelerometer/Accelerometer.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/accelerometer/Accelerometer.kt new file mode 100644 index 0000000000..f23a4f75d9 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/accelerometer/Accelerometer.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.webapps.accelerometer + +external interface Accelerometer { + val isStarted: Boolean + val x: Double + val y: Double + val z: Double + + fun start(params: AccelerometerStartParams, callback: (Boolean) -> Unit = definedExternally) + fun stop(callback: (Boolean) -> Unit) +} + diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/accelerometer/AccelerometerStartParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/accelerometer/AccelerometerStartParams.kt new file mode 100644 index 0000000000..81baae99e9 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/accelerometer/AccelerometerStartParams.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.webapps.accelerometer + +import dev.inmo.tgbotapi.types.MilliSeconds +import kotlin.js.json + +external interface AccelerometerStartParams { + @JsName("refresh_rate") + val refreshRate: MilliSeconds +} + +fun AccelerometerStartParams(refreshRate: MilliSeconds = 1000): AccelerometerStartParams = json( + "refresh_rate" to refreshRate +).unsafeCast() \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgBiometricAuthRequested.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgBiometricAuthRequested.kt new file mode 100644 index 0000000000..7d06214ecf --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgBiometricAuthRequested.kt @@ -0,0 +1,4 @@ +package dev.inmo.tgbotapi.webapps.args + +interface ArgBiometricAuthRequested : ArgBiometricTokenNullableObject, ArgIsAuthenticatedObject { +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgBiometricTokenNullableObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgBiometricTokenNullableObject.kt new file mode 100644 index 0000000000..b1b39df81b --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgBiometricTokenNullableObject.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.webapps.args + +external interface ArgBiometricTokenNullableObject { + val biometricToken: String? +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgDataNullableObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgDataNullableObject.kt new file mode 100644 index 0000000000..206cb74f62 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgDataNullableObject.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.webapps.args + +external interface ArgDataNullableObject { + val data: String? +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgDataObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgDataObject.kt new file mode 100644 index 0000000000..cf45b19e8b --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgDataObject.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.webapps.args + +external interface ArgDataObject : ArgDataNullableObject { + override val data: String +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgErrorObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgErrorObject.kt new file mode 100644 index 0000000000..d1b7757198 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgErrorObject.kt @@ -0,0 +1,32 @@ +package dev.inmo.tgbotapi.webapps.args + +interface ArgErrorObject { + val error: String +} + +val ArgErrorObject.isUnsupported + get() = error.uppercase() == "UNSUPPORTED" + +val ArgErrorObject.isAlreadyFullscreen + get() = error.uppercase() == "ALREADY_FULLSCREEN" + +val ArgErrorObject.isAMessageExpired + get() = error.uppercase() == "MESSAGE_EXPIRED" + +val ArgErrorObject.isMessageSendFailed + get() = error.uppercase() == "MESSAGE_SEND_FAILED" + +val ArgErrorObject.isUserDeclined + get() = error.uppercase() == "USER_DECLINED" + +val ArgErrorObject.isSuggestedEmojiInvalid + get() = error.uppercase() == "SUGGESTED_EMOJI_INVALID" + +val ArgErrorObject.isDurationInvalid + get() = error.uppercase() == "DURATION_INVALID" + +val ArgErrorObject.isServerError + get() = error.uppercase() == "SERVER_ERROR" + +val ArgErrorObject.isUnknownError + get() = error.uppercase() == "UNKNOWN_ERROR" diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgIsAuthenticatedObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgIsAuthenticatedObject.kt new file mode 100644 index 0000000000..876ffb99c8 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgIsAuthenticatedObject.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.webapps.args + +interface ArgIsAuthenticatedObject { + val isAuthenticated: Boolean +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgIsUpdatedObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgIsUpdatedObject.kt new file mode 100644 index 0000000000..8688dfc2d7 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgIsUpdatedObject.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.webapps.args + +interface ArgIsUpdatedObject { + val isUpdated: Boolean +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgLocationDataObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgLocationDataObject.kt new file mode 100644 index 0000000000..92b8d6740e --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgLocationDataObject.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.webapps.args + +import dev.inmo.tgbotapi.webapps.location.LocationData + +interface ArgLocationDataObject { + val locationData: LocationData +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgStatusObject.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgStatusObject.kt new file mode 100644 index 0000000000..785a17b46d --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/args/ArgStatusObject.kt @@ -0,0 +1,26 @@ +package dev.inmo.tgbotapi.webapps.args + +external interface ArgStatusObject { + val status: String +} + +val ArgStatusObject.isUnsupported + get() = status.lowercase() == "unsupported" + +val ArgStatusObject.isUnknown + get() = status.lowercase() == "unknown" + +val ArgStatusObject.isAdded + get() = status.lowercase() == "added" + +val ArgStatusObject.isMissed + get() = status.lowercase() == "missed" + +val ArgStatusObject.isAllowed + get() = status.lowercase() == "allowed" + +val ArgStatusObject.isDownloading + get() = status.lowercase() == "downloading" + +val ArgStatusObject.isCancelled + get() = status.lowercase() == "cancelled" diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/cloud/CloudStorage.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/cloud/CloudStorage.kt index 251858f616..869e5bf999 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/cloud/CloudStorage.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/cloud/CloudStorage.kt @@ -18,11 +18,11 @@ external interface CloudStorage { ): CloudStorage fun removeItem( key: CloudStorageKey, - callback: (e: Any?, success: Boolean?) -> Unit + callback: (e: Any?, success: Boolean?) -> Unit = definedExternally ): CloudStorage fun removeItems( key: Array, - callback: (e: Any?, success: Boolean?) -> Unit + callback: (e: Any?, success: Boolean?) -> Unit = definedExternally ): CloudStorage fun getKeys( callback: (e: Any?, success: Array?) -> Unit @@ -80,24 +80,24 @@ fun CloudStorage.get( fun CloudStorage.remove( key: CloudStorageKey, - callback: (result: Result) -> Unit + callback: (result: Result) -> Unit = {} ) = removeItem(key) { e, v -> callback(resultsToResult(e, v)) } fun CloudStorage.remove( key: String, - callback: (result: Result) -> Unit + callback: (result: Result) -> Unit = {} ) = remove(CloudStorageKey(key), callback) fun CloudStorage.remove( keys: Array, - callback: (result: Result) -> Unit + callback: (result: Result) -> Unit = {} ) = removeItems( keys ) { e, v -> callback(resultsToResult(e, v)) } fun CloudStorage.remove( keys: Array, - callback: (result: Result) -> Unit + callback: (result: Result) -> Unit = {} ) = remove( Array(keys.size) { CloudStorageKey(keys[it]) @@ -109,7 +109,7 @@ fun CloudStorage.remove( key: String, key2: String, vararg otherKeys: String, - callback: (result: Result) -> Unit + callback: (result: Result) -> Unit = {} ) = remove( arrayOf(key, key2) + otherKeys, callback diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/EventsList.json b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/EventsList.json new file mode 100644 index 0000000000..7c39c84f49 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/EventsList.json @@ -0,0 +1,178 @@ +[ + { + "event_name": "activated", + "callback_args": "" + }, + { + "event_name": "deactivated", + "callback_args": "" + }, + { + "event_name": "themeChanged", + "callback_args": "" + }, + { + "event_name": "viewportChanged", + "callback_args": "Boolean" + }, + { + "event_name": "safeAreaChanged", + "callback_args": "" + }, + { + "event_name": "contentSafeAreaChanged", + "callback_args": "" + }, + { + "event_name": "mainButtonClicked", + "callback_args": "" + }, + { + "event_name": "secondaryButtonClicked", + "callback_args": "" + }, + { + "event_name": "backButtonClicked", + "callback_args": "" + }, + { + "event_name": "settingsButtonClicked", + "callback_args": "" + }, + { + "event_name": "invoiceClosed", + "callback_args": "String, String" + }, + { + "event_name": "popupClosed", + "callback_args": "dev.inmo.tgbotapi.webapps.popup.PopupClosedEventArg" + }, + { + "event_name": "qrTextReceived", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgDataObject" + }, + { + "event_name": "scanQrPopupClosed", + "callback_args": "" + }, + { + "event_name": "clipboardTextReceived", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgDataNullableObject" + }, + { + "event_name": "writeAccessRequested", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgStatusObject" + }, + { + "event_name": "contactRequested", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgStatusObject" + }, + { + "event_name": "biometricManagerUpdated", + "callback_args": "" + }, + { + "event_name": "biometricAuthRequested", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgBiometricAuthRequested" + }, + { + "event_name": "biometricTokenUpdated", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgIsUpdatedObject" + }, + { + "event_name": "fullscreenChanged", + "callback_args": "" + }, + { + "event_name": "fullscreenFailed", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgErrorObject" + }, + { + "event_name": "homeScreenAdded", + "callback_args": "" + }, + { + "event_name": "homeScreenChecked", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgStatusObject" + }, + { + "event_name": "accelerometerStarted", + "callback_args": "" + }, + { + "event_name": "accelerometerStopped", + "callback_args": "" + }, + { + "event_name": "accelerometerChanged", + "callback_args": "" + }, + { + "event_name": "accelerometerFailed", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgErrorObject" + }, + { + "event_name": "deviceOrientationStarted", + "callback_args": "" + }, + { + "event_name": "deviceOrientationStopped", + "callback_args": "" + }, + { + "event_name": "deviceOrientationChanged", + "callback_args": "" + }, + { + "event_name": "deviceOrientationFailed", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgErrorObject" + }, + { + "event_name": "gyroscopeStarted", + "callback_args": "" + }, + { + "event_name": "gyroscopeStopped", + "callback_args": "" + }, + { + "event_name": "gyroscopeChanged", + "callback_args": "" + }, + { + "event_name": "gyroscopeFailed", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgErrorObject" + }, + { + "event_name": "locationManagerUpdated", + "callback_args": "" + }, + { + "event_name": "locationRequested", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgLocationDataObject" + }, + { + "event_name": "shareMessageSent", + "callback_args": "" + }, + { + "event_name": "shareMessageFailed", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgErrorObject" + }, + { + "event_name": "emojiStatusSet", + "callback_args": "" + }, + { + "event_name": "emojiStatusFailed", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgErrorObject" + }, + { + "event_name": "emojiStatusAccessRequested", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgStatusObject" + }, + { + "event_name": "fileDownloadRequested", + "callback_args": "dev.inmo.tgbotapi.webapps.args.ArgStatusObject" + } +] diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/Extensions.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/Extensions.kt new file mode 100644 index 0000000000..5991b89931 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/Extensions.kt @@ -0,0 +1,973 @@ +package dev.inmo.tgbotapi.webapps.events + +import dev.inmo.tgbotapi.webapps.EventType +import dev.inmo.tgbotapi.webapps.WebApp + +// Part for callback typealias + +typealias EmojiStatusAccessRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.EmojiStatusAccessRequested, eventHandler: EmojiStatusAccessRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onEmojiStatusAccessRequested( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEmojiStatusAccessRequested(eventHandler: EmojiStatusAccessRequestedEventHandler) = onEvent(EventType.EmojiStatusAccessRequested, eventHandler) +// Part for callback typealias + +typealias AccelerometerChangedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.AccelerometerChanged, eventHandler: AccelerometerChangedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onAccelerometerChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onAccelerometerChanged(eventHandler: AccelerometerChangedEventHandler) = onEvent(EventType.AccelerometerChanged, eventHandler) +// Part for callback typealias + +typealias DeviceOrientationStartedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.DeviceOrientationStarted, eventHandler: DeviceOrientationStartedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onDeviceOrientationStarted( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onDeviceOrientationStarted(eventHandler: DeviceOrientationStartedEventHandler) = onEvent(EventType.DeviceOrientationStarted, eventHandler) +// Part for callback typealias + +typealias EmojiStatusFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.EmojiStatusFailed, eventHandler: EmojiStatusFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onEmojiStatusFailed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEmojiStatusFailed(eventHandler: EmojiStatusFailedEventHandler) = onEvent(EventType.EmojiStatusFailed, eventHandler) +// Part for callback typealias + +typealias ActivatedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.Activated, eventHandler: ActivatedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onActivated( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onActivated(eventHandler: ActivatedEventHandler) = onEvent(EventType.Activated, eventHandler) +// Part for callback typealias + +typealias ShareMessageSentEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ShareMessageSent, eventHandler: ShareMessageSentEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onShareMessageSent( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onShareMessageSent(eventHandler: ShareMessageSentEventHandler) = onEvent(EventType.ShareMessageSent, eventHandler) +// Part for callback typealias + +typealias LocationManagerUpdatedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.LocationManagerUpdated, eventHandler: LocationManagerUpdatedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onLocationManagerUpdated( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onLocationManagerUpdated(eventHandler: LocationManagerUpdatedEventHandler) = onEvent(EventType.LocationManagerUpdated, eventHandler) +// Part for callback typealias + +typealias BiometricTokenUpdatedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgIsUpdatedObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.BiometricTokenUpdated, eventHandler: BiometricTokenUpdatedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgIsUpdatedObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onBiometricTokenUpdated( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onBiometricTokenUpdated(eventHandler: BiometricTokenUpdatedEventHandler) = onEvent(EventType.BiometricTokenUpdated, eventHandler) +// Part for callback typealias + +typealias DeviceOrientationFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.DeviceOrientationFailed, eventHandler: DeviceOrientationFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onDeviceOrientationFailed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onDeviceOrientationFailed(eventHandler: DeviceOrientationFailedEventHandler) = onEvent(EventType.DeviceOrientationFailed, eventHandler) +// Part for callback typealias + +typealias SafeAreaChangedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.SafeAreaChanged, eventHandler: SafeAreaChangedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onSafeAreaChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onSafeAreaChanged(eventHandler: SafeAreaChangedEventHandler) = onEvent(EventType.SafeAreaChanged, eventHandler) +// Part for callback typealias + +typealias WriteAccessRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onWriteAccessRequested( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onWriteAccessRequested(eventHandler: WriteAccessRequestedEventHandler) = onEvent(EventType.WriteAccessRequested, eventHandler) +// Part for callback typealias + +typealias ContentSafeAreaChangedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ContentSafeAreaChanged, eventHandler: ContentSafeAreaChangedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onContentSafeAreaChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onContentSafeAreaChanged(eventHandler: ContentSafeAreaChangedEventHandler) = onEvent(EventType.ContentSafeAreaChanged, eventHandler) +// Part for callback typealias + +typealias AccelerometerStartedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.AccelerometerStarted, eventHandler: AccelerometerStartedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onAccelerometerStarted( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onAccelerometerStarted(eventHandler: AccelerometerStartedEventHandler) = onEvent(EventType.AccelerometerStarted, eventHandler) +// Part for callback typealias + +typealias AccelerometerStoppedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.AccelerometerStopped, eventHandler: AccelerometerStoppedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onAccelerometerStopped( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onAccelerometerStopped(eventHandler: AccelerometerStoppedEventHandler) = onEvent(EventType.AccelerometerStopped, eventHandler) +// Part for callback typealias + +typealias PopupClosedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.popup.PopupClosedEventArg) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.popup.PopupClosedEventArg -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onPopupClosed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onPopupClosed(eventHandler: PopupClosedEventHandler) = onEvent(EventType.PopupClosed, eventHandler) +// Part for callback typealias + +typealias GyroscopeStoppedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.GyroscopeStopped, eventHandler: GyroscopeStoppedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onGyroscopeStopped( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onGyroscopeStopped(eventHandler: GyroscopeStoppedEventHandler) = onEvent(EventType.GyroscopeStopped, eventHandler) +// Part for callback typealias + +typealias BackButtonClickedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.BackButtonClicked, eventHandler: BackButtonClickedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onBackButtonClicked( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onBackButtonClicked(eventHandler: BackButtonClickedEventHandler) = onEvent(EventType.BackButtonClicked, eventHandler) +// Part for callback typealias + +typealias HomeScreenAddedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.HomeScreenAdded, eventHandler: HomeScreenAddedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onHomeScreenAdded( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onHomeScreenAdded(eventHandler: HomeScreenAddedEventHandler) = onEvent(EventType.HomeScreenAdded, eventHandler) +// Part for callback typealias + +typealias ShareMessageFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ShareMessageFailed, eventHandler: ShareMessageFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onShareMessageFailed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onShareMessageFailed(eventHandler: ShareMessageFailedEventHandler) = onEvent(EventType.ShareMessageFailed, eventHandler) +// Part for callback typealias + +typealias ThemeChangedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ThemeChanged, eventHandler: ThemeChangedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onThemeChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onThemeChanged(eventHandler: ThemeChangedEventHandler) = onEvent(EventType.ThemeChanged, eventHandler) +// Part for callback typealias + +typealias BiometricManagerUpdatedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.BiometricManagerUpdated, eventHandler: BiometricManagerUpdatedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onBiometricManagerUpdated( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onBiometricManagerUpdated(eventHandler: BiometricManagerUpdatedEventHandler) = onEvent(EventType.BiometricManagerUpdated, eventHandler) +// Part for callback typealias + +typealias ScanQrPopupClosedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ScanQrPopupClosed, eventHandler: ScanQrPopupClosedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onScanQrPopupClosed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onScanQrPopupClosed(eventHandler: ScanQrPopupClosedEventHandler) = onEvent(EventType.ScanQrPopupClosed, eventHandler) +// Part for callback typealias + +typealias BiometricAuthRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgBiometricAuthRequested) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.BiometricAuthRequested, eventHandler: BiometricAuthRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgBiometricAuthRequested -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onBiometricAuthRequested( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onBiometricAuthRequested(eventHandler: BiometricAuthRequestedEventHandler) = onEvent(EventType.BiometricAuthRequested, eventHandler) +// Part for callback typealias + +typealias HomeScreenCheckedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.HomeScreenChecked, eventHandler: HomeScreenCheckedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onHomeScreenChecked( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onHomeScreenChecked(eventHandler: HomeScreenCheckedEventHandler) = onEvent(EventType.HomeScreenChecked, eventHandler) +// Part for callback typealias + +typealias LocationRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgLocationDataObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.LocationRequested, eventHandler: LocationRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgLocationDataObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onLocationRequested( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onLocationRequested(eventHandler: LocationRequestedEventHandler) = onEvent(EventType.LocationRequested, eventHandler) +// Part for callback typealias + +typealias SecondaryButtonClickedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.SecondaryButtonClicked, eventHandler: SecondaryButtonClickedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onSecondaryButtonClicked( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onSecondaryButtonClicked(eventHandler: SecondaryButtonClickedEventHandler) = onEvent(EventType.SecondaryButtonClicked, eventHandler) +// Part for callback typealias + +typealias QrTextReceivedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgDataObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.QrTextReceived, eventHandler: QrTextReceivedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgDataObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onQrTextReceived( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onQrTextReceived(eventHandler: QrTextReceivedEventHandler) = onEvent(EventType.QrTextReceived, eventHandler) +// Part for callback typealias + +typealias EmojiStatusSetEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.EmojiStatusSet, eventHandler: EmojiStatusSetEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onEmojiStatusSet( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEmojiStatusSet(eventHandler: EmojiStatusSetEventHandler) = onEvent(EventType.EmojiStatusSet, eventHandler) +// Part for callback typealias + +typealias FullscreenFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.FullscreenFailed, eventHandler: FullscreenFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onFullscreenFailed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onFullscreenFailed(eventHandler: FullscreenFailedEventHandler) = onEvent(EventType.FullscreenFailed, eventHandler) +// Part for callback typealias + +typealias GyroscopeFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.GyroscopeFailed, eventHandler: GyroscopeFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onGyroscopeFailed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onGyroscopeFailed(eventHandler: GyroscopeFailedEventHandler) = onEvent(EventType.GyroscopeFailed, eventHandler) +// Part for callback typealias + +typealias SettingsButtonClickedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: SettingsButtonClickedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onSettingsButtonClicked( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onSettingsButtonClicked(eventHandler: SettingsButtonClickedEventHandler) = onEvent(EventType.SettingsButtonClicked, eventHandler) +// Part for callback typealias + +typealias DeactivatedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.Deactivated, eventHandler: DeactivatedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onDeactivated( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onDeactivated(eventHandler: DeactivatedEventHandler) = onEvent(EventType.Deactivated, eventHandler) +// Part for callback typealias + +typealias DeviceOrientationStoppedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.DeviceOrientationStopped, eventHandler: DeviceOrientationStoppedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onDeviceOrientationStopped( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onDeviceOrientationStopped(eventHandler: DeviceOrientationStoppedEventHandler) = onEvent(EventType.DeviceOrientationStopped, eventHandler) +// Part for callback typealias + +typealias FullscreenChangedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.FullscreenChanged, eventHandler: FullscreenChangedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onFullscreenChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onFullscreenChanged(eventHandler: FullscreenChangedEventHandler) = onEvent(EventType.FullscreenChanged, eventHandler) +// Part for callback typealias + +typealias ViewportChangedEventHandler = WebApp.(Boolean) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { p0: Boolean -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onViewportChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onViewportChanged(eventHandler: ViewportChangedEventHandler) = onEvent(EventType.ViewportChanged, eventHandler) +// Part for callback typealias + +typealias MainButtonClickedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.MainButtonClicked, eventHandler: MainButtonClickedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onMainButtonClicked( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onMainButtonClicked(eventHandler: MainButtonClickedEventHandler) = onEvent(EventType.MainButtonClicked, eventHandler) +// Part for callback typealias + +typealias AccelerometerFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.AccelerometerFailed, eventHandler: AccelerometerFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onAccelerometerFailed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onAccelerometerFailed(eventHandler: AccelerometerFailedEventHandler) = onEvent(EventType.AccelerometerFailed, eventHandler) +// Part for callback typealias + +typealias ClipboardTextReceivedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgDataNullableObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: ClipboardTextReceivedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgDataNullableObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onClipboardTextReceived( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onClipboardTextReceived(eventHandler: ClipboardTextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler) +// Part for callback typealias + +typealias FileDownloadRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.FileDownloadRequested, eventHandler: FileDownloadRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onFileDownloadRequested( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onFileDownloadRequested(eventHandler: FileDownloadRequestedEventHandler) = onEvent(EventType.FileDownloadRequested, eventHandler) +// Part for callback typealias + +typealias ContactRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject -> + eventHandler(js("this").unsafeCast(), p0) +}.also { + onContactRequested( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onContactRequested(eventHandler: ContactRequestedEventHandler) = onEvent(EventType.ContactRequested, eventHandler) +// Part for callback typealias + +typealias InvoiceClosedEventHandler = WebApp.(String, String) -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { p0: String, p1: String -> + eventHandler(js("this").unsafeCast(), p0, p1) +}.also { + onInvoiceClosed( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(EventType.InvoiceClosed, eventHandler) +// Part for callback typealias + +typealias GyroscopeStartedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.GyroscopeStarted, eventHandler: GyroscopeStartedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onGyroscopeStarted( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onGyroscopeStarted(eventHandler: GyroscopeStartedEventHandler) = onEvent(EventType.GyroscopeStarted, eventHandler) +// Part for callback typealias + +typealias GyroscopeChangedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.GyroscopeChanged, eventHandler: GyroscopeChangedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onGyroscopeChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onGyroscopeChanged(eventHandler: GyroscopeChangedEventHandler) = onEvent(EventType.GyroscopeChanged, eventHandler) +// Part for callback typealias + +typealias DeviceOrientationChangedEventHandler = WebApp.() -> Unit + +// Part for outside of WebApp + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.DeviceOrientationChanged, eventHandler: DeviceOrientationChangedEventHandler) = { -> + eventHandler(js("this").unsafeCast(), ) +}.also { + onDeviceOrientationChanged( + type.typeName, + callback = it + ) +} + +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onDeviceOrientationChanged(eventHandler: DeviceOrientationChangedEventHandler) = onEvent(EventType.DeviceOrientationChanged, eventHandler) diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/events_generator.main.kts b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/events_generator.main.kts new file mode 100755 index 0000000000..9de427b02b --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/events/events_generator.main.kts @@ -0,0 +1,174 @@ +#!/usr/bin/env kotlin +// This script will read Event +@file:DependsOn("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + +import kotlinx.serialization.json.* +import java.io.File +import java.io.InputStream +import java.lang.Runtime +import java.lang.System + +val rootFolder = File("../../../../../../../../") +val rfAbsolutePath = rootFolder.absolutePath +val currentFolder = File("./") +val cfAbsolutePath = currentFolder.absolutePath + +val realArgs = args.map { sourceArg -> + if (sourceArg.startsWith("\"") && sourceArg.endsWith("\"")) { + sourceArg.removePrefix("\"").removeSuffix("\"") + } else { + sourceArg + } +} + +var verboseMode: Boolean = false + +fun readParameters() { + var i = 0 + while (i < realArgs.size) { + val arg = realArgs[i] + + when (arg) { + "-v", "--verbose" -> { + verboseMode = true + } + } + + i++ + } +} + +readParameters() + +fun generateEvent(eventName: String, callbackArgs: String) { + println("Start generating $eventName (callbacks: $callbackArgs)") + val uppercaseEventName = eventName.take(1).uppercase() + eventName.drop(1) + val subpackage = eventName.map { if (it.isUpperCase()) "_${it.lowercase()}" else it }.joinToString("") + var callbackNumber: Int = -1 + val splittedCallbacks = callbackArgs.split(Regex(" ?, ?")).filter { !it.isBlank() } + val callback_args_names = splittedCallbacks.joinToString(", ") { + callbackNumber++ + "p$callbackNumber" + } + callbackNumber = -1 + val callback_args_definitions = splittedCallbacks.joinToString(", ") { + callbackNumber++ + "p$callbackNumber: $it" + } + val verboseFlag = if (verboseMode) "-v" else "" + + val commandParts = arrayOf( + "${rfAbsolutePath}/.templates/generator.kts", + verboseFlag, + "-s", + "-a", "subpackage=$subpackage", + "-a", "event_name=$eventName", + "-a", "callback_args_names=$callback_args_names", + "-a", "event_name_uppercase=$uppercaseEventName", + "-a", "callback_args_definitions=$callback_args_definitions", + "-a", "callback_args=$callbackArgs", + "-a", "callback_typealias_name=${uppercaseEventName}EventHandler", + "-o", cfAbsolutePath, + "-ex", "kt", + "${rfAbsolutePath}/.templates/{{\$subpackage}}" + ) + val command = commandParts.joinToString(" ") { "\"$it\"" } + if (verboseMode) { + println(command) + } + + val process = Runtime.getRuntime().exec(commandParts) + val inputStream: InputStream = process.getInputStream() + val errorStream: InputStream = process.getErrorStream() + + val exitCode by lazy { process.waitFor() } + + if (verboseMode) { + inputStream.use { + it.copyTo(System.out) + } + println(exitCode) + } + + if (exitCode != 0) { + errorStream.use { + it.copyTo(System.out) + } + Runtime.getRuntime().exit(exitCode) + } + println("Complete generating $eventName") +} + +val eventsList: JsonArray = Json.parseToJsonElement(File("EventsList.json").readText()).jsonArray + +eventsList.forEach { + generateEvent( + it.jsonObject["event_name"]!!.jsonPrimitive.content, + it.jsonObject["callback_args"] ?.jsonPrimitive ?.content ?: "" + ) +} + +val eventTypeParts = mutableListOf() +val webAppParts = mutableListOf() +val extensionsParts = mutableListOf() + +currentFolder.listFiles() ?.forEach { generatedFolder: File -> + if (generatedFolder.isDirectory) { + generatedFolder.listFiles() ?.forEach { generatedFile: File -> + when { + generatedFile.name.startsWith("EventType") -> { + eventTypeParts + } + generatedFile.name.startsWith("WebApp") -> { + webAppParts + } + else -> { + extensionsParts + } + }.add(generatedFile.readText()) + } + } +} + +val eventTypePartsString = eventTypeParts.joinToString("\n") { " $it" } +eventTypeParts.clear() +val eventTypeFileContent = "package dev.inmo.tgbotapi.webapps\n\nimport dev.inmo.tgbotapi.webapps.EventType\nimport dev.inmo.tgbotapi.webapps.WebApp\n\nsealed class EventType(val typeName: String) {\n${eventTypePartsString}\n}\n" +if (verboseMode) { + println(eventTypeFileContent) +} + +val eventTypeOutputFile = File(currentFolder, "../EventType.kt") +eventTypeOutputFile.writeText( + eventTypeFileContent +) + +val webAppPartsString = webAppParts.joinToString("\n") +webAppParts.clear() +val webAppPartsFileContent = webAppPartsString +if (verboseMode) { + println(webAppPartsFileContent) +} + +val webAppOutputFile = File(currentFolder, "ToPutInWebApp!!!!!.kt") +webAppOutputFile.writeText( + webAppPartsFileContent +) + +val extensionsPartsString = extensionsParts.joinToString("\n") +extensionsParts.clear() +val extensionsPartsFileContent = "package dev.inmo.tgbotapi.webapps.events\n\n${extensionsPartsString}\n" +if (verboseMode) { + println(extensionsPartsFileContent) +} + +val extensionsPartsOutputFile = File(currentFolder, "Extensions.kt") +extensionsPartsOutputFile.writeText( + extensionsPartsFileContent +) + + +currentFolder.listFiles() ?.toList() ?.forEach { generatedFolder: File -> + if (generatedFolder.isDirectory) { + generatedFolder.deleteRecursively() + } +} diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/gyroscope/Gyroscope.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/gyroscope/Gyroscope.kt new file mode 100644 index 0000000000..45ba27a4cf --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/gyroscope/Gyroscope.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.webapps.gyroscope + +external interface Gyroscope { + val isStarted: Boolean + val x: Double + val y: Double + val z: Double + + fun start(params: GyroscopeStartParams, callback: (Boolean) -> Unit = definedExternally) + fun stop(callback: (Boolean) -> Unit) +} + diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/gyroscope/GyroscopeStartParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/gyroscope/GyroscopeStartParams.kt new file mode 100644 index 0000000000..abacf779c7 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/gyroscope/GyroscopeStartParams.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.webapps.gyroscope + +import dev.inmo.tgbotapi.types.MilliSeconds +import kotlin.js.json + +external interface GyroscopeStartParams { + @JsName("refresh_rate") + val refreshRate: MilliSeconds +} + +fun GyroscopeStartParams(refreshRate: MilliSeconds = 1000): GyroscopeStartParams = json( + "refresh_rate" to refreshRate +).unsafeCast() \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/invoice/InvoiceClosedInfo.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/invoice/InvoiceClosedInfo.kt index 39feb3087a..99605e1c8c 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/invoice/InvoiceClosedInfo.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/invoice/InvoiceClosedInfo.kt @@ -5,12 +5,15 @@ external interface InvoiceClosedInfo { val status: String } -val InvoiceClosedInfo.statusTyped - get() = when (status) { +val String.statusTyped + get() = when (this) { InvoiceStatus.Paid.name -> InvoiceStatus.Paid InvoiceStatus.Cancelled.name -> InvoiceStatus.Cancelled InvoiceStatus.Failed.name -> InvoiceStatus.Failed InvoiceStatus.Pending.name -> InvoiceStatus.Pending - else -> InvoiceStatus.Unknown(status) + else -> InvoiceStatus.Unknown(this) } +val InvoiceClosedInfo.statusTyped + get() = status.statusTyped + diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/location/LocationData.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/location/LocationData.kt new file mode 100644 index 0000000000..39a3c1984d --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/location/LocationData.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.webapps.location + +external interface LocationData { + val latitude: Double + val longitude: Double + val altitude: Double? + val course: Double? + val speed: Double? + @JsName("horizontal_accuracy") + val horizontalAccuracy: Double? + @JsName("vertical_accuracy") + val verticalAccuracy: Double? + @JsName("course_accuracy") + val courseAccuracy: Double? + @JsName("speed_accuracy") + val speedAccuracy: Double? +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/location/LocationManager.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/location/LocationManager.kt new file mode 100644 index 0000000000..47c94bfb0e --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/location/LocationManager.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.webapps.location + +external interface LocationManager { + val isInited: Boolean + + val isLocationAvailable: Boolean + val isAccessRequested: Boolean + val isAccessGranted: Boolean + + fun init(callback: () -> Unit = definedExternally) + + fun getLocation(callback: (location: LocationData) -> Unit) + + fun openSettings() +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/orientation/DeviceOrientation.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/orientation/DeviceOrientation.kt new file mode 100644 index 0000000000..f24fbe9d19 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/orientation/DeviceOrientation.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.webapps.orientation + +external interface DeviceOrientation { + val isStarted: Boolean + val absolute: Boolean + val alpha: Double + val beta: Double + val gamma: Double + + fun start(params: DeviceOrientationStartParams, callback: (Boolean) -> Unit = definedExternally) + fun stop(callback: (Boolean) -> Unit) +} + diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/orientation/DeviceOrientationStartParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/orientation/DeviceOrientationStartParams.kt new file mode 100644 index 0000000000..c93c191747 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/orientation/DeviceOrientationStartParams.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.webapps.orientation + +import dev.inmo.tgbotapi.types.MilliSeconds +import kotlin.js.json + +external interface DeviceOrientationStartParams { + @JsName("refresh_rate") + val refreshRate: MilliSeconds + @JsName("need_absolute") + val needAbsolute: Boolean +} + +fun DeviceOrientationStartParams( + refreshRate: MilliSeconds = 1000, + needAbsolute: Boolean = false +): DeviceOrientationStartParams = json( + "refresh_rate" to refreshRate, + "need_absolute" to needAbsolute +).unsafeCast() \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/popup/PopupClosedEventArg.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/popup/PopupClosedEventArg.kt new file mode 100644 index 0000000000..8af1013cfd --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/popup/PopupClosedEventArg.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.webapps.popup + +external interface PopupClosedEventArg { + @JsName("button_id") + val buttonId: String? +} \ No newline at end of file