1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-18 04:50:20 +00:00

Compare commits

...

52 Commits

Author SHA1 Message Date
6a3e95c488 fix in SendGift 2025-01-03 09:32:02 +06:00
a09b3809e2 update telegram bot api support badge 2025-01-03 09:29:15 +06:00
427b5775a2 add support of verification methods 2025-01-03 09:25:36 +06:00
d222987fc7 remove hide_url from InlineQueryResultArticle 2025-01-03 09:09:03 +06:00
d211afa26a add support of pay_for_upgrade and jvmApiDump 2025-01-03 09:01:17 +06:00
9952b6c6ae add upgrade_star_count to Gift and fix serialization of gift 2025-01-03 08:53:40 +06:00
840c6b02a4 start 23.1.0 2025-01-02 10:30:52 +06:00
a6f91d5600 Merge pull request #935 from InsanusMokrassar/renovate/validator
Update dependency org.jetbrains.kotlinx.binary-compatibility-validator to v0.17.0
2024-12-26 15:40:08 +06:00
8ec0c8804b update link to remote url in dokka 2024-12-26 09:05:11 +06:00
2d08c447bc Merge pull request #934 from InsanusMokrassar/23.0.0
23.0.0
2024-12-25 11:17:34 +06:00
9a0793d81c rename old strikethrough factory 2024-12-25 11:09:16 +06:00
a95f556a5c jvmApiDump 2024-12-21 10:27:15 +06:00
f774b11de4 update dependencies 2024-12-21 10:10:30 +06:00
renovate[bot]
5164903d05 Update dependency org.jetbrains.kotlinx.binary-compatibility-validator to v0.17.0 2024-12-19 19:18:44 +00:00
adaedb8040 text sources factories renames 2024-12-19 16:31:42 +06:00
9b4b60eb33 start 23.0.0 2024-12-19 16:30:31 +06:00
b90f8ec389 Merge pull request #928 from InsanusMokrassar/22.0.0
22.0.0
2024-12-08 13:34:11 +06:00
e95550a6eb rename subscriptionPayment 2024-12-08 13:24:34 +06:00
696219df24 add api methods for setUserEmojiStatus 2024-12-08 12:51:16 +06:00
27241fad32 add default for device orientation start 2024-12-08 11:40:09 +06:00
a034fa18d7 fixes in status info 2024-12-08 10:40:09 +06:00
adcaffe115 add sealed workaround for webapp event type 2024-12-08 10:26:53 +06:00
6388d8db13 make chat in WebAppInitData nullable 2024-12-08 10:17:02 +06:00
2964586cb9 add defaults to remove/set 2024-12-08 09:42:02 +06:00
e3cb1e4faf add definedExternally in CloudStorage 2024-12-08 09:16:56 +06:00
d7f14020d8 rename field of user id in SavePreparedInlineMessage 2024-12-07 10:48:06 +06:00
397197023e fix of serializer for result in SavePreparedInlineMessage 2024-12-07 10:31:28 +06:00
12dc93313a update dependencies 2024-12-06 13:20:01 +06:00
625760afae jvmApiDump 2024-12-06 13:01:01 +06:00
795328afdf add notes about breaking changes and update latest supported API version 2024-12-06 13:00:10 +06:00
57175b7698 add affiliate in TransactionPartner.User 2024-12-06 12:56:00 +06:00
2d05a334eb add support of AffiliateProgram in TransactionPartner 2024-12-06 12:39:04 +06:00
0b6d9e47b9 add support of nanostar_amount 2024-12-06 12:32:38 +06:00
4cdae11adc support of Ed25519TelegramKeys 2024-12-06 12:26:11 +06:00
04b2d1dbd6 jvmApiDump and fix of CreateInvoiceLink API bindings 2024-12-06 12:19:53 +06:00
4343d6d161 potentially complete events generator 2024-12-06 12:11:54 +06:00
6824f2c992 preparations for events generating 2024-12-06 10:23:06 +06:00
9cde4927ce refactor and fixes 2024-12-05 21:04:54 +06:00
819982473a start adding events generator 2024-12-05 18:00:39 +06:00
5559923339 add support of saving prepared messages 2024-12-05 16:25:20 +06:00
c7d08df3bf continue adding support of webapps updates 2024-12-05 16:07:46 +06:00
41a142addb support of accelerometer, gyroscope, location and orientation data 2024-12-05 15:49:07 +06:00
652765bf46 add support for subscriptions 2024-12-05 11:35:33 +06:00
32010cf1c7 replace isActive 2024-12-05 09:42:43 +06:00
1c6359f041 add a lot of things in web apps 2024-12-05 09:41:31 +06:00
4ac5e405ac add support for gifts 2024-12-05 09:09:40 +06:00
bc00e1f28a Merge branch 'master' into 22.0.0 2024-12-05 08:30:36 +06:00
191e4cff00 Merge pull request #929 from InsanusMokrassar/21.0.1
21.0.1
2024-12-03 11:09:01 +06:00
ad4bac82dc update versions 2024-12-01 20:04:34 +06:00
300be87ffd Merge branch 'master' into 22.0.0 2024-12-01 20:03:28 +06:00
05f46d08c8 Merge pull request #923 from InsanusMokrassar/21.0.0
21.0.0
2024-11-30 15:25:59 +06:00
4eb6fa7835 start 21.0.0 2024-11-25 14:40:40 +06:00
108 changed files with 4572 additions and 662 deletions

View File

@@ -1,5 +1,32 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 23.1.0
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 8.2](https://core.telegram.org/bots/api-changelog#january-1-2025)**
## 23.0.0
* `Version`:
* `Coroutines`: `1.9.0` -> `1.10.1`
* `MicroUtils`: `0.23.2` -> `0.24.0`
* `KSLog`: `1.3.6` -> `1.4.0`
* `Ktor`: `3.0.2` -> `3.0.3`
* `Core`:
* All old factory methods for `TextSource`s took suffix `TextSource`. For example: `regular` -> `regularTextSource`.
That has been for excluding names resolution ambiguity with extensions for `EntitiesBuilder`
## 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 ## 21.0.1
* `Core`: * `Core`:
@@ -20,9 +47,9 @@ due to its redundancy
* `BehaviourBuilder`: * `BehaviourBuilder`:
* Add special `val data: BehaviourContextData` into all realizations of `BehaviourContext` * Add special `val data: BehaviourContextData` into all realizations of `BehaviourContext`
* Add `CombinedSubcontextInitialAction` and functions * Add `CombinedSubcontextInitialAction` and functions
`buildSubcontextInitialAction`/`buildSubcontextInitialActionWithSubActions` `buildSubcontextInitialAction`/`buildSubcontextInitialActionWithSubActions`
* Add `subcontextInitialAction` for all the functions-builders of `BehaviourContext` and * Add `subcontextInitialAction` for all the functions-builders of `BehaviourContext` and
`additionalSubcontextInitialAction` to all triggers `additionalSubcontextInitialAction` to all triggers
## 20.0.1 ## 20.0.1

View File

@@ -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.2-blue)](https://core.telegram.org/bots/api-changelog#january-1-2025)
| 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) | | 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) |
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|

View File

@@ -55,7 +55,7 @@ Object callback = {
sourceLink { sourceLink {
localDirectory.set(file("../")) localDirectory.set(file("../"))
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/ktgbotapi/tree/master")) remoteUrl.set(new URL("https://github.com/InsanusMokrassar/ktgbotapi"))
remoteLineSuffix.set("#L") remoteLineSuffix.set("#L")
} }
} }

View File

@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true kotlin.incremental.js=true
library_group=dev.inmo library_group=dev.inmo
library_version=21.0.1 library_version=23.1.0

View File

@@ -2,26 +2,26 @@
kotlin = "2.1.0" kotlin = "2.1.0"
kotlin-serialization = "1.7.3" kotlin-serialization = "1.7.3"
kotlin-coroutines = "1.9.0" kotlin-coroutines = "1.10.1"
javax-activation = "1.1.1" javax-activation = "1.1.1"
korlibs = "5.4.0" korlibs = "5.4.0"
uuid = "0.8.4" uuid = "0.8.4"
ktor = "3.0.1" ktor = "3.0.3"
ksp = "2.1.0-1.0.29" ksp = "2.1.0-1.0.29"
kotlin-poet = "1.18.1" kotlin-poet = "1.18.1"
microutils = "0.23.1" microutils = "0.24.0"
kslog = "1.3.6" kslog = "1.4.0"
versions = "0.51.0" versions = "0.51.0"
github-release-plugin = "2.5.2" github-release-plugin = "2.5.2"
dokka = "1.9.20" dokka = "2.0.0"
validator = "0.16.3" validator = "0.17.0"
[libraries] [libraries]
@@ -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-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-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-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" } kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip

View File

@@ -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 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 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 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; 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,36 @@ 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 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;ZLkotlin/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;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift$default (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;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun sendGift$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-0SDnvgk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-0SDnvgk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-1FWvrZc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-1FWvrZc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-CrS58cM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-CrS58cM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-GROm3fU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-VjR9mJc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-ySMgKnk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-ySMgKnk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)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 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;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; 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 +2160,9 @@ public final class dev/inmo/tgbotapi/extensions/api/send/media/SendVoiceKt {
public final class dev/inmo/tgbotapi/extensions/api/send/payments/CreateInvoiceLinkKt { 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/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/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 { public final class dev/inmo/tgbotapi/extensions/api/send/payments/RefundStarPaymentKt {
@@ -2172,6 +2211,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 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 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;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; 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;
@@ -2271,6 +2319,20 @@ public final class dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandlingKt {
public static synthetic fun updateHandlerWithMediaGroupsAdaptation$default (Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;JILjava/lang/Object;)Lkotlin/jvm/functions/Function2; public static synthetic fun updateHandlerWithMediaGroupsAdaptation$default (Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;JILjava/lang/Object;)Lkotlin/jvm/functions/Function2;
} }
public final class dev/inmo/tgbotapi/extensions/api/verifications/VerifyChatKt {
public static final fun verifyChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun verifyChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun verifyChat$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun verifyChat$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/verifications/VerifyUserKt {
public static final fun verifyUser (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun verifyUser$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun verifyUser-nc95W0g (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun verifyUser-nc95W0g$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhookKt { public final class dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhookKt {
public static final fun deleteWebhook (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun deleteWebhook (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
} }

View File

@@ -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
)

View File

@@ -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)

View File

@@ -0,0 +1,119 @@
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?,
upgradableToUnique: Boolean = false
): Boolean = execute(
SendGift(
userId = userId,
giftId = giftId,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
)
public suspend fun TelegramBot.sendGift(
userId: UserId,
giftId: GiftId,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = execute(
SendGift(
userId = userId,
giftId = giftId,
textSources = textSources,
upgradableToUnique = upgradableToUnique
)
)
public suspend fun TelegramBot.sendGift(
user: User,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = sendGift(
userId = user.id,
giftId = giftId,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: User,
giftId: GiftId,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = sendGift(
userId = user.id,
giftId = giftId,
textSources = textSources,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: UserId,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = sendGift(
userId = user,
giftId = gift.id,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: UserId,
gift: Gift,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = sendGift(
userId = user,
giftId = gift.id,
textSources = textSources,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = sendGift(
userId = user.id,
giftId = gift.id,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = sendGift(
userId = user.id,
giftId = gift.id,
textSources = textSources,
upgradableToUnique = upgradableToUnique
)

View File

@@ -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
)

View File

@@ -2,9 +2,11 @@ package dev.inmo.tgbotapi.extensions.api.send.payments
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink 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.LabeledPrice
import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.payments.abstracts.XTR import dev.inmo.tgbotapi.types.payments.abstracts.XTR
import korlibs.time.TimeSpan
public suspend fun TelegramBot.createInvoiceLink( public suspend fun TelegramBot.createInvoiceLink(
title: String, title: String,
@@ -24,7 +26,25 @@ public suspend fun TelegramBot.createInvoiceLink(
shouldSendEmailToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false,
priceDependOnShipAddress: Boolean = false priceDependOnShipAddress: Boolean = false
): String = execute( ): 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, description: String,
payload: String, payload: String,
prices: List<LabeledPrice>, prices: List<LabeledPrice>,
businessConnectionId: BusinessConnectionId? = null,
subscriptionPeriod: TimeSpan? = null,
maxTipAmount: Int? = null, maxTipAmount: Int? = null,
suggestedTipAmounts: List<Int>? = null, suggestedTipAmounts: List<Int>? = null,
providerData: String? = null, providerData: String? = null,
@@ -46,5 +68,24 @@ public suspend fun TelegramBot.createInvoiceLink(
shouldSendEmailToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false,
priceDependOnShipAddress: Boolean = false priceDependOnShipAddress: Boolean = false
): String = execute( ): 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
)
) )

View File

@@ -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
)

View File

@@ -0,0 +1,39 @@
package dev.inmo.tgbotapi.extensions.api.verifications
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.verifications.VerifyChat
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.customDescriptionField
import kotlinx.serialization.SerialName
public suspend fun TelegramBot.verifyChat(
chatId: ChatIdentifier,
description: String? = null
): Boolean = execute(
VerifyChat(
chatId = chatId,
description = description
)
)
/**
* This method may call [verifyUser] in case when [chat] is [PrivateChat]
*/
public suspend fun TelegramBot.verifyChat(
chat: Chat,
description: String? = null
): Boolean = when (chat) {
is PrivateChat -> verifyUser(
chat = chat,
description = description
)
is UnknownExtendedChat,
is UnknownChatType,
is BusinessChat,
is PublicChat -> verifyChat(
chatId = chat.id,
description = description
)
}

View File

@@ -0,0 +1,26 @@
package dev.inmo.tgbotapi.extensions.api.verifications
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.verifications.VerifyChat
import dev.inmo.tgbotapi.requests.verifications.VerifyUser
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.Chat
import kotlinx.serialization.SerialName
public suspend fun TelegramBot.verifyUser(
userId: UserId,
description: String? = null
): Boolean = execute(
VerifyUser(
userId = userId,
description = description
)
)
public suspend fun TelegramBot.verifyUser(
chat: Chat,
description: String? = null
): Boolean = verifyUser(
userId = chat.id.toChatId(),
description = description
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.abstracts.types
import korlibs.time.TimeSpan
interface SubscriptionInfo : SubscriptionPeriodInfo {
val subscriptionPrice: UInt?
}

View File

@@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.abstracts.types
import korlibs.time.TimeSpan
interface SubscriptionPeriodInfo {
val subscriptionPeriod: TimeSpan?
}

View File

@@ -9,17 +9,14 @@ import dev.inmo.tgbotapi.bot.exceptions.newRequestException
import dev.inmo.tgbotapi.requests.GetUpdatesRequest import dev.inmo.tgbotapi.requests.GetUpdatesRequest
import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.Response import dev.inmo.tgbotapi.types.Response
import dev.inmo.tgbotapi.types.message.textsources.pre
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.plugins.timeout import io.ktor.client.plugins.timeout
import io.ktor.client.request.* import io.ktor.client.request.*
import io.ktor.client.request.forms.*
import io.ktor.client.statement.bodyAsText import io.ktor.client.statement.bodyAsText
import io.ktor.http.ContentType import io.ktor.http.ContentType
import io.ktor.http.content.* import io.ktor.http.content.*
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlin.collections.set import kotlin.collections.set

View File

@@ -1,5 +1,7 @@
package dev.inmo.tgbotapi.requests.chat.invite_links 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 korlibs.time.DateTime
import dev.inmo.tgbotapi.requests.chat.abstracts.* import dev.inmo.tgbotapi.requests.chat.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
@@ -15,9 +17,9 @@ sealed interface CreateChatInviteLink<R : SecondaryChatInviteLink> : EditChatInv
override fun method(): String = "createChatInviteLink" override fun method(): String = "createChatInviteLink"
sealed interface Subscription : CreateChatInviteLink<ChatInviteLinkUnlimited> { sealed interface Subscription : CreateChatInviteLink<ChatInviteLinkUnlimited>, SubscriptionInfo {
val subscriptionPeriod: TimeSpan override val subscriptionPeriod: TimeSpan
val subscriptionPrice: UInt override val subscriptionPrice: UInt
override fun method(): String = "createChatSubscriptionInviteLink" override fun method(): String = "createChatSubscriptionInviteLink"
} }

View File

@@ -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<Boolean> {
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "editUserStarSubscription"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
}

View File

@@ -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<Gifts> {
override fun method(): String = "getAvailableGifts"
override val resultDeserializer: DeserializationStrategy<Gifts>
get() = Gifts.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,75 @@
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<RawMessageEntity>? = null,
@SerialName(payToUpgradeField)
val upgradableToUnique: Boolean = false
) : SimpleRequest<Boolean>, 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<Boolean>
get() = Boolean.serializer()
constructor(
userId: UserId,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
) : this(
userId = userId,
giftId = giftId,
text = text,
parseMode = parseMode,
rawEntities = null,
upgradableToUnique = upgradableToUnique
)
constructor(
userId: UserId,
giftId: GiftId,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
) : this(
userId = userId,
giftId = giftId,
text = textSources.makeSourceString(),
parseMode = null,
rawEntities = textSources.toRawMessageEntities(),
upgradableToUnique = upgradableToUnique
)
}

View File

@@ -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<PreparedInlineMessage> {
override fun method(): String = "savePreparedInlineMessage"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override val resultDeserializer: DeserializationStrategy<PreparedInlineMessage>
get() = PreparedInlineMessage.serializer()
}

View File

@@ -3,8 +3,8 @@ package dev.inmo.tgbotapi.requests.send.payments
import dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData import dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData
import dev.inmo.tgbotapi.abstracts.types.* import dev.inmo.tgbotapi.abstracts.types.*
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest 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.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.InvoiceContent 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.LabeledPricesSerializer
import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.payments.abstracts.XTR import dev.inmo.tgbotapi.types.payments.abstracts.XTR
import dev.inmo.tgbotapi.utils.TimeSpanAsSecondsSerializer
import korlibs.time.TimeSpan
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer import kotlinx.serialization.builtins.serializer
@@ -30,9 +32,14 @@ data class CreateInvoiceLink(
override val providerToken: String?, override val providerToken: String?,
@SerialName(currencyField) @SerialName(currencyField)
override val currency: Currency, override val currency: Currency,
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId? = null,
@Serializable(LabeledPricesSerializer::class) @Serializable(LabeledPricesSerializer::class)
@SerialName(pricesField) @SerialName(pricesField)
override val prices: List<LabeledPrice>, override val prices: List<LabeledPrice>,
@SerialName(subscriptionPeriodField)
@Serializable(TimeSpanAsSecondsSerializer::class)
override val subscriptionPeriod: TimeSpan? = null,
@SerialName(maxTipAmountField) @SerialName(maxTipAmountField)
override val maxTipAmount: Int? = null, override val maxTipAmount: Int? = null,
@SerialName(suggestedTipAmountsField) @SerialName(suggestedTipAmountsField)
@@ -53,7 +60,7 @@ data class CreateInvoiceLink(
override val shouldSendEmailToProvider: Boolean = false, override val shouldSendEmailToProvider: Boolean = false,
@SerialName(priceDependOnShipAddressField) @SerialName(priceDependOnShipAddressField)
override val priceDependOnShipAddress: Boolean = false override val priceDependOnShipAddress: Boolean = false
) : CommonSendInvoiceData, SimpleRequest<String> { ) : CommonSendInvoiceData, SimpleRequest<String>, WithOptionalBusinessConnectionId, SubscriptionPeriodInfo {
override fun method(): String = "createInvoiceLink" override fun method(): String = "createInvoiceLink"
override val resultDeserializer: DeserializationStrategy<String> override val resultDeserializer: DeserializationStrategy<String>
get() = String.serializer() get() = String.serializer()
@@ -137,4 +144,8 @@ data class CreateInvoiceLink(
photoWidth = null photoWidth = null
photoHeight = null photoHeight = null
} }
companion object {
const val DEFAULT: Seconds = 2592000 // 30 days
}
} }

View File

@@ -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<Boolean> {
override fun method(): String = "setUserEmojiStatus"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
}

View File

@@ -0,0 +1,23 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
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 RemoveChatVerification(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "removeChatVerification"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,23 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
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 RemoveUserVerification(
@SerialName(userIdField)
val userId: UserId,
): SimpleRequest<Boolean> {
override fun method(): String = "removeUserVerification"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,28 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.customDescriptionField
import dev.inmo.tgbotapi.types.descriptionField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class VerifyChat(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(customDescriptionField)
val description: String? = null
): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "verifyChat"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,25 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
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 VerifyUser(
@SerialName(userIdField)
val userId: UserId,
@SerialName(customDescriptionField)
val description: String? = null
): SimpleRequest<Boolean> {
override fun method(): String = "verifyUser"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -2,8 +2,12 @@ package dev.inmo.tgbotapi.types
import korlibs.time.DateTime import korlibs.time.DateTime
import dev.inmo.tgbotapi.abstracts.WithUser 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.types.chat.User
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.TimeSpanAsSecondsSerializer
import korlibs.time.TimeSpan
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
@@ -64,7 +68,7 @@ sealed interface ChatInviteLink : WithUser {
* Base interface for all [ChatInviteLink]s which are NOT [PrimaryInviteLink] * Base interface for all [ChatInviteLink]s which are NOT [PrimaryInviteLink]
*/ */
@Serializable(ChatInviteLinkSerializer::class) @Serializable(ChatInviteLinkSerializer::class)
sealed interface SecondaryChatInviteLink : ChatInviteLink { sealed interface SecondaryChatInviteLink : ChatInviteLink, SubscriptionInfo {
override val isPrimary: Boolean override val isPrimary: Boolean
get() = false get() = false
} }
@@ -108,7 +112,12 @@ data class ChatInviteLinkWithJoinRequest(
@SerialName(isRevokedField) @SerialName(isRevokedField)
override val isRevoked: Boolean = false, override val isRevoked: Boolean = false,
@SerialName(expireDateField) @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 { ) : SecondaryChatInviteLink {
override val expirationDateTime: DateTime? override val expirationDateTime: DateTime?
get() = expireDate ?.asDate get() = expireDate ?.asDate
@@ -131,6 +140,11 @@ data class ChatInviteLinkWithLimitedMembers(
override val isRevoked: Boolean = false, override val isRevoked: Boolean = false,
@SerialName(expireDateField) @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 { ) : SecondaryChatInviteLink {
override val expirationDateTime: DateTime? override val expirationDateTime: DateTime?
get() = expireDate ?.asDate get() = expireDate ?.asDate
@@ -152,6 +166,11 @@ data class ChatInviteLinkUnlimited(
override val isRevoked: Boolean = false, override val isRevoked: Boolean = false,
@SerialName(expireDateField) @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 { ) : SecondaryChatInviteLink {
override val expirationDateTime: DateTime? override val expirationDateTime: DateTime?
get() = expireDate ?.asDate get() = expireDate ?.asDate

View File

@@ -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 usernameRegex = Regex("@[\\w\\d_]+")
val degreesLimit = 1 .. 360 val degreesLimit = 1 .. 360
@@ -190,6 +202,7 @@ const val maskPositionField = "mask_position"
const val phoneNumberField = "phone_number" const val phoneNumberField = "phone_number"
const val userIdField = "user_id" const val userIdField = "user_id"
const val userIdsField = "user_ids" const val userIdsField = "user_ids"
const val giftIdField = "gift_id"
const val onlyIfBannedField = "only_if_banned" const val onlyIfBannedField = "only_if_banned"
const val containsMasksField = "contains_masks" const val containsMasksField = "contains_masks"
const val resultIdField = "result_id" const val resultIdField = "result_id"
@@ -414,6 +427,7 @@ const val emojiField = "emoji"
const val emojisField = "emojis" const val emojisField = "emojis"
const val titleField = "title" const val titleField = "title"
const val descriptionField = "description" const val descriptionField = "description"
const val customDescriptionField = "custom_description"
const val shortDescriptionField = "short_description" const val shortDescriptionField = "short_description"
const val performerField = "performer" const val performerField = "performer"
const val durationField = "duration" const val durationField = "duration"
@@ -454,6 +468,7 @@ const val actionField = "action"
const val positionField = "position" const val positionField = "position"
const val labelField = "label" const val labelField = "label"
const val amountField = "amount" const val amountField = "amount"
const val nanostarAmountField = "nanostar_amount"
const val pricesField = "prices" const val pricesField = "prices"
const val payloadField = "payload" const val payloadField = "payload"
const val vcardField = "vcard" const val vcardField = "vcard"
@@ -472,6 +487,8 @@ const val creatorField = "creator"
const val subscriptionPeriodField = "subscription_period" const val subscriptionPeriodField = "subscription_period"
const val subscriptionPriceField = "subscription_price" const val subscriptionPriceField = "subscription_price"
const val copyTextField = "copy_text" const val copyTextField = "copy_text"
const val giftField = "gift"
const val giftsField = "gifts"
const val pointField = "point" const val pointField = "point"
const val xShiftField = "x_shift" const val xShiftField = "x_shift"
@@ -504,6 +521,11 @@ const val startParameterField = "start_parameter"
const val totalAmountField = "total_amount" const val totalAmountField = "total_amount"
const val invoicePayloadField = "invoice_payload" const val invoicePayloadField = "invoice_payload"
const val requestCountField = "request_count" 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 paidMediaPayloadField = "paid_media_payload"
const val shippingOptionIdField = "shipping_option_id" const val shippingOptionIdField = "shipping_option_id"
const val shippingQueryIdField = "shipping_query_id" const val shippingQueryIdField = "shipping_query_id"
@@ -512,6 +534,7 @@ const val shippingOptionsField = "shipping_options"
const val countryCodeField = "country_code" const val countryCodeField = "country_code"
const val countryCodesField = "country_codes" const val countryCodesField = "country_codes"
const val totalCountField = "total_count" const val totalCountField = "total_count"
const val remainingCountField = "remaining_count"
const val stateField = "state" const val stateField = "state"
const val cityField = "city" const val cityField = "city"
const val firstStreetLineField = "street_line1" const val firstStreetLineField = "street_line1"
@@ -519,7 +542,11 @@ const val secondStreetLineField = "street_line2"
const val postCodeField = "post_code" const val postCodeField = "post_code"
const val shippingAddressField = "shipping_address" const val shippingAddressField = "shipping_address"
const val orderInfoField = "order_info" 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 telegramPaymentChargeIdField = "telegram_payment_charge_id"
const val isCanceledField = "is_canceled"
const val providerPaymentChargeIdField = "provider_payment_charge_id" const val providerPaymentChargeIdField = "provider_payment_charge_id"
const val providerTokenField = "provider_token" const val providerTokenField = "provider_token"
const val providerDataField = "provider_data" const val providerDataField = "provider_data"
@@ -628,6 +655,8 @@ const val giveawayMessageField = "giveaway_message"
const val wasRefundedField = "was_refunded" const val wasRefundedField = "was_refunded"
const val isManualField = "is_manual" const val isManualField = "is_manual"
const val starCountField = "star_count" const val starCountField = "star_count"
const val upgradeStarCountField = "upgrade_star_count"
const val payToUpgradeField = "pay_for_upgrade"
const val paidMediaField = "paid_media" const val paidMediaField = "paid_media"
const val businessConnectionIdField = "business_connection_id" const val businessConnectionIdField = "business_connection_id"

View File

@@ -19,8 +19,6 @@ class InlineQueryResultArticle(
override val replyMarkup: InlineKeyboardMarkup? = null, override val replyMarkup: InlineKeyboardMarkup? = null,
@SerialName(urlField) @SerialName(urlField)
override val url: String? = null, override val url: String? = null,
@SerialName(hideUrlField)
val hideUrl: Boolean? = null,
@SerialName(descriptionField) @SerialName(descriptionField)
override val description: String? = null, override val description: String? = null,
@SerialName(thumbnailUrlField) @SerialName(thumbnailUrlField)
@@ -36,4 +34,31 @@ class InlineQueryResultArticle(
WithInputMessageContentInlineQueryResult, WithInputMessageContentInlineQueryResult,
UrlInlineQueryResult { UrlInlineQueryResult {
override val type: String = "article" override val type: String = "article"
@Deprecated("Field hide_url has been deprecated in Bot API 8.2. Use empty url instead")
val hideUrl: Boolean
get() = url != null && url.isEmpty()
@Deprecated("Field hide_url has been deprecated in Bot API 8.2. Use empty url instead")
constructor(
id: InlineQueryId,
title: String,
inputMessageContent: InputMessageContent,
replyMarkup: InlineKeyboardMarkup? = null,
url: String? = null,
hideUrl: Boolean?,
description: String? = null,
thumbnailUrl: String? = null,
thumbnailWidth: Int? = null,
thumbnailHeight: Int? = null
) : this(
id = id,
title = title,
inputMessageContent = inputMessageContent,
replyMarkup = replyMarkup,
url = url,
description = description,
thumbnailUrl = thumbnailUrl,
thumbnailWidth = thumbnailWidth,
thumbnailHeight = thumbnailHeight
)
} }

View File

@@ -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,
)

View File

@@ -0,0 +1,102 @@
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 upgradeStarCount: 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,
@SerialName(upgradeStarCountField)
override val upgradeStarCount: Int? = null
) : 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,
@SerialName(upgradeStarCountField)
override val upgradeStarCount: Int? = null,
) : Gift
companion object : KSerializer<Gift> {
@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,
val upgrade_star_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(
id = surrogate.id,
sticker = surrogate.sticker,
starCount = surrogate.star_count,
totalCount = surrogate.total_count,
remainingCount = surrogate.remaining_count,
upgradeStarCount = surrogate.upgrade_star_count,
)
} else {
Unlimited(
id = surrogate.id,
sticker = surrogate.sticker,
starCount = surrogate.star_count,
upgradeStarCount = surrogate.upgrade_star_count,
)
}
}
override fun serialize(encoder: Encoder, value: Gift) {
val surrogate = GiftSurrogate(
id = value.id,
sticker = value.sticker,
star_count = value.starCount,
total_count = value.totalCount,
remaining_count = value.remainingCount,
upgrade_star_count = value.upgradeStarCount
)
GiftSurrogate.serializer().serialize(encoder, surrogate)
}
}
}

View File

@@ -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<Gift>
)

View File

@@ -1,13 +1,10 @@
package dev.inmo.tgbotapi.types.message package dev.inmo.tgbotapi.types.message
import dev.inmo.micro_utils.common.Warning import dev.inmo.micro_utils.common.Warning
import dev.inmo.micro_utils.serialization.mapper.MapperSerializer
import dev.inmo.tgbotapi.types.CustomEmojiId import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.textsources.* import dev.inmo.tgbotapi.types.message.textsources.*
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.ListSerializer
@Serializable @Serializable
@Warning("This thing is subject of changes. Library do not guarantee stability of this class") @Warning("This thing is subject of changes. Library do not guarantee stability of this class")
@@ -102,7 +99,7 @@ internal fun List<Pair<Int, TextSource>>.fillWithRegulars(source: String): TextS
for (i in indices) { for (i in indices) {
val (offset, textSource) = get(i) val (offset, textSource) = get(i)
if (offset - index > 0) { if (offset - index > 0) {
result.add(regular(source.substring(index, offset))) result.add(regularTextSource(source.substring(index, offset)))
index = offset index = offset
} }
result.add(textSource) result.add(textSource)
@@ -110,7 +107,7 @@ internal fun List<Pair<Int, TextSource>>.fillWithRegulars(source: String): TextS
} }
if (index != source.length) { if (index != source.length) {
result.add(regular(source.substring(index, source.length))) result.add(regularTextSource(source.substring(index, source.length)))
} }
return result return result

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see blockquote * @see blockquoteTextSource
*/ */
@Serializable @Serializable
data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,6 +18,6 @@ data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
override val html: String by lazy { blockquoteHTML() } override val html: String by lazy { blockquoteHTML() }
} }
inline fun blockquote(parts: TextSourcesList) = BlockquoteTextSource(parts.makeString(), parts) inline fun blockquoteTextSource(parts: TextSourcesList) = BlockquoteTextSource(parts.makeString(), parts)
inline fun blockquote(vararg parts: TextSource) = blockquote(parts.toList()) inline fun blockquoteTextSource(vararg parts: TextSource) = blockquoteTextSource(parts.toList())
inline fun blockquote(text: String) = blockquote(regular(text)) inline fun blockquoteTextSource(text: String) = blockquoteTextSource(regularTextSource(text))

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see bold * @see boldTextSource
*/ */
@Serializable @Serializable
data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,6 +18,6 @@ data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
override val html: String by lazy { boldHTML() } override val html: String by lazy { boldHTML() }
} }
inline fun bold(parts: TextSourcesList) = BoldTextSource(parts.makeString(), parts) inline fun boldTextSource(parts: TextSourcesList) = BoldTextSource(parts.makeString(), parts)
inline fun bold(vararg parts: TextSource) = bold(parts.toList()) inline fun boldTextSource(vararg parts: TextSource) = boldTextSource(parts.toList())
inline fun bold(text: String) = bold(regular(text)) inline fun boldTextSource(text: String) = boldTextSource(regularTextSource(text))

View File

@@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see botCommand * @see botCommandTextSource
*/ */
@Serializable @Serializable
data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -33,6 +33,6 @@ data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
/** /**
* @param command Without leading "/" * @param command Without leading "/"
*/ */
inline fun botCommand(command: String) = BotCommandTextSource("/$command") inline fun botCommandTextSource(command: String) = BotCommandTextSource("/$command")
inline fun botCommand(botCommand: BotCommand) = botCommand(botCommand.command) inline fun botCommandTextSource(botCommand: BotCommand) = botCommandTextSource(botCommand.command)

View File

@@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see cashTag * @see cashTagTextSource
*/ */
@Serializable @Serializable
data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -25,6 +25,6 @@ data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
override val html: String by lazy { cashTagHTML() } override val html: String by lazy { cashTagHTML() }
} }
inline fun cashTag(parts: TextSourcesList) = CashTagTextSource(parts.makeString(), parts) inline fun cashTagTextSource(parts: TextSourcesList) = CashTagTextSource(parts.makeString(), parts)
inline fun cashTag(vararg parts: TextSource) = cashTag(parts.toList()) inline fun cashTagTextSource(vararg parts: TextSource) = cashTagTextSource(parts.toList())
inline fun cashTag(tag: String) = cashTag(regular(tag)) inline fun cashTagTextSource(tag: String) = cashTagTextSource(regularTextSource(tag))

View File

@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see code * @see codeTextSource
*/ */
@Serializable @Serializable
data class CodeTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class CodeTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -16,4 +16,4 @@ data class CodeTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
override val html: String by lazy { source.codeHTML() } override val html: String by lazy { source.codeHTML() }
} }
inline fun code(code: String) = CodeTextSource(code) inline fun codeTextSource(code: String) = CodeTextSource(code)

View File

@@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see customEmoji * @see customEmojiTextSource
*/ */
@Serializable @Serializable
data class CustomEmojiTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class CustomEmojiTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -21,9 +21,9 @@ data class CustomEmojiTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
} }
@Suppress("EXPERIMENTAL_API_USAGE") @Suppress("EXPERIMENTAL_API_USAGE")
inline fun customEmoji(emojiId: CustomEmojiId, parts: TextSourcesList) = CustomEmojiTextSource(parts.makeString(), emojiId, parts) inline fun customEmojiTextSource(emojiId: CustomEmojiId, parts: TextSourcesList) = CustomEmojiTextSource(parts.makeString(), emojiId, parts)
inline fun customEmoji(emojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(emojiId, parts.toList()) inline fun customEmojiTextSource(emojiId: CustomEmojiId, vararg parts: TextSource) = customEmojiTextSource(emojiId, parts.toList())
/** /**
* Without sharp (#) * Without sharp (#)
*/ */
inline fun customEmoji(emojiId: CustomEmojiId, text: String) = customEmoji(emojiId, regular(text)) inline fun customEmojiTextSource(emojiId: CustomEmojiId, text: String) = customEmojiTextSource(emojiId, regularTextSource(text))

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see email * @see emailTextSource
*/ */
@Serializable @Serializable
data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,6 +18,6 @@ data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
override val html: String by lazy { emailHTML(source) } override val html: String by lazy { emailHTML(source) }
} }
inline fun email(parts: TextSourcesList) = EMailTextSource(parts.makeString(), parts) inline fun emailTextSource(parts: TextSourcesList) = EMailTextSource(parts.makeString(), parts)
inline fun email(vararg parts: TextSource) = email(parts.toList()) inline fun emailTextSource(vararg parts: TextSource) = emailTextSource(parts.toList())
inline fun email(emailAddress: String) = email(regular(emailAddress)) inline fun emailTextSource(emailAddress: String) = emailTextSource(regularTextSource(emailAddress))

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see expandableBlockquote * @see expandableBlockquoteTextSource
*/ */
@Serializable @Serializable
data class ExpandableBlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class ExpandableBlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,6 +18,6 @@ data class ExpandableBlockquoteTextSource @RiskFeature(DirectInvocationOfTextSou
override val html: String by lazy { expandableBlockquoteHTML() } override val html: String by lazy { expandableBlockquoteHTML() }
} }
inline fun expandableBlockquote(parts: TextSourcesList) = ExpandableBlockquoteTextSource(parts.makeString(), parts) inline fun expandableBlockquoteTextSource(parts: TextSourcesList) = ExpandableBlockquoteTextSource(parts.makeString(), parts)
inline fun expandableBlockquote(vararg parts: TextSource) = expandableBlockquote(parts.toList()) inline fun expandableBlockquoteTextSource(vararg parts: TextSource) = expandableBlockquoteTextSource(parts.toList())
inline fun expandableBlockquote(text: String) = expandableBlockquote(regular(text)) inline fun expandableBlockquoteTextSource(text: String) = expandableBlockquoteTextSource(regularTextSource(text))

View File

@@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see hashtag * @see hashtagTextSource
*/ */
@Serializable @Serializable
data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -33,9 +33,9 @@ data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
} }
@Suppress("EXPERIMENTAL_API_USAGE") @Suppress("EXPERIMENTAL_API_USAGE")
inline fun hashtag(parts: TextSourcesList) = (regular("#") + parts).let { HashTagTextSource(it.makeString(), it) } inline fun hashtagTextSource(parts: TextSourcesList) = (regularTextSource("#") + parts).let { HashTagTextSource(it.makeString(), it) }
inline fun hashtag(vararg parts: TextSource) = hashtag(parts.toList()) inline fun hashtagTextSource(vararg parts: TextSource) = hashtagTextSource(parts.toList())
/** /**
* Without sharp (#) * Without sharp (#)
*/ */
inline fun hashtag(hashtag: String) = hashtag(regular(hashtag)) inline fun hashtagTextSource(hashtag: String) = hashtagTextSource(regularTextSource(hashtag))

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see italic * @see italicTextSource
*/ */
@Serializable @Serializable
data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,7 +18,7 @@ data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor
override val html: String by lazy { italicHTML() } override val html: String by lazy { italicHTML() }
} }
inline fun italic(parts: TextSourcesList) = ItalicTextSource(parts.makeString(), parts) inline fun italicTextSource(parts: TextSourcesList) = ItalicTextSource(parts.makeString(), parts)
inline fun italic(vararg parts: TextSource) = italic(parts.toList()) inline fun italicTextSource(vararg parts: TextSource) = italicTextSource(parts.toList())
inline fun italic(text: String) = italic(regular(text)) inline fun italicTextSource(text: String) = italicTextSource(regularTextSource(text))

View File

@@ -14,7 +14,7 @@ private val String.withoutCommercialAt
} }
/** /**
* @see mention * @see mentionTextSource
*/ */
@Serializable @Serializable
data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -33,13 +33,13 @@ data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
} }
} }
inline fun mention(parts: TextSourcesList) = (regular("@") + parts).let { MentionTextSource(it.makeString(), it) } inline fun mentionTextSource(parts: TextSourcesList) = (regularTextSource("@") + parts).let { MentionTextSource(it.makeString(), it) }
inline fun mention(vararg parts: TextSource) = mention(parts.toList()) inline fun mentionTextSource(vararg parts: TextSource) = mentionTextSource(parts.toList())
/** /**
* Without leading "@" * Without leading "@"
*/ */
inline fun mention(whoToMention: String) = mention(regular(whoToMention)) inline fun mentionTextSource(whoToMention: String) = mentionTextSource(regularTextSource(whoToMention))
inline fun mention(whoToMention: Username) = mention(whoToMention.full.dropWhile { it == '@' }) inline fun mentionTextSource(whoToMention: Username) = mentionTextSource(whoToMention.full.dropWhile { it == '@' })

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see phone * @see phoneTextSource
*/ */
@Serializable @Serializable
data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,7 +18,7 @@ data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
override val html: String by lazy { phoneHTML() } override val html: String by lazy { phoneHTML() }
} }
inline fun phone(parts: TextSourcesList) = PhoneNumberTextSource(parts.makeString(), parts) inline fun phoneTextSource(parts: TextSourcesList) = PhoneNumberTextSource(parts.makeString(), parts)
inline fun phone(vararg parts: TextSource) = phone(parts.toList()) inline fun phoneTextSource(vararg parts: TextSource) = phoneTextSource(parts.toList())
inline fun phone(number: String) = phone(regular(number)) inline fun phoneTextSource(number: String) = phoneTextSource(regularTextSource(number))

View File

@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see pre * @see preTextSource
*/ */
@Serializable @Serializable
data class PreTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class PreTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -17,5 +17,5 @@ data class PreTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) c
override val html: String by lazy { source.preHTML(language) } override val html: String by lazy { source.preHTML(language) }
} }
inline fun pre(code: String, language: String? = null) = PreTextSource(code, language) inline fun preTextSource(code: String, language: String? = null) = PreTextSource(code, language)

View File

@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see regular * @see regularTextSource
*/ */
@Serializable @Serializable
data class RegularTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class RegularTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -16,6 +16,6 @@ data class RegularTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
override val html: String by lazy { source.regularHtml() } override val html: String by lazy { source.regularHtml() }
} }
inline fun regular(text: String) = RegularTextSource(text) inline fun regularTextSource(text: String) = RegularTextSource(text)
inline fun regularln(text: String) = regular("$text\n") inline fun regularTextSourceLn(text: String) = regularTextSource("$text\n")

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see italic * @see italicTextSource
*/ */
@Serializable @Serializable
data class SpoilerTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class SpoilerTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,7 +18,7 @@ data class SpoilerTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
override val html: String by lazy { spoilerHTML() } override val html: String by lazy { spoilerHTML() }
} }
inline fun spoiler(parts: TextSourcesList) = SpoilerTextSource(parts.makeString(), parts) inline fun spoilerTextSource(parts: TextSourcesList) = SpoilerTextSource(parts.makeString(), parts)
inline fun spoiler(vararg parts: TextSource) = spoiler(parts.toList()) inline fun spoilerTextSource(vararg parts: TextSource) = spoilerTextSource(parts.toList())
inline fun spoiler(text: String) = spoiler(regular(text)) inline fun spoilerTextSource(text: String) = spoilerTextSource(regularTextSource(text))

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see strikethrough * @see strikethroughTextSource
*/ */
@Serializable @Serializable
data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,6 +18,6 @@ data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceCons
override val markdown: String by lazy { source.strikethroughMarkdown() } override val markdown: String by lazy { source.strikethroughMarkdown() }
} }
inline fun strikethrough(parts: TextSourcesList) = StrikethroughTextSource(parts.makeString(), parts) inline fun strikethroughTextSource(parts: TextSourcesList) = StrikethroughTextSource(parts.makeString(), parts)
inline fun strikethrough(vararg parts: TextSource) = strikethrough(parts.toList()) inline fun strikethroughTextSource(vararg parts: TextSource) = strikethroughTextSource(parts.toList())
inline fun strikethrough(text: String) = strikethrough(regular(text)) inline fun strikethroughTextSource(text: String) = strikethroughTextSource(regularTextSource(text))

View File

@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see link * @see linkTextSource
*/ */
@Serializable @Serializable
data class TextLinkTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class TextLinkTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -17,4 +17,4 @@ data class TextLinkTextSource @RiskFeature(DirectInvocationOfTextSourceConstruct
override val html: String by lazy { source.linkHTML(url) } override val html: String by lazy { source.linkHTML(url) }
} }
inline fun link(text: String, url: String) = TextLinkTextSource(text, url) inline fun linkTextSource(text: String, url: String) = TextLinkTextSource(text, url)

View File

@@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see mention * @see mentionTextSource
*/ */
@Serializable @Serializable
data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -22,21 +22,21 @@ data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
override val html: String by lazy { textMentionHTML(user.id) } override val html: String by lazy { textMentionHTML(user.id) }
} }
inline fun mention(parts: TextSourcesList, user: User) = TextMentionTextSource(parts.makeString(), user, parts) inline fun mentionTextSource(parts: TextSourcesList, user: User) = TextMentionTextSource(parts.makeString(), user, parts)
inline fun User.mention(parts: TextSourcesList) = mention(parts, this) inline fun User.mentionTextSource(parts: TextSourcesList) = mentionTextSource(parts, this)
inline fun mention(parts: TextSourcesList, userId: UserId) = mention(parts, CommonUser(userId, "")) inline fun mentionTextSource(parts: TextSourcesList, userId: UserId) = mentionTextSource(parts, CommonUser(userId, ""))
inline fun UserId.mention(parts: TextSourcesList) = mention(parts, this) inline fun UserId.mentionTextSource(parts: TextSourcesList) = mentionTextSource(parts, this)
inline fun mention(parts: TextSourcesList, id: RawChatId) = mention(parts, UserId(id)) inline fun mentionTextSource(parts: TextSourcesList, id: RawChatId) = mentionTextSource(parts, UserId(id))
inline fun RawChatId.mention(parts: TextSourcesList) = mention(parts, this) inline fun RawChatId.mentionTextSource(parts: TextSourcesList) = mentionTextSource(parts, this)
inline fun mention(user: User, vararg parts: TextSource) = mention( inline fun mentionTextSource(user: User, vararg parts: TextSource) = mentionTextSource(
textSourcesOrElseTextSource(parts.toList()) { textSourcesOrElseTextSource(parts.toList()) {
RegularTextSource("${user.lastName} ${user.firstName}") RegularTextSource("${user.lastName} ${user.firstName}")
}, },
user user
) )
inline fun mention(text: String, user: User) = mention(user, regular(text)) inline fun mentionTextSource(text: String, user: User) = mentionTextSource(user, regularTextSource(text))
inline fun User.mention(text: String) = mention(this, regular(text)) inline fun User.mentionTextSource(text: String) = mentionTextSource(this, regularTextSource(text))
inline fun mention(text: String, userId: UserId) = mention(text, CommonUser(userId, "")) inline fun mentionTextSource(text: String, userId: UserId) = mentionTextSource(text, CommonUser(userId, ""))
inline fun UserId.mention(text: String) = mention(text, this) inline fun UserId.mentionTextSource(text: String) = mentionTextSource(text, this)
inline fun mention(text: String, id: RawChatId) = mention(text, UserId(id)) inline fun mentionTextSource(text: String, id: RawChatId) = mentionTextSource(text, UserId(id))
inline fun RawChatId.mention(text: String) = mention(text, this) inline fun RawChatId.mentionTextSource(text: String) = mentionTextSource(text, this)

View File

@@ -26,7 +26,7 @@ operator fun TextSource.plus(other: TextSource) = when {
this is RegularTextSource && other is RegularTextSource -> listOf(RegularTextSource(source + other.source)) this is RegularTextSource && other is RegularTextSource -> listOf(RegularTextSource(source + other.source))
else -> listOf(this, other) else -> listOf(this, other)
} }
operator fun TextSource.plus(text: String) = this + regular(text) operator fun TextSource.plus(text: String) = this + regularTextSource(text)
operator fun List<TextSource>.plus(text: String): List<TextSource> { operator fun List<TextSource>.plus(text: String): List<TextSource> {
val newList = mutableListOf<TextSource>() val newList = mutableListOf<TextSource>()
@@ -36,7 +36,7 @@ operator fun List<TextSource>.plus(text: String): List<TextSource> {
val sublist = lastOrNull() ?.let { val sublist = lastOrNull() ?.let {
it + text it + text
} ?: listOf(regular(text)) } ?: listOf(regularTextSource(text))
newList.addAll(sublist) newList.addAll(sublist)

View File

@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see link * @see linkTextSource
*/ */
@Serializable @Serializable
data class URLTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class URLTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -16,4 +16,4 @@ data class URLTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) c
override val html: String by lazy { source.linkHTML(source) } override val html: String by lazy { source.linkHTML(source) }
} }
inline fun link(url: String) = URLTextSource(url) inline fun linkTextSource(url: String) = URLTextSource(url)

View File

@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/** /**
* @see underline * @see underlineTextSource
*/ */
@Serializable @Serializable
data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
@@ -18,6 +18,6 @@ data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstruc
override val html: String by lazy { underlineHTML() } override val html: String by lazy { underlineHTML() }
} }
inline fun underline(parts: TextSourcesList) = UnderlineTextSource(parts.makeString(), parts) inline fun underlineTextSource(parts: TextSourcesList) = UnderlineTextSource(parts.makeString(), parts)
inline fun underline(vararg parts: TextSource) = underline(parts.toList()) inline fun underlineTextSource(vararg parts: TextSource) = underlineTextSource(parts.toList())
inline fun underline(text: String) = underline(regular(text)) inline fun underlineTextSource(text: String) = underlineTextSource(regularTextSource(text))

View File

@@ -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

View File

@@ -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
)

View File

@@ -13,6 +13,12 @@ data class SuccessfulPayment(
override val amount: Long, override val amount: Long,
@SerialName(invoicePayloadField) @SerialName(invoicePayloadField)
val invoicePayload: String, val invoicePayload: String,
@SerialName(subscriptionExpirationDateField)
val subscriptionExpirationDate: TelegramDate? = null,
@SerialName(isRecurringField)
val isSubscriptionPayment: Boolean? = null,
@SerialName(isFirstRecurringField)
val isFirstPeriodPayment: Boolean? = null,
@SerialName(telegramPaymentChargeIdField) @SerialName(telegramPaymentChargeIdField)
val telegramPaymentChargeId: TelegramPaymentChargeId, val telegramPaymentChargeId: TelegramPaymentChargeId,
@SerialName(providerPaymentChargeIdField) @SerialName(providerPaymentChargeIdField)
@@ -21,4 +27,15 @@ data class SuccessfulPayment(
val shippingOptionId: String? = null, val shippingOptionId: String? = null,
@SerialName(orderInfoField) @SerialName(orderInfoField)
val orderInfo: OrderInfo? = null val orderInfo: OrderInfo? = null
) : Amounted, Currencied ) : Amounted, Currencied {
val recurringInfo: RecurringInfo? by lazy {
if (isSubscriptionPayment == true && subscriptionExpirationDate != null) {
RecurringInfo(
subscriptionExpirationDate,
isFirstPeriodPayment == true,
)
} else {
null
}
}
}

View File

@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.payments.stars
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.PreviewUser 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.decodeDataAndJson
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
@@ -16,9 +17,9 @@ import kotlinx.serialization.json.JsonElement
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE") @Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@Serializable(StarTransaction.Companion::class) @Serializable(StarTransaction.Companion::class)
@ClassCastsIncluded @ClassCastsIncluded
sealed interface StarTransaction { sealed interface StarTransaction : Amounted {
val id: StarTransactionId val id: StarTransactionId
val amount: Int val nanostarAmount: Int
val date: TelegramDate val date: TelegramDate
val partner: TransactionPartner val partner: TransactionPartner
val source: TransactionPartner? val source: TransactionPartner?
@@ -29,7 +30,9 @@ sealed interface StarTransaction {
@SerialName(idField) @SerialName(idField)
override val id: StarTransactionId, override val id: StarTransactionId,
@SerialName(amountField) @SerialName(amountField)
override val amount: Int, override val amount: Long,
@SerialName(nanostarAmountField)
override val nanostarAmount: Int,
@SerialName(dateField) @SerialName(dateField)
override val date: TelegramDate, override val date: TelegramDate,
@SerialName(sourceField) @SerialName(sourceField)
@@ -47,7 +50,9 @@ sealed interface StarTransaction {
@SerialName(idField) @SerialName(idField)
override val id: StarTransactionId, override val id: StarTransactionId,
@SerialName(amountField) @SerialName(amountField)
override val amount: Int, override val amount: Long,
@SerialName(nanostarAmountField)
override val nanostarAmount: Int,
@SerialName(dateField) @SerialName(dateField)
override val date: TelegramDate, override val date: TelegramDate,
@SerialName(receiverField) @SerialName(receiverField)
@@ -64,7 +69,9 @@ sealed interface StarTransaction {
data class Unknown( data class Unknown(
@SerialName(idField) @SerialName(idField)
override val id: StarTransactionId, override val id: StarTransactionId,
override val amount: Int, override val amount: Long,
@SerialName(nanostarAmountField)
override val nanostarAmount: Int,
override val date: TelegramDate, override val date: TelegramDate,
override val source: TransactionPartner?, override val source: TransactionPartner?,
override val receiver: TransactionPartner?, override val receiver: TransactionPartner?,
@@ -78,7 +85,9 @@ sealed interface StarTransaction {
@Serializable @Serializable
private data class Surrogate( private data class Surrogate(
val id: StarTransactionId, val id: StarTransactionId,
val amount: Int, val amount: Long,
@SerialName(nanostarAmountField)
val nanostarAmount: Int,
val date: TelegramDate, val date: TelegramDate,
val source: TransactionPartner? = null, val source: TransactionPartner? = null,
val receiver: TransactionPartner? = null, val receiver: TransactionPartner? = null,
@@ -94,6 +103,7 @@ sealed interface StarTransaction {
Unknown( Unknown(
id = data.id, id = data.id,
amount = data.amount, amount = data.amount,
nanostarAmount = data.nanostarAmount,
date = data.date, date = data.date,
source = data.source, source = data.source,
receiver = data.receiver, receiver = data.receiver,
@@ -104,12 +114,14 @@ sealed interface StarTransaction {
data.source != null -> Incoming( data.source != null -> Incoming(
id = data.id, id = data.id,
amount = data.amount, amount = data.amount,
nanostarAmount = data.nanostarAmount,
date = data.date, date = data.date,
partner = data.source partner = data.source
) )
data.receiver != null -> Outgoing( data.receiver != null -> Outgoing(
id = data.id, id = data.id,
amount = data.amount, amount = data.amount,
nanostarAmount = data.nanostarAmount,
date = data.date, date = data.date,
partner = data.receiver partner = data.receiver
) )
@@ -126,6 +138,7 @@ sealed interface StarTransaction {
val surrogate = Surrogate( val surrogate = Surrogate(
id = value.id, id = value.id,
amount = value.amount, amount = value.amount,
nanostarAmount = value.nanostarAmount,
date = value.date, date = value.date,
source = value.source, source = value.source,
receiver = value.receiver, receiver = value.receiver,

View File

@@ -2,11 +2,17 @@
package dev.inmo.tgbotapi.types.payments.stars package dev.inmo.tgbotapi.types.payments.stars
import dev.inmo.tgbotapi.abstracts.types.SubscriptionPeriodInfo
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.PreviewBot
import dev.inmo.tgbotapi.types.chat.PreviewUser 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.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.decodeDataAndJson
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import korlibs.time.TimeSpan
import kotlinx.serialization.EncodeDefault import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
@@ -40,13 +46,20 @@ sealed interface TransactionPartner {
data class User( data class User(
@SerialName(userField) @SerialName(userField)
val user: PreviewUser, val user: PreviewUser,
@SerialName(affiliateField)
val affiliate: AffiliateInfo? = null,
@SerialName(invoicePayloadField) @SerialName(invoicePayloadField)
val invoicePayload: InvoicePayload? = null, val invoicePayload: InvoicePayload? = null,
@SerialName(subscriptionPeriodField)
@Serializable(TimeSpanAsSecondsSerializer::class)
override val subscriptionPeriod: TimeSpan? = null,
@SerialName(paidMediaField) @SerialName(paidMediaField)
val paidMedia: List<PaidMedia>? = null, val paidMedia: List<PaidMedia>? = null,
@SerialName(paidMediaPayloadField) @SerialName(paidMediaPayloadField)
val paidMediaPayload: PaidMediaPayload? = null val paidMediaPayload: PaidMediaPayload? = null,
) : TransactionPartner { @SerialName(giftField)
val gift: Gift? = null
) : TransactionPartner, SubscriptionPeriodInfo {
@EncodeDefault @EncodeDefault
override val type: String = Companion.type 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) @Serializable(TransactionPartner.Companion::class)
data object Ads : TransactionPartner { data object Ads : TransactionPartner {
@EncodeDefault @EncodeDefault
@@ -95,8 +126,17 @@ sealed interface TransactionPartner {
val type: String, val type: String,
val withdrawal_state: RevenueWithdrawalState? = null, val withdrawal_state: RevenueWithdrawalState? = null,
val user: PreviewUser? = null, val user: PreviewUser? = null,
val affiliate: AffiliateInfo? = null,
val invoice_payload: InvoicePayload? = null, val invoice_payload: InvoicePayload? = null,
val request_count: Int? = null @Serializable(TimeSpanAsSecondsSerializer::class)
val subscription_period: TimeSpan? = null,
val paid_media: List<PaidMedia>? = 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 override val descriptor: SerialDescriptor
@@ -108,35 +148,63 @@ sealed interface TransactionPartner {
val unknown by lazy { val unknown by lazy {
Unknown(data.type, json) Unknown(data.type, json)
} }
return when (data.type) { return with(data) {
Other.type -> Other when (data.type) {
User.type -> User( Other.type -> Other
data.user ?: return unknown, User.type -> User(
) user = user ?: return unknown,
TelegramAPI.type -> TelegramAPI( affiliate = affiliate,
data.request_count ?: return unknown, invoicePayload = invoice_payload,
) subscriptionPeriod = subscription_period,
Ads.type -> Ads paidMedia = paid_media,
Fragment.type -> Fragment( paidMediaPayload = paid_media_payload,
data.withdrawal_state ?: return unknown, gift = gift
) )
else -> unknown 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) { override fun serialize(encoder: Encoder, value: TransactionPartner) {
val surrogate = when (value) { val surrogate = with (value) {
Other -> Surrogate(value.type) when (this) {
Ads -> Surrogate(value.type) Other -> Surrogate(type = value.type)
is User -> Surrogate(value.type, user = value.user) Ads -> Surrogate(type = value.type)
is TelegramAPI -> Surrogate(value.type, request_count = value.requestCount) is User -> Surrogate(
is Fragment -> Surrogate( type = value.type,
value.type, user = user,
value.withdrawalState affiliate = affiliate,
) invoice_payload = invoicePayload,
is Unknown -> value.raw ?.let { subscription_period = subscriptionPeriod,
return JsonElement.serializer().serialize(encoder, it) paid_media = paidMedia,
} ?: Surrogate(value.type) 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) Surrogate.serializer().serialize(encoder, surrogate)

View File

@@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.textsources.* import dev.inmo.tgbotapi.types.message.textsources.*
typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit
val newLine = regular("\n") val newLine = regularTextSource("\n")
inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build() inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build()
inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init) inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regularTextSource(separator), init)
/** /**
* This builder can be used to provide building of [TextSource]s [List] * This builder can be used to provide building of [TextSource]s [List]
@@ -51,7 +51,7 @@ class EntitiesBuilder(
operator fun invoke(vararg source: TextSource) = addAll(source.toList()) operator fun invoke(vararg source: TextSource) = addAll(source.toList())
operator fun String.unaryPlus(): EntitiesBuilder { operator fun String.unaryPlus(): EntitiesBuilder {
add(dev.inmo.tgbotapi.types.message.textsources.regular(this)) add(dev.inmo.tgbotapi.types.message.textsources.regularTextSource(this))
return this@EntitiesBuilder return this@EntitiesBuilder
} }
@@ -68,18 +68,18 @@ class EntitiesBuilder(
} }
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.boldTextSource]
*/ */
inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.bold(parts)) inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.boldTextSource(parts))
/** /**
* Version of [EntitiesBuilder.bold] with new line at the end * Version of [EntitiesBuilder.bold] with new line at the end
*/ */
inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]. * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.boldTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold( inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.boldTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -88,35 +88,35 @@ inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.in
*/ */
inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.boldTextSource]
*/ */
inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.bold(*parts)) inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.boldTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.bold] with new line at the end * Version of [EntitiesBuilder.bold] with new line at the end
*/ */
inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.boldTextSource]
*/ */
inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.bold(text)) inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.boldTextSource(text))
/** /**
* Version of [EntitiesBuilder.bold] with new line at the end * Version of [EntitiesBuilder.bold] with new line at the end
*/ */
inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine
/** /**
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote] * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource]
*/ */
inline fun EntitiesBuilder.blockquote(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(parts)) inline fun EntitiesBuilder.blockquote(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource(parts))
/** /**
* Version of [EntitiesBuilder.blockquote] with new line at the end * Version of [EntitiesBuilder.blockquote] with new line at the end
*/ */
inline fun EntitiesBuilder.blockquoteln(parts: TextSourcesList) = blockquote(parts) + newLine inline fun EntitiesBuilder.blockquoteln(parts: TextSourcesList) = blockquote(parts) + newLine
/** /**
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote]. * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.blockquote(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote( inline fun EntitiesBuilder.blockquote(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -125,17 +125,17 @@ inline fun EntitiesBuilder.blockquote(noinline init: EntitiesBuilderBody) = add(
*/ */
inline fun EntitiesBuilder.blockquoteln(noinline init: EntitiesBuilderBody) = blockquote(init) + newLine inline fun EntitiesBuilder.blockquoteln(noinline init: EntitiesBuilderBody) = blockquote(init) + newLine
/** /**
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote] * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource]
*/ */
inline fun EntitiesBuilder.blockquote(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(*parts)) inline fun EntitiesBuilder.blockquote(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.blockquote] with new line at the end * Version of [EntitiesBuilder.blockquote] with new line at the end
*/ */
inline fun EntitiesBuilder.blockquoteln(vararg parts: TextSource) = blockquote(*parts) + newLine inline fun EntitiesBuilder.blockquoteln(vararg parts: TextSource) = blockquote(*parts) + newLine
/** /**
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote] * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource]
*/ */
inline fun EntitiesBuilder.blockquote(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(text)) inline fun EntitiesBuilder.blockquote(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource(text))
/** /**
* Version of [EntitiesBuilder.blockquote] with new line at the end * Version of [EntitiesBuilder.blockquote] with new line at the end
*/ */
@@ -143,18 +143,18 @@ inline fun EntitiesBuilder.blockquoteln(text: String) = blockquote(text) + newLi
/** /**
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote] * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquoteTextSource]
*/ */
inline fun EntitiesBuilder.expandableBlockquote(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquote(parts)) inline fun EntitiesBuilder.expandableBlockquote(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquoteTextSource(parts))
/** /**
* Version of [EntitiesBuilder.expandableBlockquote] with new line at the end * Version of [EntitiesBuilder.expandableBlockquote] with new line at the end
*/ */
inline fun EntitiesBuilder.expandableBlockquoteln(parts: TextSourcesList) = expandableBlockquote(parts) + newLine inline fun EntitiesBuilder.expandableBlockquoteln(parts: TextSourcesList) = expandableBlockquote(parts) + newLine
/** /**
* Add expandableBlockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.expandableBlockquote]. * Add expandableBlockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.expandableBlockquoteTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.expandableBlockquote(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquote( inline fun EntitiesBuilder.expandableBlockquote(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquoteTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -163,35 +163,35 @@ inline fun EntitiesBuilder.expandableBlockquote(noinline init: EntitiesBuilderBo
*/ */
inline fun EntitiesBuilder.expandableBlockquoteln(noinline init: EntitiesBuilderBody) = expandableBlockquote(init) + newLine inline fun EntitiesBuilder.expandableBlockquoteln(noinline init: EntitiesBuilderBody) = expandableBlockquote(init) + newLine
/** /**
* Add expandableBlockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.expandableBlockquote] * Add expandableBlockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.expandableBlockquoteTextSource]
*/ */
inline fun EntitiesBuilder.expandableBlockquote(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquote(*parts)) inline fun EntitiesBuilder.expandableBlockquote(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquoteTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.expandableBlockquote] with new line at the end * Version of [EntitiesBuilder.expandableBlockquote] with new line at the end
*/ */
inline fun EntitiesBuilder.expandableBlockquoteln(vararg parts: TextSource) = expandableBlockquote(*parts) + newLine inline fun EntitiesBuilder.expandableBlockquoteln(vararg parts: TextSource) = expandableBlockquote(*parts) + newLine
/** /**
* Add expandableBlockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.expandableBlockquote] * Add expandableBlockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.expandableBlockquoteTextSource]
*/ */
inline fun EntitiesBuilder.expandableBlockquote(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquote(text)) inline fun EntitiesBuilder.expandableBlockquote(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.expandableBlockquoteTextSource(text))
/** /**
* Version of [EntitiesBuilder.expandableBlockquote] with new line at the end * Version of [EntitiesBuilder.expandableBlockquote] with new line at the end
*/ */
inline fun EntitiesBuilder.expandableBlockquoteln(text: String) = expandableBlockquote(text) + newLine inline fun EntitiesBuilder.expandableBlockquoteln(text: String) = expandableBlockquote(text) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource]
*/ */
inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(parts)) inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource(parts))
/** /**
* Version of [EntitiesBuilder.spoiler] with new line at the end * Version of [EntitiesBuilder.spoiler] with new line at the end
*/ */
inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]. * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler( inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -200,17 +200,17 @@ inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev
*/ */
inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource]
*/ */
inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts)) inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.spoiler] with new line at the end * Version of [EntitiesBuilder.spoiler] with new line at the end
*/ */
inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource]
*/ */
inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(text)) inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoilerTextSource(text))
/** /**
* Version of [EntitiesBuilder.spoiler] with new line at the end * Version of [EntitiesBuilder.spoiler] with new line at the end
*/ */
@@ -218,17 +218,17 @@ inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine
/** /**
* Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommandTextSource]
*/ */
inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(command)) inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommandTextSource(command))
/** /**
* Version of [EntitiesBuilder.botCommand] with new line at the end * Version of [EntitiesBuilder.botCommand] with new line at the end
*/ */
inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine
/** /**
* Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommandTextSource]
*/ */
inline fun EntitiesBuilder.botCommand(botCommand: BotCommand) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(botCommand)) inline fun EntitiesBuilder.botCommand(botCommand: BotCommand) = add(dev.inmo.tgbotapi.types.message.textsources.botCommandTextSource(botCommand))
/** /**
* Version of [EntitiesBuilder.botCommand] with new line at the end * Version of [EntitiesBuilder.botCommand] with new line at the end
*/ */
@@ -237,18 +237,18 @@ inline fun EntitiesBuilder.botCommandln(botCommand: BotCommand) = botCommand(bot
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource]
*/ */
inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(parts)) inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource(parts))
/** /**
* Version of [EntitiesBuilder.cashTag] with new line at the end * Version of [EntitiesBuilder.cashTag] with new line at the end
*/ */
inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]. * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag( inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -257,17 +257,17 @@ inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev
*/ */
inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource]
*/ */
inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts)) inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.cashTag] with new line at the end * Version of [EntitiesBuilder.cashTag] with new line at the end
*/ */
inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource]
*/ */
inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(text)) inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTagTextSource(text))
/** /**
* Version of [EntitiesBuilder.cashTag] with new line at the end * Version of [EntitiesBuilder.cashTag] with new line at the end
*/ */
@@ -275,9 +275,9 @@ inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine
/** /**
* Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code] * Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.codeTextSource]
*/ */
inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.code(code)) inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.codeTextSource(code))
/** /**
* Version of [EntitiesBuilder.code] with new line at the end * Version of [EntitiesBuilder.code] with new line at the end
*/ */
@@ -285,18 +285,18 @@ inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.emailTextSource]
*/ */
inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.email(parts)) inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.emailTextSource(parts))
/** /**
* Version of [EntitiesBuilder.email] with new line at the end * Version of [EntitiesBuilder.email] with new line at the end
*/ */
inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]. * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.emailTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email( inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.emailTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -305,17 +305,17 @@ inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.i
*/ */
inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.emailTextSource]
*/ */
inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.email(*parts)) inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.emailTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.email] with new line at the end * Version of [EntitiesBuilder.email] with new line at the end
*/ */
inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.emailTextSource]
*/ */
inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.email(emailAddress)) inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.emailTextSource(emailAddress))
/** /**
* Version of [EntitiesBuilder.email] with new line at the end * Version of [EntitiesBuilder.email] with new line at the end
*/ */
@@ -323,18 +323,18 @@ inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) +
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource]
*/ */
inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(parts)) inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource(parts))
/** /**
* Version of [EntitiesBuilder.hashtag] with new line at the end * Version of [EntitiesBuilder.hashtag] with new line at the end
*/ */
inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]. * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag( inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -343,17 +343,17 @@ inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev
*/ */
inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource]
*/ */
inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts)) inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.hashtag] with new line at the end * Version of [EntitiesBuilder.hashtag] with new line at the end
*/ */
inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource]
*/ */
inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(hashtag)) inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtagTextSource(hashtag))
/** /**
* Version of [EntitiesBuilder.hashtag] with new line at the end * Version of [EntitiesBuilder.hashtag] with new line at the end
*/ */
@@ -361,18 +361,18 @@ inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLi
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italicTextSource]
*/ */
inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italic(parts)) inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italicTextSource(parts))
/** /**
* Version of [EntitiesBuilder.italic] with new line at the end * Version of [EntitiesBuilder.italic] with new line at the end
*/ */
inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]. * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italicTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic( inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italicTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -381,17 +381,17 @@ inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.
*/ */
inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italicTextSource]
*/ */
inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italic(*parts)) inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italicTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.italic] with new line at the end * Version of [EntitiesBuilder.italic] with new line at the end
*/ */
inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italicTextSource]
*/ */
inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italic(text)) inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italicTextSource(text))
/** /**
* Version of [EntitiesBuilder.italic] with new line at the end * Version of [EntitiesBuilder.italic] with new line at the end
*/ */
@@ -399,18 +399,18 @@ inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource]
*/ */
inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts)) inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(parts))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]. * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention( inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -419,25 +419,25 @@ inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev
*/ */
inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource]
*/ */
inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mention(*parts)) inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource]
*/ */
inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention)) inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(whoToMention))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource]
*/ */
inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, user)) inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(parts, user))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
@@ -445,24 +445,24 @@ inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = menti
inline fun EntitiesBuilder.mention( inline fun EntitiesBuilder.mention(
user: User, user: User,
vararg parts: TextSource vararg parts: TextSource
) = add(dev.inmo.tgbotapi.types.message.textsources.mention(user, *parts)) ) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(user, *parts))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource]
*/ */
inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, user)) inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(text, user))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text, user) + newLine inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text, user) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource]
*/ */
inline fun EntitiesBuilder.mention(parts: TextSourcesList, userId: UserId) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, userId)) inline fun EntitiesBuilder.mention(parts: TextSourcesList, userId: UserId) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(parts, userId))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
@@ -476,9 +476,9 @@ inline fun EntitiesBuilder.mention(
*/ */
inline fun EntitiesBuilder.mentionln(userId: UserId, vararg parts: TextSource) = mention(userId, *parts) + newLine inline fun EntitiesBuilder.mentionln(userId: UserId, vararg parts: TextSource) = mention(userId, *parts) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mentionTextSource]
*/ */
inline fun EntitiesBuilder.mention(text: String, userId: UserId) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, userId)) inline fun EntitiesBuilder.mention(text: String, userId: UserId) = add(dev.inmo.tgbotapi.types.message.textsources.mentionTextSource(text, userId))
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * Version of [EntitiesBuilder.mention] with new line at the end
*/ */
@@ -486,18 +486,18 @@ inline fun EntitiesBuilder.mentionln(text: String, userId: UserId) = mention(tex
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phoneTextSource]
*/ */
inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phone(parts)) inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phoneTextSource(parts))
/** /**
* Version of [EntitiesBuilder.phone] with new line at the end * Version of [EntitiesBuilder.phone] with new line at the end
*/ */
inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]. * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phoneTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone( inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phoneTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -506,17 +506,17 @@ inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.i
*/ */
inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phoneTextSource]
*/ */
inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phone(*parts)) inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phoneTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.phone] with new line at the end * Version of [EntitiesBuilder.phone] with new line at the end
*/ */
inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phoneTextSource]
*/ */
inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phone(number)) inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phoneTextSource(number))
/** /**
* Version of [EntitiesBuilder.phone] with new line at the end * Version of [EntitiesBuilder.phone] with new line at the end
*/ */
@@ -524,24 +524,24 @@ inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine
/** /**
* Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre] * Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.preTextSource]
*/ */
inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.pre(code, language)) inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.preTextSource(code, language))
/** /**
* Version of [EntitiesBuilder.pre] with new line at the end * Version of [EntitiesBuilder.pre] with new line at the end
*/ */
inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code, language) + newLine inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code, language) + newLine
/** /**
* Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regularTextSource] [TextSource]
* *
* @see RegularTextSource * @see RegularTextSource
* @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln * @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln
*/ */
inline fun EntitiesBuilder.regular(text: String) = inline fun EntitiesBuilder.regular(text: String) =
add(dev.inmo.tgbotapi.types.message.textsources.regular(text)) add(dev.inmo.tgbotapi.types.message.textsources.regularTextSource(text))
/** /**
* Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] and "\n" at the end * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regularTextSource] [TextSource] and "\n" at the end
* *
* @see RegularTextSource * @see RegularTextSource
* @see dev.inmo.tgbotapi.extensions.utils.formatting.regular * @see dev.inmo.tgbotapi.extensions.utils.formatting.regular
@@ -550,18 +550,18 @@ inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource]
*/ */
inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts)) inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource(parts))
/** /**
* Version of [EntitiesBuilder.strikethrough] with new line at the end * Version of [EntitiesBuilder.strikethrough] with new line at the end
*/ */
inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]. * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough( inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -570,17 +570,17 @@ inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = a
*/ */
inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource]
*/ */
inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts)) inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.strikethrough] with new line at the end * Version of [EntitiesBuilder.strikethrough] with new line at the end
*/ */
inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource]
*/ */
inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(text)) inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethroughTextSource(text))
/** /**
* Version of [EntitiesBuilder.strikethrough] with new line at the end * Version of [EntitiesBuilder.strikethrough] with new line at the end
*/ */
@@ -588,17 +588,17 @@ inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) +
/** /**
* Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.linkTextSource]
*/ */
inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(text, url)) inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.linkTextSource(text, url))
/** /**
* Version of [EntitiesBuilder.link] with new line at the end * Version of [EntitiesBuilder.link] with new line at the end
*/ */
inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine
/** /**
* Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.linkTextSource]
*/ */
inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(url)) inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.linkTextSource(url))
/** /**
* Version of [EntitiesBuilder.link] with new line at the end * Version of [EntitiesBuilder.link] with new line at the end
*/ */
@@ -606,18 +606,18 @@ inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underlineTextSource]
*/ */
inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underline(parts)) inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underlineTextSource(parts))
/** /**
* Version of [EntitiesBuilder.underline] with new line at the end * Version of [EntitiesBuilder.underline] with new line at the end
*/ */
inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]. * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underlineTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline( inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underlineTextSource(
buildEntities(separator, init) buildEntities(separator, init)
)) ))
/** /**
@@ -626,17 +626,17 @@ inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(d
*/ */
inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underlineTextSource]
*/ */
inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underline(*parts)) inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underlineTextSource(*parts))
/** /**
* Version of [EntitiesBuilder.underline] with new line at the end * Version of [EntitiesBuilder.underline] with new line at the end
*/ */
inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underlineTextSource]
*/ */
inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underline(text)) inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underlineTextSource(text))
/** /**
* Version of [EntitiesBuilder.underline] with new line at the end * Version of [EntitiesBuilder.underline] with new line at the end
*/ */
@@ -644,35 +644,35 @@ inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine
/** /**
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource]
*/ */
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts)) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource(customEmojiId, parts))
/** /**
* Version of [EntitiesBuilder.customEmoji] with new line at the end * Version of [EntitiesBuilder.customEmoji] with new line at the end
*/ */
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine
/** /**
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]. * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init))) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource(customEmojiId, buildEntities(separator, init)))
/** /**
* Version of [EntitiesBuilder.customEmoji] with new line at the end. * Version of [EntitiesBuilder.customEmoji] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine
/** /**
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource]
*/ */
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts)) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource(customEmojiId, *parts))
/** /**
* Version of [EntitiesBuilder.customEmoji] with new line at the end * Version of [EntitiesBuilder.customEmoji] with new line at the end
*/ */
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine
/** /**
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource]
*/ */
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text)) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmojiTextSource(customEmojiId, text))
/** /**
* Version of [EntitiesBuilder.customEmoji] with new line at the end * Version of [EntitiesBuilder.customEmoji] with new line at the end
*/ */

View File

@@ -0,0 +1,6 @@
package dev.inmo.tgbotapi.utils.crypto
object Ed25519TelegramKeys {
const val TestEnvironment = "40055058a4ee38156a06562e52eece92a771bcd8346a8c4615cb7376eddf72ec" // hex
const val Production = "e7bf03a2fa4602af4580703d88dda5bb59f32ed8b02a56c187fe7d34caed242d" // hex
}

View File

@@ -39,24 +39,24 @@ class StringFormattingTests {
@Test @Test
fun testThatCreatingOfStringWithSimpleDSLWorksCorrectly() { fun testThatCreatingOfStringWithSimpleDSLWorksCorrectly() {
val sources: TextSourcesList = regular("It (is?) ") + val sources: TextSourcesList = regularTextSource("It (is?) ") +
bold(italic("is") + boldTextSource(italicTextSource("is") +
" " + " " +
strikethrough(underline("simple"))) + strikethroughTextSource(underlineTextSource("simple"))) +
" " + " " +
spoiler("hello world") + spoilerTextSource("hello world") +
" with " + " with " +
hashtag("tag@sample") + hashtagTextSource("tag@sample") +
" and " + " and " +
mention("mention") + mentionTextSource("mention") +
". Start of blockquote: " + ". Start of blockquote: " +
blockquote( blockquoteTextSource(
"Block quotation started\n" + "Block quotation started\n" +
"Block quotation continued\n" + "Block quotation continued\n" +
"The last line of the block quotation" "The last line of the block quotation"
) + ) +
"\n. Start of expandable blockquote: " + "\n. Start of expandable blockquote: " +
expandableBlockquote( expandableBlockquoteTextSource(
"Block quotation started\n" + "Block quotation started\n" +
"Block quotation continued\n" + "Block quotation continued\n" +
"The last line of the block quotation" "The last line of the block quotation"

View File

@@ -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 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 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 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 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 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; 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 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 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 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 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 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; public static final fun ifAnimationFile (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;

View File

@@ -5330,6 +5330,16 @@ public inline fun TransactionPartner.adsOrThrow(): TransactionPartner.Ads = this
public inline fun <T> TransactionPartner.ifAds(block: (TransactionPartner.Ads) -> T): T? = public inline fun <T> TransactionPartner.ifAds(block: (TransactionPartner.Ads) -> T): T? =
adsOrNull() ?.let(block) 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 <T>
TransactionPartner.ifAffiliateProgram(block: (TransactionPartner.AffiliateProgram) -> T): T? =
affiliateProgramOrNull() ?.let(block)
public inline fun TransactionPartner.fragmentOrNull(): TransactionPartner.Fragment? = this as? public inline fun TransactionPartner.fragmentOrNull(): TransactionPartner.Fragment? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Fragment dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Fragment

View File

@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.utils.formatting
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.textsources.link import dev.inmo.tgbotapi.types.message.textsources.linkTextSource
import io.ktor.http.encodeURLQueryComponent import io.ktor.http.encodeURLQueryComponent
@@ -115,4 +115,4 @@ val Chat.chatLink: String?
private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addstickers" private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addstickers"
val StickerSetName.stickerSetLink val StickerSetName.stickerSetLink
get() = link(string, "$stickerSetAddingLinkPrefix/$this") get() = linkTextSource(string, "$stickerSetAddingLinkPrefix/$this")

View File

@@ -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<File>()
var extensions: List<String>? = null
var skipPrompts: Boolean = false
val commandLineArgs = mutableMapOf<String, String>()
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, String>): 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<String, String>?): Map<String, String> {
val initialEnvs = mutableMapOf<String, String>()
val contentAsMap = mutableMapOf<String, String>()
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<String, String> = (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<String, String>) {
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)
}

View File

@@ -0,0 +1 @@
data object {{$event_name_uppercase}} : EventType("{{$event_name}}")

View File

@@ -0,0 +1,2 @@
@JsName("onEvent")
internal fun on{{$event_name_uppercase}}(type: String, callback: ({{$callback_args}}) -> Unit)

View File

@@ -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<WebApp>(), {{$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)

View File

@@ -2,6 +2,7 @@ plugins {
id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization" id "org.jetbrains.kotlin.plugin.serialization"
id "org.jetbrains.dokka" id "org.jetbrains.dokka"
id "com.google.devtools.ksp"
} }
project.description = "Web App bindings for the Telegram Web Apps API" project.description = "Web App bindings for the Telegram Web Apps API"
@@ -14,7 +15,15 @@ kotlin {
commonMain { commonMain {
dependencies { dependencies {
api project(":tgbotapi.core") api project(":tgbotapi.core")
api libs.microutils.ksp.sealed
} }
} }
} }
} }
dependencies {
add("kspJs", libs.microutils.ksp.sealed.generator)
}
ksp {}

View File

@@ -0,0 +1,3 @@
package dev.inmo.tgbotapi.webapps
external interface ContentSafeAreaInset : SafeAreaInset {}

View File

@@ -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<DownloadFileParams>()

View File

@@ -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<EmojiStatusParams>()

View File

@@ -3,11 +3,3 @@ package dev.inmo.tgbotapi.webapps
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
typealias EventHandler = WebApp.() -> Unit 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

View File

@@ -1,17 +1,53 @@
package dev.inmo.tgbotapi.webapps package dev.inmo.tgbotapi.webapps
import dev.inmo.micro_utils.ksp.sealed.GenerateSealedWorkaround
@GenerateSealedWorkaround
sealed class EventType(val typeName: String) { 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 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 ViewportChanged : EventType("viewportChanged")
data object MainButtonClicked : EventType("mainButtonClicked") data object MainButtonClicked : EventType("mainButtonClicked")
data object SecondaryButtonClicked : EventType("secondaryButtonClicked") data object AccelerometerFailed : EventType("accelerometerFailed")
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 ClipboardTextReceived : EventType("clipboardTextReceived") data object ClipboardTextReceived : EventType("clipboardTextReceived")
data object WriteAccessRequested : EventType("writeAccessRequested") data object FileDownloadRequested : EventType("fileDownloadRequested")
data object ContactRequested : EventType("contactRequested") 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
} }

View File

@@ -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<EventType> = 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<EventType> = values

View File

@@ -0,0 +1,8 @@
package dev.inmo.tgbotapi.webapps
enum class HomeScreenStatus(val value: String) {
Unsupported("unsupported"),
Unknown("unknown"),
Added("added"),
Missed("missed"),
}

View File

@@ -11,4 +11,13 @@ inline val RequestStatus.isAllowed: Boolean
get() = status == "allowed" get() = status == "allowed"
inline val RequestStatus.isSent: Boolean 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" get() = status == "sent"

View File

@@ -0,0 +1,9 @@
package dev.inmo.tgbotapi.webapps
external interface SafeAreaInset {
val top: Int
val bottom: Int
val left: Int
val right: Int
}

View File

@@ -1,10 +1,16 @@
package dev.inmo.tgbotapi.webapps 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.utils.TelegramAPIUrlsKeeper
import dev.inmo.tgbotapi.webapps.accelerometer.Accelerometer
import dev.inmo.tgbotapi.webapps.biometric.BiometricManager import dev.inmo.tgbotapi.webapps.biometric.BiometricManager
import dev.inmo.tgbotapi.webapps.cloud.CloudStorage 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.haptic.HapticFeedback
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo 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.popup.*
import dev.inmo.tgbotapi.webapps.stories.StoryShareParams import dev.inmo.tgbotapi.webapps.stories.StoryShareParams
@@ -52,6 +58,20 @@ external class WebApp {
fun closeScanQrPopup() fun closeScanQrPopup()
fun readTextFromClipboard(callback: TextReceivedCallback? = definedExternally) 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") @JsName("MainButton")
val mainButton: BottomButton val mainButton: BottomButton
@JsName("SecondaryButton") @JsName("SecondaryButton")
@@ -69,28 +89,22 @@ external class WebApp {
@JsName("BiometricManager") @JsName("BiometricManager")
val biometricManager: 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") @JsName("SettingsButton")
val settingsButton: SettingsButton val settingsButton: SettingsButton
internal fun onEvent(type: String, callback: () -> Unit) 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) fun offEvent(type: String, callback: () -> Unit)
@JsName("offEvent") @JsName("offEvent")
@@ -111,8 +125,108 @@ external class WebApp {
fun shareToStory(mediaUrl: String, params: StoryShareParams? = definedExternally) 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 requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally)
fun requestContact(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 val WebApp.colorScheme: ColorScheme
@@ -122,178 +236,178 @@ val WebApp.colorScheme: ColorScheme
else -> ColorScheme.LIGHT else -> ColorScheme.LIGHT
} }
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @return The callback which should be used in case you want to turn off events handling
*/ // */
fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = { //fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = {
eventHandler(js("this").unsafeCast<WebApp>()) // eventHandler(js("this").unsafeCast<WebApp>())
}.also { //}.also {
onEvent( // onEvent(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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 -> //fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: ViewportChangedData ->
eventHandler(js("this").unsafeCast<WebApp>(), it) // eventHandler(js("this").unsafeCast<WebApp>(), it)
}.also { //}.also {
onEventWithViewportChangedData( // onEventWithViewportChangedData(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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 -> //fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { it: InvoiceClosedInfo ->
eventHandler(js("this").unsafeCast<WebApp>(), it) // eventHandler(js("this").unsafeCast<WebApp>(), it)
}.also { //}.also {
onEventWithInvoiceClosedInfo( // onEventWithInvoiceClosedInfo(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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? -> //fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHandler) = { it: String? ->
eventHandler(js("this").unsafeCast<WebApp>(), it) // eventHandler(js("this").unsafeCast<WebApp>(), it)
}.also { //}.also {
onEventWithPopupClosedInfo( // onEventWithPopupClosedInfo(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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 -> //fun WebApp.onEvent(type: EventType.QRTextReceived, eventHandler: QRTextReceivedEventHandler) = { it: String ->
eventHandler(js("this").unsafeCast<WebApp>(), it) // eventHandler(js("this").unsafeCast<WebApp>(), it)
}.also { //}.also {
onEventWithQRTextInfo( // onEventWithQRTextInfo(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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 -> //fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: TextReceivedEventHandler) = { it: String ->
eventHandler(js("this").unsafeCast<WebApp>(), it) // eventHandler(js("this").unsafeCast<WebApp>(), it)
}.also { //}.also {
onEventWithTextInfo( // onEventWithTextInfo(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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 -> //fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedHandler) = { it: RequestStatus ->
eventHandler(js("this").unsafeCast<WebApp>(), it.isAllowed) // eventHandler(js("this").unsafeCast<WebApp>(), it.isAllowed)
}.also { //}.also {
onEventWithWriteAccessRequested( // onEventWithWriteAccessRequested(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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 -> //fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedHandler) = { it: RequestStatus ->
eventHandler(js("this").unsafeCast<WebApp>(), it.isSent) // eventHandler(js("this").unsafeCast<WebApp>(), it.isSent)
}.also { //}.also {
onEventWithContactRequested( // onEventWithContactRequested(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @return The callback which should be used in case you want to turn off events handling
*/ // */
fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = { //fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = {
eventHandler(js("this").unsafeCast<WebApp>()) // eventHandler(js("this").unsafeCast<WebApp>())
}.also { //}.also {
onEventWithSettingsButtonClicked( // onEventWithSettingsButtonClicked(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @return The callback which should be used in case you want to turn off events handling
*/ // */
fun WebApp.onEvent(type: EventType.ScanQRPopupClosed, eventHandler: EventHandler) = { //fun WebApp.onEvent(type: EventType.ScanQRPopupClosed, eventHandler: EventHandler) = {
eventHandler(js("this").unsafeCast<WebApp>()) // eventHandler(js("this").unsafeCast<WebApp>())
}.also { //}.also {
onEventWithScanQRPopupClosed( // onEventWithScanQRPopupClosed(
type.typeName, // type.typeName,
callback = it // callback = it
) // )
} //}
//
/** ///**
* @return The callback which should be used in case you want to turn off events handling // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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) //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 // * @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.onScanQRPopupClosed(eventHandler: onScanQRPopupClosedHandler) = onEvent(EventType.ScanQRPopupClosed, eventHandler)
fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData( fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData(
initData, initData,

View File

@@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.webapps package dev.inmo.tgbotapi.webapps
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.ChatType
external interface WebAppInitData { external interface WebAppInitData {
@JsName("query_id") @JsName("query_id")
@@ -9,6 +10,14 @@ external interface WebAppInitData {
val user: WebAppUser? val user: WebAppUser?
val receiver: WebAppUser? val receiver: WebAppUser?
val chat: WebAppChat?
@JsName("chat_type")
val chatType: ChatType?
@JsName("chat_instance")
val chatInstance: String?
@JsName("start_param") @JsName("start_param")
val startParam: String? val startParam: String?
@@ -16,9 +25,9 @@ external interface WebAppInitData {
val authDate: MilliSeconds val authDate: MilliSeconds
@JsName("can_send_after") @JsName("can_send_after")
val canSendAfter: MilliSeconds val canSendAfter: MilliSeconds?
val chat: WebAppChat
val hash: String val hash: String
val signature: String
} }

View File

@@ -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)
}

View File

@@ -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<AccelerometerStartParams>()

View File

@@ -0,0 +1,4 @@
package dev.inmo.tgbotapi.webapps.args
interface ArgBiometricAuthRequested : ArgBiometricTokenNullableObject, ArgIsAuthenticatedObject {
}

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.webapps.args
external interface ArgBiometricTokenNullableObject {
val biometricToken: String?
}

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.webapps.args
external interface ArgDataNullableObject {
val data: String?
}

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.webapps.args
external interface ArgDataObject : ArgDataNullableObject {
override val data: String
}

View File

@@ -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"

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.webapps.args
interface ArgIsAuthenticatedObject {
val isAuthenticated: Boolean
}

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.webapps.args
interface ArgIsUpdatedObject {
val isUpdated: Boolean
}

View File

@@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.webapps.args
import dev.inmo.tgbotapi.webapps.location.LocationData
interface ArgLocationDataObject {
val locationData: LocationData
}

View File

@@ -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"

View File

@@ -18,11 +18,11 @@ external interface CloudStorage {
): CloudStorage ): CloudStorage
fun removeItem( fun removeItem(
key: CloudStorageKey, key: CloudStorageKey,
callback: (e: Any?, success: Boolean?) -> Unit callback: (e: Any?, success: Boolean?) -> Unit = definedExternally
): CloudStorage ): CloudStorage
fun removeItems( fun removeItems(
key: Array<CloudStorageKey>, key: Array<CloudStorageKey>,
callback: (e: Any?, success: Boolean?) -> Unit callback: (e: Any?, success: Boolean?) -> Unit = definedExternally
): CloudStorage ): CloudStorage
fun getKeys( fun getKeys(
callback: (e: Any?, success: Array<CloudStorageKey>?) -> Unit callback: (e: Any?, success: Array<CloudStorageKey>?) -> Unit
@@ -80,24 +80,24 @@ fun CloudStorage.get(
fun CloudStorage.remove( fun CloudStorage.remove(
key: CloudStorageKey, key: CloudStorageKey,
callback: (result: Result<Boolean>) -> Unit callback: (result: Result<Boolean>) -> Unit = {}
) = removeItem(key) { e, v -> callback(resultsToResult(e, v)) } ) = removeItem(key) { e, v -> callback(resultsToResult(e, v)) }
fun CloudStorage.remove( fun CloudStorage.remove(
key: String, key: String,
callback: (result: Result<Boolean>) -> Unit callback: (result: Result<Boolean>) -> Unit = {}
) = remove(CloudStorageKey(key), callback) ) = remove(CloudStorageKey(key), callback)
fun CloudStorage.remove( fun CloudStorage.remove(
keys: Array<CloudStorageKey>, keys: Array<CloudStorageKey>,
callback: (result: Result<Boolean>) -> Unit callback: (result: Result<Boolean>) -> Unit = {}
) = removeItems( ) = removeItems(
keys keys
) { e, v -> callback(resultsToResult(e, v)) } ) { e, v -> callback(resultsToResult(e, v)) }
fun CloudStorage.remove( fun CloudStorage.remove(
keys: Array<String>, keys: Array<String>,
callback: (result: Result<Boolean>) -> Unit callback: (result: Result<Boolean>) -> Unit = {}
) = remove( ) = remove(
Array(keys.size) { Array(keys.size) {
CloudStorageKey(keys[it]) CloudStorageKey(keys[it])
@@ -109,7 +109,7 @@ fun CloudStorage.remove(
key: String, key: String,
key2: String, key2: String,
vararg otherKeys: String, vararg otherKeys: String,
callback: (result: Result<Boolean>) -> Unit callback: (result: Result<Boolean>) -> Unit = {}
) = remove( ) = remove(
arrayOf(key, key2) + otherKeys, arrayOf(key, key2) + otherKeys,
callback callback

View File

@@ -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"
}
]

View File

@@ -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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), 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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), 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<WebApp>(), 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<WebApp>(), 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<WebApp>(), 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<WebApp>(), 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<WebApp>(), )
}.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<WebApp>(), )
}.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<WebApp>(), )
}.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)

View File

@@ -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<String>()
val webAppParts = mutableListOf<String>()
val extensionsParts = mutableListOf<String>()
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()
}
}

Some files were not shown because too many files have changed in this diff Show More