mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 20:10:18 +00:00
Compare commits
216 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fda53cf171 | |||
| b588622c3d | |||
| 8b64a0c94e | |||
| 959f0dffba | |||
| 8fc9185884 | |||
| 3a9cf03958 | |||
| 7cd97ac779 | |||
| c460b4eacc | |||
| 0aa58bd9f6 | |||
| a4a82f69c6 | |||
| d450ed9126 | |||
| 69c5f1ae7d | |||
| e4e8eadfb5 | |||
| c1374c118d | |||
| 6004b159ec | |||
| 67f95682d5 | |||
| 5aa5460a43 | |||
| e937845fc7 | |||
| 96f40e55bc | |||
| d3d8603c35 | |||
| 759650892c | |||
| b58550a9ec | |||
| e15817e7c5 | |||
| 4cd1316e27 | |||
| 3575a62f34 | |||
| 82f7d5bd4f | |||
| 7a5e6a69a1 | |||
| fd25db5633 | |||
| f539a24740 | |||
| 1d7b4ea862 | |||
| 2d6f296c20 | |||
| 0ba1aa1127 | |||
| ae8a461e9d | |||
| 99f16e33a6 | |||
| e029b29f7f | |||
| c04f795fdd | |||
| b873898100 | |||
| 61ac9df5e3 | |||
| b1931900e7 | |||
| fab3af48d6 | |||
| 8d7563b6e4 | |||
| 05112afe0c | |||
| 9ea06de27c | |||
| fff05a40d9 | |||
| 5c6428f220 | |||
| 766b7ca205 | |||
| 41e6c52369 | |||
| 06013f624f | |||
| d8bba89f3f | |||
| 141281f96d | |||
| be7aaa7845 | |||
| 78c224ffa8 | |||
| a08d07f7b3 | |||
| 69dde19543 | |||
| e8a3b93831 | |||
| e10caa3171 | |||
| d4fe4e09fc | |||
| ad453afba2 | |||
| a0daca28b1 | |||
| cd62a9ef3c | |||
| 3c084d70e5 | |||
| 2611d4ecc1 | |||
| b4d853dfa0 | |||
| 5044075adf | |||
| 5f2660b804 | |||
| c72dccc0f9 | |||
| 3fc1058491 | |||
| c3668e978b | |||
| 5a4a6d5710 | |||
| ed1d8beb2e | |||
| 881ede7d2a | |||
| 60d3d279e7 | |||
| 4b84518dbb | |||
| 8b451791dd | |||
| 771fb5c288 | |||
| d19ee74f8b | |||
| aaf489c2ed | |||
| 1b06b63703 | |||
| bf7fc25285 | |||
| 4df242747f | |||
| e831ca143e | |||
| 44838a2088 | |||
| 3823b03453 | |||
| ec48708195 | |||
| 6a06775bc4 | |||
| bbdff0b31a | |||
| cb4880bd00 | |||
| a18eda3db6 | |||
| d8f6429385 | |||
| be74249b67 | |||
| 69f658e4a8 | |||
| 8c51ca9d72 | |||
| 48c4a3156b | |||
| 92407c9010 | |||
| 86937cc096 | |||
| ea614b790b | |||
| c994332cb9 | |||
| 9d893ffa48 | |||
| 57d2fe85c5 | |||
| c68b148d5e | |||
| 0a0a7cea0e | |||
| ea981605f6 | |||
| fe1e65a83c | |||
| c85983bd59 | |||
| d72e1029d3 | |||
| 4b89563cff | |||
| 542079f4bf | |||
|
|
5c7164e864 | ||
| 6329905f62 | |||
| c54945e4cc | |||
| 8f20e1d617 | |||
|
|
edbfedb74e | ||
|
|
b5006cd1e0 | ||
| ca01ce7843 | |||
| 54fad3f338 | |||
| 15ef481fd7 | |||
| 91e1202674 | |||
| bdd39963a8 | |||
| 01dfedf540 | |||
| 8ded892b72 | |||
| d0b606469b | |||
| 678f79da04 | |||
| fde2c79f4c | |||
| acaf46e015 | |||
| 3f9237b5de | |||
| 3d7334dd62 | |||
| 26306f1567 | |||
| 247553d990 | |||
| 049a8a3263 | |||
| cc67a31e97 | |||
| 8791573145 | |||
| 5752f7a4fb | |||
| ade236eaa3 | |||
| e7340a483a | |||
| c7dc69d09f | |||
| c2487c5adc | |||
| 7c4808f163 | |||
| b91b516659 | |||
| 57cdc4ff2a | |||
| 864992aff0 | |||
| e18e8ba6df | |||
| 02cedc6626 | |||
| 619b890956 | |||
| 100a76a832 | |||
| c583ae6761 | |||
| 7429ffb514 | |||
| 95aeedfb94 | |||
| 095e318a78 | |||
| 4aa2d2ae41 | |||
| e936d25c13 | |||
| 97a2a5d9fd | |||
| 00ab532eac | |||
| c2cc6ee1ec | |||
| d20b94e52c | |||
| 9f3cc6eafb | |||
| f86a095421 | |||
| b0c6b80d8b | |||
| 1df653f428 | |||
| 8dfaca7648 | |||
| 04db76831f | |||
| f2e9bf6bd8 | |||
| cde8fdeffd | |||
| e74f339ae2 | |||
| ff7702486f | |||
| c7818fe4df | |||
| 8243acd69e | |||
| 8081602a39 | |||
| 6fd85dbc56 | |||
| 8d6f4ba136 | |||
| b95b339ad1 | |||
| 637979100b | |||
| 4067439a13 | |||
| 03583ff6c1 | |||
| c1330f8e32 | |||
| db36c6aacb | |||
| 757e317e70 | |||
| cb708a1ba4 | |||
| 551276f78e | |||
| 88339a4977 | |||
| a13371e14c | |||
| ad7fdc6211 | |||
| c870a48a22 | |||
| 3149fd0231 | |||
| 7430490499 | |||
| 416187e079 | |||
| e7aec75aca | |||
| 95a466a08b | |||
| 507cb2af26 | |||
| 126a07cdc7 | |||
| 27a24a18a6 | |||
| 562e8c7429 | |||
| be027efc43 | |||
| e55195b308 | |||
| 14afb59b5f | |||
| 6b23347d56 | |||
| f54843fb60 | |||
| 8a3538d9c7 | |||
| e3db4250bb | |||
| 4643ac906a | |||
| 497974e45c | |||
| 78a00f0efb | |||
| 14ecb9d948 | |||
| c759b9a466 | |||
| 58c1f2ee6a | |||
| 9d16ca3b7e | |||
| 9d40e598f1 | |||
| f1be8bf16e | |||
| 56a8804e99 | |||
| 1e73aac750 | |||
| 82c6eda0b7 | |||
| e9ff93cde1 | |||
| 9b179ea1c9 | |||
| 72d20d2344 | |||
| bcd288fe05 | |||
| 75477060e9 | |||
| 60df609486 |
260
CHANGELOG.md
260
CHANGELOG.md
@@ -1,5 +1,263 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 3.2.7
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.12.13` -> `0.12.17`
|
||||
* `Ktor`: `2.1.1` -> `2.1.2`
|
||||
* `Utils`:
|
||||
* Next classes become typealiases instead of classes:
|
||||
* `ReplyKeyboardBuilder`
|
||||
* `ReplyKeyboardRowBuilder`
|
||||
* `InlineKeyboardBuilder`
|
||||
* `InlineKeyboardRowBuilder`
|
||||
|
||||
## 3.2.6
|
||||
|
||||
* `Core`:
|
||||
* Fixes in `ChatMemberSerializer#serialize` method
|
||||
* Migration of `EntitiesBuilder` from `Utils` to `Core`
|
||||
* `API`:
|
||||
* All the extensions related to text messages (replies, sending, editing) got their duplicates with `buildEntities` lambda and separator
|
||||
* `Utils`:
|
||||
* Migration of `EntitiesBuilder` from `Utils` to `Core`
|
||||
|
||||
## 3.2.5
|
||||
|
||||
* `Common`:
|
||||
* Improve support of new exceptions recovering mechanism
|
||||
|
||||
## 3.2.4
|
||||
|
||||
* `API`:
|
||||
* New `edit`'s with chats and message ids
|
||||
|
||||
## 3.2.3
|
||||
|
||||
* `Core`:
|
||||
* Fixes in `DeleteMyCommands`
|
||||
|
||||
## 3.2.2
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.12.10` -> `0.12.13`
|
||||
* `Core`:
|
||||
* `MessageIdentifier` has been renamed to `MessageId`
|
||||
* `API`:
|
||||
* New `reply`'es with chats and message ids
|
||||
|
||||
## 3.2.1
|
||||
|
||||
* `Versions`:
|
||||
* `Ktor`: `2.1.0` -> `2.1.1`
|
||||
* `Korlibs`: `3.0.0` -> `3.1.0`
|
||||
* `MicroUtils`: `0.12.4` -> `0.12.10`
|
||||
|
||||
## 3.2.0
|
||||
|
||||
**Since this update, `RequestsExecutor#execute` may throw only `BotException`. In case you wish to handle some exceptions from `execute` you must catch `BotException` and handle its `cause`**
|
||||
|
||||
* `Versions`:
|
||||
* `Serialization`: `1.4.0-RC` -> `1.4.0`
|
||||
* `MicroUtils`: `0.12.1` -> `0.12.4`
|
||||
* `Core`:
|
||||
* `SetWebhook#allowedUpdates` now is `ALL_UPDATES_LIST` by default instead of `null`
|
||||
* `API`:
|
||||
* Extension `TelegramBot#setWebhook` parameter `allowedUpdates` now is `ALL_UPDATES_LIST` by default instead of `null`
|
||||
* `Utils`:
|
||||
* All related to long polling extensions parameters `allowedUpdates` now are `ALL_UPDATES_LIST` by default instead of `null`
|
||||
|
||||
## 3.1.1
|
||||
|
||||
* `Common`:
|
||||
* Complete Bot API 6.2 implementation
|
||||
|
||||
## 3.1.0
|
||||
|
||||
**This update contains including of Bot API 6.2**
|
||||
|
||||
* `Versions`:
|
||||
* `Ktor`: `2.0.3` -> `2.1.0`
|
||||
* `MicroUtils`: `0.12.0` -> `0.12.1`
|
||||
* `Core`:
|
||||
* Add support of `custom emoji`s
|
||||
* Add support of `sticker_type`
|
||||
|
||||
## 3.0.2
|
||||
|
||||
**ALL OLD DEPRECATIONS HAVE BEEN REMOVED**
|
||||
|
||||
**`copyMessage` HAVE CHANGED THEIR SIGNATURE BY SWAPPING FROM AND TO CHAT IDS**
|
||||
|
||||
* `Versions`:
|
||||
* `Kotlin`: `1.6.21` -> `1.7.10`
|
||||
* `Serialization`: `1.3.3` -> `1.4.0-RC`
|
||||
* `Korlibs`: `2.7.0` -> `3.0.0`
|
||||
* `UUID`: `0.4.1` -> `0.5.0`
|
||||
* `MicroUtils`: `0.11.13` -> `0.12.0`
|
||||
* `Core`:
|
||||
* Interface `ReplyMakrup` has been renamed to `WithReplyMarkup` to correspond its purpose
|
||||
* Data class `LeftChatMember` has been renamed to `LeftChatMemberEvent` to avoid type ambiguite with the other `LeftChatMember`
|
||||
* `ForwardInfo` hierarchy has been fully reworked:
|
||||
* `AnonymousForwardInfo` -> `ForwardInfo.ByAnonymous`
|
||||
* `UserForwardInfo` -> `ForwardInfo.ByUser`
|
||||
* `ForwardFromPublicChatInfo` -> `ForwardInfo.PublicChat`
|
||||
* `ForwardFromChannelInfo` -> `ForwardInfo.PublicChat.FromChannel`
|
||||
* `ForwardFromSupergroupInfo` -> `ForwardInfo.PublicChat.FromSupergroup`
|
||||
* `ForwardInfo.PublicChat.SentByChannel` ___has been created___
|
||||
* `API`:
|
||||
* Add new `Flow`-based live locations API
|
||||
* Add `sendLocation` for sending live locations
|
||||
* `Utils`:
|
||||
* **BREAKING CHANGES** Now all new classcasts (like `Chat.ifPrivateChat` etc.) have been rewritten to be generated with `ksp` and `kotlin poet`
|
||||
|
||||
*Note: Versions 3.0.0 and 3.0.1 have been published with errors and didn't recommend to use*
|
||||
|
||||
## 2.2.2
|
||||
|
||||
* `Utils`:
|
||||
* `buildEntities` now is inline
|
||||
* `Behaviour Builder`:
|
||||
* Fixes in `CallbackQuery` triggers
|
||||
|
||||
## 2.2.1
|
||||
|
||||
* `Versions`:
|
||||
* `Coroutines`: `1.6.3` -> `1.6.4`
|
||||
* `MicroUtils`: `0.11.12` -> `0.11.13`
|
||||
* `Core`:
|
||||
* New `typealiase`s for `CommonMessage` with all supported content types, more info: [PR](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/629)
|
||||
* `Utils`:
|
||||
* New extensions for all types of messages `*.withContentOrNull` and `*.withContentOrThrow` as analogies to the same ones from class casts
|
||||
|
||||
## 2.2.0
|
||||
|
||||
* `Core`:
|
||||
* For `CopyMessage` order of parameters has been changed
|
||||
* `ReplyForce` defaults changes:
|
||||
* All old companion properties (like `ReplyForce.ReplyForceSelective`) have been renamed:
|
||||
* `ReplyForceSelective` -> `Selective`
|
||||
* `ReplyForceNonSelective` -> `NonSelective`
|
||||
* `ReplyForceDefault` -> `Default`
|
||||
* New companion functions:
|
||||
* `ReplyForce#Selective`
|
||||
* `ReplyForce#NonSelective`
|
||||
* Rename `CreatorChatMember` -> `OwnerChatMember`
|
||||
* `API`:
|
||||
* For `copyMessage` order of parameters has been changed
|
||||
* `Utils`:
|
||||
* New extension `Message#sameChat`
|
||||
* New extension `Message#sameMessage`
|
||||
* New functions `flatInlineKeyboard` and `flatReplyKeyboard`
|
||||
* Experimentally add new triple of class casts: `if*`, `*OrNull` and `*OrThrow`
|
||||
|
||||
## 2.1.3
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.11.9` -> `0.11.12`
|
||||
* `Utils`:
|
||||
* Rename `UserId` extension `link` to `userLink`
|
||||
* `Core`
|
||||
* `ChatJoinRequest#inviteLink` is nullable due to the fact that join requests without link do not require invite link
|
||||
|
||||
## 2.1.2
|
||||
|
||||
* `Versions`:
|
||||
* `Coroutines`: `1.6.1` -> `1.6.3`
|
||||
* `Ktor`: `2.0.2` -> `2.0.3`
|
||||
* `MicroUtils`: `0.11.6` -> `0.11.9`
|
||||
|
||||
## 2.1.1
|
||||
|
||||
* `API`:
|
||||
* Now it is possible to edit any message text via `editMessageText` (but with warning)
|
||||
* Now it is possible to edit any message caption via `editMessageCaption` (but with warning)
|
||||
* Media message caption edit method (`editMessageCaption`) now returns the message with the same generic type (as it must be in telegram system)
|
||||
* New extensions `TelegramBot#edit` has been added for all possible editions types
|
||||
* New extensions `TelegramBot#send` has been added for all possible sending types
|
||||
* New extensions `TelegramBot#delete` has been added
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.11.3` -> `0.11.6`
|
||||
|
||||
## 2.1.0
|
||||
|
||||
__This update contains including of [Telegram Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)__
|
||||
|
||||
* Add support of functionality for `WebApp`s from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of functionality for premium feature from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of `addedToAttachmentMenu` in `CommonUser` from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of `secret_token` in `SetWebhook` request from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of `createInvoiceLink` request from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
|
||||
## 2.0.3
|
||||
|
||||
* `Core`:
|
||||
* New function `regularln` for simple creating of `RegularTextSource` with new line in the end
|
||||
* `API`:
|
||||
* New function `downloadFileToTemp` for simple downloading of file in filesystem and manipulation with avoiding of direct using input streams and other low-level things
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.11.0` -> `0.11.3`
|
||||
|
||||
## 2.0.2
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.10.8` -> `0.11.0`
|
||||
* `UUID`: `0.4.0` -> `0.4.1`
|
||||
|
||||
## 2.0.1
|
||||
|
||||
* `Versions`:
|
||||
* `Ktor`: `2.0.1` -> `2.0.2`
|
||||
* `MicroUtils`: `0.10.5` -> `0.10.8`
|
||||
* `Utils`:
|
||||
* `TelegramBot#longPolling` now accepts `UpdatesFilter` instead of `FlowsUpdatesFilter`
|
||||
|
||||
## 2.0.0
|
||||
|
||||
___ALL PREVIOUS DEPRECATIONS HAVE BEEN REMOVED___
|
||||
|
||||
* `Behaviour Builder`:
|
||||
* Mappers have been removed from waiters extensions
|
||||
* Triggers extensions now will use filtering inside of context receiver instead of passing the filters into `BehaviourContext`. That means that in the subcontext will not be used preinstalled filters for their `BehaviourContext` and filter of trigger will not be used in subcontext
|
||||
* Waiters do not take count parameter anymore
|
||||
* Waiters do not take filter parameter anymore. Use flows filters
|
||||
* `Utils`:
|
||||
* Add opportunity to get event messages with specific `ChatEvent` type using `withEvent`/`requireWithEvent` (by analog with `withEvent` and `requireWithEvent`)
|
||||
|
||||
## 1.1.3
|
||||
|
||||
* `Behaviour Builder with FSM`:
|
||||
* Typealias `StateHandlingErrorHandler` from `1.1.2` has been deprecated and should be replaced with the new one from microutils
|
||||
|
||||
## 1.1.2
|
||||
|
||||
* `Core`:
|
||||
* Rename of `TelegramAPIUrlsKeeper#checkWebAppLink` -> `TelegramAPIUrlsKeeper#checkWebAppData` (fix of [#591](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/591))
|
||||
* `Behaviour Builder with FSM`:
|
||||
* New typealias `StateHandlingErrorHandler`
|
||||
* `BehaviourBuilderWithFSM` now accepts new parameter `onStateHandlingErrorHandler` which will be used in case if state has not been successfully completed
|
||||
|
||||
## 1.1.1
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils.Crypto` will not be provided with that library anymore. Instead, it is recommended to use `Korlibs.Krypto`. You still can add crypto from microutils using next groovy dependency: `dev.inmo:micro_utils.crypto:$micro_utils_version`
|
||||
* `Core`:
|
||||
* Improvements in `TelegramAPIUrlsKeeper#checkWebAppLink`
|
||||
* New field in `TelegramAPIUrlsKeeper#webAppDataSecretKeyHash`
|
||||
* `Behaviour Builder`:
|
||||
* Extension `TelegramBot#buildBehaviour` now returns `BehaviourContext`
|
||||
|
||||
## 1.1.0
|
||||
|
||||
* `Utils`:
|
||||
* New parameter `additionalApplicationEngineEnvironmentConfigurator` in `RequestsExecutor#setWebhookInfoAndStartListenWebhooks` and `startListenWebhooks`
|
||||
|
||||
## 1.0.1
|
||||
|
||||
* `Versions`:
|
||||
* `Serialization`: `1.3.2` -> `1.3.3`
|
||||
* `MicroUtils`: `0.10.3` -> `0.10.4`
|
||||
|
||||
## 1.0.0
|
||||
|
||||
__All the `tgbotapi.extensions.*` packages have been removed__
|
||||
@@ -7,7 +265,7 @@ __All the `tgbotapi.extensions.*` packages have been removed__
|
||||
* `Versions`:
|
||||
* `Kotlin`: `1.6.10` -> `1.6.21`
|
||||
* `Ktor`: `1.6.8` -> `2.0.1`
|
||||
* `MicroUtils`: `0.9.24` -> `0.10.2`
|
||||
* `MicroUtils`: `0.9.24` -> `0.10.3`
|
||||
* `Core`:
|
||||
* **`Ktor` package renamed. Migration:** `dev.inmo.tgbotapi.bot.Ktor` -> `dev.inmo.tgbotapi.bot.ktor`
|
||||
* **`CallbackQuery` package renamed. Migration:** `dev.inmo.tgbotapi.types.CallbackQuery([\s\\.])` -> `dev.inmo.tgbotapi.types.queries.callback$1`
|
||||
|
||||
19
README.md
19
README.md
@@ -1,8 +1,17 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-16-2022)
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#august-12-2022)
|
||||
|
||||
| [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) [](https://t.me/InMoTelegramBotAPI) |
|
||||
|:---:|
|
||||
| [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||
|:---:|:---:|
|
||||
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
||||
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
||||
|
||||
<!--- [](https://t.me/InMoTelegramBotAPI) --->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://t.me/InMoTelegramBotAPI">
|
||||
<img src="./resources/tg_channel_qr.jpg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||
|
||||
@@ -107,5 +116,5 @@ suspend fun main() {
|
||||
### More examples
|
||||
|
||||
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
|
||||
always welcome in our [wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/About-this-project) and
|
||||
always welcome in our [bookstack](https://bookstack.inmo.dev/books/telegrambotapi) and
|
||||
[chat](https://t.me/InMoTelegramBotAPIChat).
|
||||
|
||||
21
build.gradle
21
build.gradle
@@ -6,19 +6,21 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
|
||||
classpath libs.kotlin.gradle.plugin
|
||||
classpath libs.kotlin.ksp.plugin
|
||||
classpath libs.kotlin.serialization.plugin
|
||||
classpath libs.kotlin.dokka.plugin
|
||||
classpath libs.github.release.plugin
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
||||
}
|
||||
|
||||
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
if (it != rootProject.findProject("docs")) {
|
||||
tasks.whenTaskAdded { task ->
|
||||
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
||||
@@ -27,6 +29,7 @@ allprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
apply from: "./extensions.gradle"
|
||||
|
||||
private String getCurrentVersionChangelog() {
|
||||
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
||||
@@ -48,7 +51,7 @@ if (new File(projectDir, "secret.gradle").exists()) {
|
||||
owner "InsanusMokrassar"
|
||||
repo "TelegramBotAPI"
|
||||
|
||||
tagName "$library_version"
|
||||
tagName "v$library_version"
|
||||
releaseName "$library_version"
|
||||
targetCommitish "$library_version"
|
||||
|
||||
|
||||
@@ -1,45 +1,17 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "org.jetbrains.dokka" version "$dokka_version"
|
||||
id "org.jetbrains.dokka"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
project.description = "Full collection of all built-in tgbotapi tools"
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
|
||||
api project(":tgbotapi.core")
|
||||
api project(":tgbotapi.api")
|
||||
api project(":tgbotapi.utils")
|
||||
@@ -58,12 +30,13 @@ kotlin {
|
||||
|
||||
private List<SourceDirectorySet> findSourcesWithName(String... approximateNames) {
|
||||
return parent.subprojects
|
||||
.findAll { it != project }
|
||||
.collectMany { it.kotlin.sourceSets }
|
||||
.findAll { sourceSet -> approximateNames.any {
|
||||
nameToFilter -> sourceSet.name.contains(nameToFilter)
|
||||
}
|
||||
}.collect { it.kotlin }
|
||||
.findAll { it != project && it.hasProperty("kotlin") }
|
||||
.collectMany { it.kotlin.sourceSets }
|
||||
.findAll { sourceSet ->
|
||||
approximateNames.any { nameToFilter ->
|
||||
sourceSet.name.contains(nameToFilter)
|
||||
}
|
||||
}.collect { it.kotlin }
|
||||
}
|
||||
|
||||
Object callback = {
|
||||
@@ -103,8 +76,3 @@ Object callback = {
|
||||
|
||||
tasks.dokkaGfm(callback)
|
||||
tasks.dokkaHtml(callback)
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
8
extensions.gradle
Normal file
8
extensions.gradle
Normal file
@@ -0,0 +1,8 @@
|
||||
allprojects {
|
||||
ext {
|
||||
mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization.gradle"
|
||||
mppJsProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJsProject.gradle"
|
||||
|
||||
publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle"
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,5 @@ kotlin.js.generate.externals=true
|
||||
kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
kotlin_version=1.6.21
|
||||
kotlin_coroutines_version=1.6.1
|
||||
kotlin_serialisation_runtime_version=1.3.2
|
||||
klock_version=2.7.0
|
||||
uuid_version=0.4.0
|
||||
ktor_version=2.0.1
|
||||
|
||||
micro_utils_version=0.10.3
|
||||
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
|
||||
dokka_version=1.6.21
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=1.0.0
|
||||
|
||||
github_release_plugin_version=2.3.7
|
||||
library_version=3.2.7
|
||||
|
||||
68
gradle/libs.versions.toml
Normal file
68
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,68 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "1.7.10"
|
||||
kotlin-serialization = "1.4.0"
|
||||
kotlin-coroutines = "1.6.4"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "3.1.0"
|
||||
uuid = "0.5.0"
|
||||
ktor = "2.1.2"
|
||||
|
||||
ksp = "1.7.10-1.0.6"
|
||||
kotlin-poet = "1.12.0"
|
||||
|
||||
microutils = "0.12.17"
|
||||
|
||||
github-release-plugin = "2.4.1"
|
||||
|
||||
[libraries]
|
||||
|
||||
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
|
||||
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
|
||||
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlin-serialization" }
|
||||
kotlin-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlin-serialization" }
|
||||
kotlin-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" }
|
||||
kotlin-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" }
|
||||
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
|
||||
kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kotlin" }
|
||||
|
||||
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
||||
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
||||
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
|
||||
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
|
||||
|
||||
javax-activation = { module = "javax.activation:activation", version.ref = "javax-activation" }
|
||||
|
||||
korlibs-klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "korlibs" }
|
||||
korlibs-krypto = { module = "com.soywiz.korlibs.krypto:krypto", version.ref = "korlibs" }
|
||||
|
||||
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
|
||||
|
||||
microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.ref = "microutils" }
|
||||
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" }
|
||||
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
|
||||
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", 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-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
||||
|
||||
# ksp dependencies
|
||||
|
||||
kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" }
|
||||
ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
|
||||
|
||||
# buildscript classpaths
|
||||
|
||||
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
kotlin-ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
|
||||
kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||
kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "kotlin" }
|
||||
github-release-plugin = { module = "com.github.breadmoirai:github-release", version.ref = "github-release-plugin" }
|
||||
|
||||
[plugins]
|
||||
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
|
||||
32
mppJsProject.gradle
Normal file
32
mppJsProject.gradle
Normal file
@@ -0,0 +1,32 @@
|
||||
project.version = "$version"
|
||||
project.group = "$group"
|
||||
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
js (IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation libs.kotlin
|
||||
api libs.kotlin.serialization
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.common
|
||||
implementation libs.kotlin.test.annotations.common
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.js
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
mppProjectWithSerialization.gradle
Normal file
47
mppProjectWithSerialization.gradle
Normal file
@@ -0,0 +1,47 @@
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js (IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation libs.kotlin
|
||||
api libs.kotlin.serialization
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.common
|
||||
implementation libs.kotlin.test.annotations.common
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.js
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
BIN
resources/tg_channel_qr.jpg
Normal file
BIN
resources/tg_channel_qr.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 593 KiB |
@@ -12,6 +12,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
include ":tgbotapi.core"
|
||||
include ":tgbotapi.ksp"
|
||||
include ":tgbotapi.api"
|
||||
include ":tgbotapi.utils"
|
||||
include ":tgbotapi.behaviour_builder"
|
||||
|
||||
@@ -1,56 +1,20 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor"
|
||||
|
||||
apply from: "../publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api project(":tgbotapi.core")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
|
||||
@@ -3,26 +3,40 @@ package dev.inmo.tgbotapi.extensions.api
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.DeleteMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier
|
||||
messageId: MessageId
|
||||
) = execute(
|
||||
DeleteMessage(chatId, messageId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
messageId: MessageId
|
||||
) = deleteMessage(chat.id, messageId)
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
message: Message
|
||||
) = deleteMessage(message.chat, message.messageId)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId
|
||||
) = deleteMessage(chatId, messageId)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chat: Chat,
|
||||
messageId: MessageId
|
||||
) = deleteMessage(chat, messageId)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
message: Message
|
||||
) = deleteMessage(message)
|
||||
|
||||
suspend fun Message.delete(
|
||||
requestsExecutor: TelegramBot
|
||||
) = requestsExecutor.deleteMessage(this)
|
||||
|
||||
@@ -3,14 +3,14 @@ package dev.inmo.tgbotapi.extensions.api
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.ForwardMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false
|
||||
) = execute(
|
||||
@@ -20,7 +20,7 @@ suspend fun TelegramBot.forwardMessage(
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false
|
||||
) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification, protectContent)
|
||||
@@ -28,7 +28,7 @@ suspend fun TelegramBot.forwardMessage(
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false
|
||||
) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification, protectContent)
|
||||
@@ -36,7 +36,7 @@ suspend fun TelegramBot.forwardMessage(
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChat: Chat,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false
|
||||
) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification, protectContent)
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.abstracts.*
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.math.ceil
|
||||
|
||||
@Serializable
|
||||
data class EditLiveLocationInfo(
|
||||
override val latitude: Double,
|
||||
override val longitude: Double,
|
||||
override val horizontalAccuracy: Meters? = null,
|
||||
override val heading: Degrees? = null,
|
||||
override val proximityAlertRadius: Meters? = null,
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : Locationed, HorizontallyAccured, ProximityAlertable, Headed, WithReplyMarkup
|
||||
|
||||
/**
|
||||
* Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing,
|
||||
* the message will be sent again and new edits will be applied to the new message
|
||||
*/
|
||||
suspend fun TelegramBot.handleLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
locationsFlow: Flow<EditLiveLocationInfo>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
var currentLiveLocationMessage: ContentMessage<LocationContent>? = null
|
||||
val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
|
||||
while (isActive) {
|
||||
delay(liveTimeMillis)
|
||||
// Remove previous location message info to resend live location message
|
||||
currentLiveLocationMessage = null
|
||||
}
|
||||
}
|
||||
locationsFlow.collect {
|
||||
val capturedLiveLocationMessage = currentLiveLocationMessage
|
||||
if (capturedLiveLocationMessage == null) {
|
||||
updateMessageJob.start()
|
||||
currentLiveLocationMessage = sendLiveLocation(
|
||||
chatId,
|
||||
it.latitude,
|
||||
it.longitude,
|
||||
ceil(liveTimeMillis.toDouble() / 1000).toInt(),
|
||||
it.horizontalAccuracy,
|
||||
it.heading,
|
||||
it.proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
it.replyMarkup
|
||||
)
|
||||
} else {
|
||||
editLiveLocation(
|
||||
capturedLiveLocationMessage,
|
||||
it.latitude,
|
||||
it.longitude,
|
||||
it.horizontalAccuracy,
|
||||
it.heading,
|
||||
it.proximityAlertRadius,
|
||||
it.replyMarkup
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
|
||||
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
|
||||
*/
|
||||
@JvmName("handleLiveLocationWithLocation")
|
||||
@JsName("handleLiveLocationWithLocation")
|
||||
suspend fun TelegramBot.handleLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
locationsFlow: Flow<Location>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
chatId,
|
||||
locationsFlow.map {
|
||||
EditLiveLocationInfo(
|
||||
it.latitude,
|
||||
it.longitude,
|
||||
it.horizontalAccuracy,
|
||||
(it as? LiveLocation) ?.heading,
|
||||
(it as? LiveLocation) ?.proximityAlertRadius,
|
||||
(it as? WithReplyMarkup) ?.replyMarkup as? InlineKeyboardMarkup
|
||||
)
|
||||
},
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
|
||||
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
|
||||
*/
|
||||
@JvmName("handleLiveLocationWithLatLong")
|
||||
@JsName("handleLiveLocationWithLatLong")
|
||||
suspend fun TelegramBot.handleLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
locationsFlow: Flow<Pair<Double, Double>>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
chatId,
|
||||
locationsFlow.map { (lat, long) ->
|
||||
EditLiveLocationInfo(
|
||||
lat,
|
||||
long
|
||||
)
|
||||
},
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
@@ -92,7 +92,7 @@ suspend fun TelegramBot.startLiveLocation(
|
||||
initProximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocationProvider {
|
||||
@@ -137,7 +137,7 @@ suspend fun TelegramBot.startLiveLocation(
|
||||
initProximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocationProvider = startLiveLocation(
|
||||
@@ -170,7 +170,7 @@ suspend fun TelegramBot.startLiveLocation(
|
||||
initProximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocationProvider = startLiveLocation(
|
||||
@@ -203,7 +203,7 @@ suspend fun TelegramBot.startLiveLocation(
|
||||
initProximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocationProvider = startLiveLocation(
|
||||
|
||||
@@ -13,7 +13,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
*/
|
||||
suspend fun TelegramBot.stopPoll(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopPoll(chatId, messageId, replyMarkup)
|
||||
@@ -25,7 +25,7 @@ suspend fun TelegramBot.stopPoll(
|
||||
*/
|
||||
suspend fun TelegramBot.stopPoll(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopPoll(chat.id, messageId, replyMarkup)
|
||||
|
||||
|
||||
@@ -3,19 +3,19 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.pinChatMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
disableNotification: Boolean = false
|
||||
) = execute(PinChatMessage(chatId, messageId, disableNotification))
|
||||
|
||||
suspend fun TelegramBot.pinChatMessage(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
disableNotification: Boolean = false
|
||||
) = pinChatMessage(chat.id, messageId, disableNotification)
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.unpinChatMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier? = null
|
||||
messageId: MessageId? = null
|
||||
) = execute(UnpinChatMessage(chatId, messageId))
|
||||
|
||||
suspend fun TelegramBot.unpinChatMessage(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier? = null
|
||||
messageId: MessageId? = null
|
||||
) = unpinChatMessage(chat.id, messageId)
|
||||
|
||||
suspend fun TelegramBot.unpinChatMessage(
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedWithTextSources
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.caption.editMessageCaption
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.media.editMessageMedia
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
import dev.inmo.tgbotapi.types.media.TelegramMedia
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||
import dev.inmo.tgbotapi.utils.buildEntities
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun <T> TelegramBot.edit(
|
||||
message: ContentMessage<T>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message, text, parseMode, replyMarkup)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun <T> TelegramBot.edit(
|
||||
message: ContentMessage<T>,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message, entities, replyMarkup)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<LocationContent>,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(
|
||||
chatId, messageId, location, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat, messageId, location, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<LocationContent>,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message, location, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chatId, messageId, media, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chat, messageId, media, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<MediaContent>,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(message, media, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chat, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(message, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = edit(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
@@ -1,92 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
message: ContentMessage<LocationContent>,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chatId, messageId, location, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat, messageId, location, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
message: ContentMessage<LocationContent>,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message, location, replyMarkup)
|
||||
@@ -1,25 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
import dev.inmo.tgbotapi.requests.edit.location.live.EditInlineMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(inlineMessageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(inlineMessageId, location, replyMarkup)
|
||||
@@ -1,43 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
|
||||
import dev.inmo.tgbotapi.requests.edit.location.live.StopChatMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(chatId, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(chat, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
message: ContentMessage<LocationContent>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(message, replyMarkup)
|
||||
@@ -1,17 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
|
||||
import dev.inmo.tgbotapi.requests.edit.location.live.StopInlineMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(inlineMessageId, replyMarkup)
|
||||
@@ -1,42 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chat, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(message, replyMarkup)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.requests.edit.reply_markup.EditInlineMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(inlineMessageId, replyMarkup)
|
||||
@@ -6,12 +6,14 @@ import dev.inmo.tgbotapi.requests.edit.caption.EditChatMessageCaption
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -19,7 +21,7 @@ import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
@@ -33,7 +35,7 @@ suspend fun TelegramBot.editMessageCaption(
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
@@ -48,8 +50,9 @@ suspend fun <T> TelegramBot.editMessageCaption(
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) as ContentMessage<T>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +61,7 @@ suspend fun <T> TelegramBot.editMessageCaption(
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -71,7 +74,7 @@ suspend fun TelegramBot.editMessageCaption(
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageCaption(chat.id, messageId, entities, replyMarkup)
|
||||
@@ -84,6 +87,20 @@ suspend fun <T> TelegramBot.editMessageCaption(
|
||||
message: ContentMessage<T>,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup) as ContentMessage<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not media message this method will throw an exception")
|
||||
suspend fun <T> TelegramBot.editMessageCaption(
|
||||
message: Message,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
*/
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
@@ -34,7 +34,7 @@ suspend fun TelegramBot.editLiveLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
@@ -63,7 +63,7 @@ suspend fun TelegramBot.editLiveLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -78,7 +78,7 @@ suspend fun TelegramBot.editLiveLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.location.live
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.location.live.StopChatMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
@@ -15,7 +15,7 @@ import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
*/
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopChatMessageLiveLocation(
|
||||
@@ -29,7 +29,7 @@ suspend fun TelegramBot.stopLiveLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(chat.id, messageId, replyMarkup)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.media.EditChatMessageMedia
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.media.TelegramMedia
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
@@ -16,7 +16,7 @@ import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageMedia(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -29,7 +29,7 @@ suspend fun TelegramBot.editMessageMedia(
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageMedia(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.reply_markup
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.reply_markup.EditChatMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
@@ -14,7 +14,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||
@@ -26,7 +26,7 @@ suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
|
||||
|
||||
|
||||
@@ -4,12 +4,15 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -17,7 +20,7 @@ import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
@@ -32,7 +35,7 @@ suspend fun TelegramBot.editMessageText(
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
@@ -57,7 +60,7 @@ suspend fun TelegramBot.editMessageText(
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
@@ -65,18 +68,70 @@ suspend fun TelegramBot.editMessageText(
|
||||
EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
@@ -87,3 +142,65 @@ suspend fun TelegramBot.editMessageText(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: Message,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: Message,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: Message,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
@@ -6,6 +6,9 @@ import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||
import dev.inmo.tgbotapi.utils.buildEntities
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -29,3 +32,27 @@ suspend fun TelegramBot.editMessageText(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup))
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
|
||||
@@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.message.content.GameContent
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
userId: UserId,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier
|
||||
messageId: MessageId
|
||||
) = execute(
|
||||
GetGameHighScoresByChat(userId, chatId, messageId)
|
||||
)
|
||||
@@ -19,7 +19,7 @@ suspend fun TelegramBot.getGameScore(
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
user: CommonUser,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier
|
||||
messageId: MessageId
|
||||
) = getGameScore(
|
||||
user.id, chatId, messageId
|
||||
)
|
||||
@@ -27,7 +27,7 @@ suspend fun TelegramBot.getGameScore(
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
userId: UserId,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
messageId: MessageId
|
||||
) = getGameScore(
|
||||
userId, chat.id, messageId
|
||||
)
|
||||
@@ -35,7 +35,7 @@ suspend fun TelegramBot.getGameScore(
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
user: CommonUser,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
messageId: MessageId
|
||||
) = getGameScore(
|
||||
user.id, chat.id, messageId
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ suspend fun TelegramBot.setGameScore(
|
||||
userId: UserId,
|
||||
score: Long,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = execute(
|
||||
@@ -23,7 +23,7 @@ suspend fun TelegramBot.setGameScore(
|
||||
user: CommonUser,
|
||||
score: Long,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
@@ -34,7 +34,7 @@ suspend fun TelegramBot.setGameScore(
|
||||
userId: UserId,
|
||||
score: Long,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
@@ -45,7 +45,7 @@ suspend fun TelegramBot.setGameScore(
|
||||
user: CommonUser,
|
||||
score: Long,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetCustomEmojiStickers
|
||||
import dev.inmo.tgbotapi.requests.get.GetStickerSet
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickers(
|
||||
customEmojiIds: List<CustomEmojiId>
|
||||
) = execute(
|
||||
GetCustomEmojiStickers(customEmojiIds)
|
||||
)
|
||||
|
||||
@JvmName("getCustomEmojiStickersWithStringsList")
|
||||
@JsName("getCustomEmojiStickersWithStringsList")
|
||||
suspend fun TelegramBot.getCustomEmojiStickers(
|
||||
customEmojiIds: List<String>
|
||||
) = getCustomEmojiStickers(customEmojiIds.map(::CustomEmojiId))
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrNull(
|
||||
customEmojiId: CustomEmojiId
|
||||
) = getCustomEmojiStickers(listOf(customEmojiId)).firstOrNull()
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrThrow(
|
||||
customEmojiId: CustomEmojiId
|
||||
) = getCustomEmojiStickers(listOf(customEmojiId)).first()
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrNull(
|
||||
customEmojiId: String
|
||||
) = getCustomEmojiStickerOrNull(CustomEmojiId(customEmojiId))
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrThrow(
|
||||
customEmojiId: String
|
||||
) = getCustomEmojiStickerOrThrow(CustomEmojiId(customEmojiId))
|
||||
@@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -16,17 +16,28 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(fromChatId, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -35,16 +46,16 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -52,16 +63,16 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -69,48 +80,16 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChatId, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChat, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -119,16 +98,26 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(fromChatId, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -137,15 +126,15 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(fromChat.id, messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -153,15 +142,15 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(fromChatId, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -169,15 +158,47 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(fromChat.id, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -189,10 +210,10 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChatId, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(message.chat, message.messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -204,7 +225,228 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChat, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(
|
||||
toChatId,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChatId,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(
|
||||
toChatId,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChatId,
|
||||
messageId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
fromChat: Chat,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.media.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
@@ -23,7 +23,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
): List<MediaGroupMessage<MediaGroupContent>> {
|
||||
val first = messages.first().content.toMediaGroupMemberTelegramMedia().let {
|
||||
@@ -62,7 +62,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChat.id, messages, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
@@ -77,7 +77,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChat, update.data, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
@@ -92,7 +92,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChat.id, update, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
@@ -106,7 +106,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
): List<MediaGroupMessage<MediaGroupContent>> {
|
||||
val first = messages.first().content.toMediaGroupMemberTelegramMedia().let {
|
||||
@@ -140,7 +140,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChat.id, messages, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
@@ -154,7 +154,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChat, update.data, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
@@ -168,6 +168,6 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChat.id, update, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.*
|
||||
import dev.inmo.tgbotapi.extensions.api.send.games.sendGame
|
||||
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
||||
import dev.inmo.tgbotapi.extensions.api.send.payments.sendInvoice
|
||||
@@ -10,7 +11,6 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.rawSendingMediaGroupsWarning
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.media.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@@ -24,11 +24,15 @@ import dev.inmo.tgbotapi.types.games.Game
|
||||
import dev.inmo.tgbotapi.types.location.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import dev.inmo.tgbotapi.types.venue.Venue
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
|
||||
// Contact
|
||||
@@ -206,6 +210,36 @@ suspend inline fun TelegramBot.reply(
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.reply(
|
||||
to: Message,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.reply(
|
||||
to: Message,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Venue
|
||||
|
||||
@@ -943,19 +977,30 @@ suspend inline fun TelegramBot.reply(
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, to.chat.id, messageId, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
to.chat.id,
|
||||
fromChatId,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
to.messageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
fromChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
messageId: MessageId,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -995,6 +1040,80 @@ suspend fun TelegramBot.reply(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||
*
|
||||
* @see handleLiveLocation
|
||||
*/
|
||||
suspend fun TelegramBot.reply(
|
||||
message: Message,
|
||||
locationsFlow: Flow<EditLiveLocationInfo>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = handleLiveLocation(
|
||||
message.chat.id,
|
||||
locationsFlow,
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
message.messageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
|
||||
/**
|
||||
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||
*
|
||||
* @see handleLiveLocation
|
||||
*/
|
||||
@JvmName("replyLiveLocationWithLocation")
|
||||
@JsName("replyLiveLocationWithLocation")
|
||||
suspend fun TelegramBot.reply(
|
||||
message: Message,
|
||||
locationsFlow: Flow<Location>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
message.chat.id,
|
||||
locationsFlow,
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
message.messageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||
*
|
||||
* @see handleLiveLocation
|
||||
*/
|
||||
@JvmName("replyLiveLocationWithLatLong")
|
||||
@JsName("replyLiveLocationWithLatLong")
|
||||
suspend fun TelegramBot.reply(
|
||||
message: Message,
|
||||
locationsFlow: Flow<Pair<Double, Double>>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
message.chat.id,
|
||||
locationsFlow,
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
message.messageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.reply(
|
||||
to: Message,
|
||||
mediaFile: TelegramMediaFile,
|
||||
@@ -1156,7 +1275,7 @@ suspend fun TelegramBot.reply(
|
||||
suspend fun TelegramBot.reply(
|
||||
to: Message,
|
||||
content: TextedMediaContent,
|
||||
entities: List<TextSource>,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,7 @@ suspend fun <T> TelegramBot.withAction(
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
val botActionJob = CoroutineScope(coroutineContext).launch {
|
||||
val botActionJob = CoroutineScope(currentCoroutineContext()).launch {
|
||||
while (isActive) {
|
||||
delay(refreshTime)
|
||||
safelyWithoutExceptions {
|
||||
|
||||
@@ -17,7 +17,7 @@ suspend fun TelegramBot.sendContact(
|
||||
lastName: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -35,7 +35,7 @@ suspend fun TelegramBot.sendContact(
|
||||
contact: Contact,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -55,7 +55,7 @@ suspend fun TelegramBot.sendContact(
|
||||
lastName: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendContact(
|
||||
@@ -71,7 +71,7 @@ suspend fun TelegramBot.sendContact(
|
||||
contact: Contact,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendContact(
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.send
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendDice
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
|
||||
@@ -17,7 +17,7 @@ suspend fun TelegramBot.sendDice(
|
||||
animationType: DiceAnimationType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -33,7 +33,7 @@ suspend fun TelegramBot.sendDice(
|
||||
animationType: DiceAnimationType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDice(chat.id, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendLiveLocation(
|
||||
chatId,
|
||||
latitude,
|
||||
longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chatId,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
latitude,
|
||||
longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chat: Chat,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -2,12 +2,14 @@ package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||
import dev.inmo.tgbotapi.utils.buildEntities
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -20,7 +22,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -38,7 +40,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(
|
||||
@@ -56,7 +58,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -73,7 +75,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -88,13 +90,46 @@ suspend fun TelegramBot.sendMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
@@ -105,13 +140,46 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(
|
||||
chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
@@ -122,11 +190,44 @@ suspend fun TelegramBot.sendMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chat: Chat,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chat: Chat,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -138,7 +239,40 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chat: Chat,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chat: Chat,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -3,10 +3,10 @@ package dev.inmo.tgbotapi.extensions.api.send
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendStaticLocation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -19,7 +19,7 @@ suspend fun TelegramBot.sendLocation(
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendStaticLocation(
|
||||
@@ -40,11 +40,11 @@ suspend fun TelegramBot.sendLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chatId,
|
||||
@@ -68,7 +68,7 @@ suspend fun TelegramBot.sendLocation(
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
@@ -87,11 +87,11 @@ suspend fun TelegramBot.sendLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
@@ -115,7 +115,7 @@ suspend fun TelegramBot.sendStaticLocation(
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chatId, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
||||
|
||||
@@ -125,11 +125,11 @@ suspend fun TelegramBot.sendStaticLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendStaticLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chatId, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
||||
|
||||
@@ -144,7 +144,7 @@ suspend fun TelegramBot.sendStaticLocation(
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chat.id, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
||||
|
||||
@@ -154,10 +154,10 @@ suspend fun TelegramBot.sendStaticLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendStaticLocation(
|
||||
chat: Chat,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chat.id, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
||||
@@ -24,7 +24,7 @@ suspend fun TelegramBot.sendVenue(
|
||||
googlePlaceType: GooglePlaceType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -62,7 +62,7 @@ suspend fun TelegramBot.sendVenue(
|
||||
googlePlaceType: GooglePlaceType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
@@ -97,7 +97,7 @@ suspend fun TelegramBot.sendVenue(
|
||||
googlePlaceType: GooglePlaceType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
@@ -132,7 +132,7 @@ suspend fun TelegramBot.sendVenue(
|
||||
googlePlaceType: GooglePlaceType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
@@ -161,7 +161,7 @@ suspend fun TelegramBot.sendVenue(
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -185,7 +185,7 @@ suspend fun TelegramBot.sendVenue(
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.send.games
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.games.SendGame
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.games.Game
|
||||
@@ -17,7 +17,7 @@ suspend fun TelegramBot.sendGame(
|
||||
gameShortName: String,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -35,7 +35,7 @@ suspend fun TelegramBot.sendGame(
|
||||
gameShortName: String,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
@@ -51,7 +51,7 @@ suspend fun TelegramBot.sendGame(
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
@@ -67,7 +67,7 @@ suspend fun TelegramBot.sendGame(
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendAnimation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -26,7 +26,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -61,7 +61,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
@@ -83,7 +83,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -102,7 +102,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -122,7 +122,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -155,7 +155,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
@@ -176,7 +176,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -194,7 +194,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -26,7 +26,7 @@ suspend fun TelegramBot.sendAudio(
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -62,7 +62,7 @@ suspend fun TelegramBot.sendAudio(
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -79,7 +79,7 @@ suspend fun TelegramBot.sendAudio(
|
||||
title: String? = audio.title,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -96,7 +96,7 @@ suspend fun TelegramBot.sendAudio(
|
||||
title: String? = audio.title,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chat.id, audio, text, parseMode, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -116,7 +116,7 @@ suspend inline fun TelegramBot.sendAudio(
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -150,7 +150,7 @@ suspend inline fun TelegramBot.sendAudio(
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -166,7 +166,7 @@ suspend inline fun TelegramBot.sendAudio(
|
||||
title: String? = audio.title,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -182,7 +182,7 @@ suspend inline fun TelegramBot.sendAudio(
|
||||
title: String? = audio.title,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chat.id, audio, entities, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendDocument
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -23,7 +23,7 @@ suspend fun TelegramBot.sendDocument(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
@@ -55,7 +55,7 @@ suspend fun TelegramBot.sendDocument(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
@@ -72,7 +72,7 @@ suspend fun TelegramBot.sendDocument(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
@@ -91,7 +91,7 @@ suspend fun TelegramBot.sendDocument(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
@@ -108,7 +108,7 @@ suspend inline fun TelegramBot.sendDocument(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
@@ -138,7 +138,7 @@ suspend inline fun TelegramBot.sendDocument(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
@@ -154,7 +154,7 @@ suspend inline fun TelegramBot.sendDocument(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
@@ -172,7 +172,7 @@ suspend inline fun TelegramBot.sendDocument(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.media.*
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.media.*
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
@@ -22,7 +22,7 @@ suspend fun TelegramBot.sendMediaGroup(
|
||||
media: List<MediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = execute(
|
||||
SendMediaGroup<MediaGroupContent>(
|
||||
@@ -39,7 +39,7 @@ suspend fun TelegramBot.sendMediaGroup(
|
||||
media: List<MediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendMediaGroup(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -55,7 +55,7 @@ suspend fun TelegramBot.sendMediaGroup(
|
||||
media: List<MediaGroupContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendMediaGroup(
|
||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -71,7 +71,7 @@ suspend fun TelegramBot.sendMediaGroup(
|
||||
media: List<MediaGroupContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendMediaGroup(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -85,7 +85,7 @@ suspend fun TelegramBot.sendPlaylist(
|
||||
media: List<AudioMediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = execute(
|
||||
SendPlaylist(
|
||||
@@ -101,7 +101,7 @@ suspend fun TelegramBot.sendPlaylist(
|
||||
media: List<AudioMediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendPlaylist(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -116,7 +116,7 @@ suspend fun TelegramBot.sendPlaylist(
|
||||
media: List<AudioContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendPlaylist(
|
||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -131,7 +131,7 @@ suspend fun TelegramBot.sendPlaylist(
|
||||
media: List<AudioContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendPlaylist(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -145,7 +145,7 @@ suspend fun TelegramBot.sendDocumentsGroup(
|
||||
media: List<DocumentMediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = execute(
|
||||
SendDocumentsGroup(
|
||||
@@ -161,7 +161,7 @@ suspend fun TelegramBot.sendDocumentsGroup(
|
||||
media: List<DocumentMediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendDocumentsGroup(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -176,7 +176,7 @@ suspend fun TelegramBot.sendDocumentsGroup(
|
||||
media: List<DocumentContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendDocumentsGroup(
|
||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -191,7 +191,7 @@ suspend fun TelegramBot.sendDocumentsGroup(
|
||||
media: List<DocumentContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendDocumentsGroup(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -205,7 +205,7 @@ suspend fun TelegramBot.sendVisualMediaGroup(
|
||||
media: List<VisualMediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = execute(
|
||||
SendVisualMediaGroup(
|
||||
@@ -221,7 +221,7 @@ suspend fun TelegramBot.sendVisualMediaGroup(
|
||||
media: List<VisualMediaGroupMemberTelegramMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendVisualMediaGroup(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -236,7 +236,7 @@ suspend fun TelegramBot.sendVisualMediaGroup(
|
||||
media: List<VisualMediaGroupContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendVisualMediaGroup(
|
||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
@@ -251,7 +251,7 @@ suspend fun TelegramBot.sendVisualMediaGroup(
|
||||
media: List<VisualMediaGroupContent>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = sendVisualMediaGroup(
|
||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendPhoto
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -22,7 +22,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -50,7 +50,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -66,7 +66,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -82,7 +82,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photo, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -98,7 +98,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -114,7 +114,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photoSize, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -130,7 +130,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -156,7 +156,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -171,7 +171,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -186,7 +186,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photo, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -201,7 +201,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photoSize.fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -216,7 +216,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photoSize, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendSticker
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
@@ -18,7 +18,7 @@ suspend fun TelegramBot.sendSticker(
|
||||
sticker: InputFile,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -34,7 +34,7 @@ suspend fun TelegramBot.sendSticker(
|
||||
sticker: InputFile,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat.id, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -48,7 +48,7 @@ suspend fun TelegramBot.sendSticker(
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chatId, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -62,7 +62,7 @@ suspend fun TelegramBot.sendSticker(
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVideo
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -26,7 +26,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -59,7 +59,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -79,7 +79,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -96,7 +96,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -115,7 +115,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -146,7 +146,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -165,7 +165,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -181,7 +181,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVideoNote
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.files.VideoNoteFile
|
||||
@@ -21,7 +21,7 @@ suspend fun TelegramBot.sendVideoNote(
|
||||
size: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -48,7 +48,7 @@ suspend fun TelegramBot.sendVideoNote(
|
||||
videoNote: VideoNoteFile,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(
|
||||
@@ -67,7 +67,7 @@ suspend fun TelegramBot.sendVideoNote(
|
||||
size: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(chat.id, videoNote, thumb, duration, size, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -81,7 +81,7 @@ suspend fun TelegramBot.sendVideoNote(
|
||||
videoNote: VideoNoteFile,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(chat.id, videoNote, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVoice
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -23,7 +23,7 @@ suspend fun TelegramBot.sendVoice(
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -53,7 +53,7 @@ suspend fun TelegramBot.sendVoice(
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(chat.id, voice, text, parseMode, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -69,7 +69,7 @@ suspend fun TelegramBot.sendVoice(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(
|
||||
@@ -87,7 +87,7 @@ suspend fun TelegramBot.sendVoice(
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(chat.id, voice, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -104,7 +104,7 @@ suspend inline fun TelegramBot.sendVoice(
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -132,7 +132,7 @@ suspend inline fun TelegramBot.sendVoice(
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(chat.id, voice, entities, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -147,7 +147,7 @@ suspend inline fun TelegramBot.sendVoice(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(
|
||||
@@ -163,7 +163,7 @@ suspend inline fun TelegramBot.sendVoice(
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(chat.id, voice, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.payments
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink
|
||||
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||
|
||||
suspend fun TelegramBot.createInvoiceLink(
|
||||
title: String,
|
||||
description: String,
|
||||
payload: String,
|
||||
providerToken: String,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
maxTipAmount: Int? = null,
|
||||
suggestedTipAmounts: List<Int>? = null,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
requirePhoneNumber: Boolean = false,
|
||||
requireEmail: Boolean = false,
|
||||
requireShippingAddress: Boolean = false,
|
||||
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||
shouldSendEmailToProvider: Boolean = false,
|
||||
priceDependOnShipAddress: Boolean = false
|
||||
) = execute(
|
||||
CreateInvoiceLink(title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress)
|
||||
)
|
||||
@@ -33,7 +33,7 @@ suspend fun TelegramBot.sendInvoice(
|
||||
priceDependOnShipAddress: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -65,7 +65,7 @@ suspend fun TelegramBot.sendInvoice(
|
||||
priceDependOnShipAddress: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll
|
||||
import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -25,7 +25,7 @@ suspend fun TelegramBot.sendRegularPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -48,7 +48,7 @@ suspend fun TelegramBot.sendRegularPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -67,7 +67,7 @@ suspend fun TelegramBot.sendRegularPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
@@ -89,7 +89,7 @@ suspend fun TelegramBot.sendRegularPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
@@ -113,7 +113,7 @@ suspend fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -138,7 +138,7 @@ suspend fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
@@ -162,7 +162,7 @@ suspend fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
@@ -186,7 +186,7 @@ suspend fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
@@ -209,7 +209,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
@@ -233,7 +233,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
@@ -256,7 +256,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
@@ -279,7 +279,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.*
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = execute(
|
||||
CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = execute(
|
||||
CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = createNewMaskAnimatedStickerSet(
|
||||
user.id, name, title, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = createNewMaskAnimatedStickerSet(
|
||||
user.id, name, title, sticker, emojis, maskPosition
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.*
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = execute(
|
||||
CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = execute(
|
||||
CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = createNewMaskStickerSet(
|
||||
user.id, name, title, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = createNewMaskStickerSet(
|
||||
user.id, name, title, sticker, emojis, maskPosition
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.*
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = execute(
|
||||
CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = execute(
|
||||
CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = createNewMaskVideoStickerSet(
|
||||
user.id, name, title, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition
|
||||
) = createNewMaskVideoStickerSet(
|
||||
user.id, name, title, sticker, emojis, maskPosition
|
||||
)
|
||||
@@ -0,0 +1,50 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.*
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String
|
||||
) = execute(
|
||||
CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String
|
||||
) = execute(
|
||||
CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String
|
||||
) = createNewRegularAnimatedStickerSet(
|
||||
user.id, name, title, sticker, emojis
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String
|
||||
) = createNewRegularAnimatedStickerSet(
|
||||
user.id, name, title, sticker, emojis
|
||||
)
|
||||
@@ -0,0 +1,50 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.*
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String
|
||||
) = execute(
|
||||
CreateNewRegularStickerSet(userId, name, title, sticker, emojis)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String
|
||||
) = execute(
|
||||
CreateNewRegularStickerSet(userId, name, title, sticker, emojis)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String
|
||||
) = createNewRegularStickerSet(
|
||||
user.id, name, title, sticker, emojis
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String
|
||||
) = createNewRegularStickerSet(
|
||||
user.id, name, title, sticker, emojis
|
||||
)
|
||||
@@ -0,0 +1,50 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.*
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String
|
||||
) = execute(
|
||||
CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String
|
||||
) = execute(
|
||||
CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String
|
||||
) = createNewRegularVideoStickerSet(
|
||||
user.id, name, title, sticker, emojis
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String
|
||||
) = createNewRegularVideoStickerSet(
|
||||
user.id, name, title, sticker, emojis
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.webhook.SetWebhook
|
||||
import dev.inmo.tgbotapi.types.ALL_UPDATES_LIST
|
||||
|
||||
/**
|
||||
* Use this method to send information about webhook (like [url])
|
||||
@@ -12,11 +13,12 @@ suspend fun TelegramBot.setWebhookInfo(
|
||||
url: String,
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
|
||||
url, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
|
||||
)
|
||||
)
|
||||
|
||||
@@ -28,11 +30,12 @@ suspend fun TelegramBot.setWebhookInfo(
|
||||
certificate: FileId,
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
|
||||
)
|
||||
)
|
||||
|
||||
@@ -44,10 +47,11 @@ suspend fun TelegramBot.setWebhookInfo(
|
||||
certificate: MultipartFile,
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
|
||||
)
|
||||
)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.files
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.common.filename
|
||||
import dev.inmo.micro_utils.coroutines.doOutsideOfCoroutine
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||
import dev.inmo.tgbotapi.utils.fileExtension
|
||||
import io.ktor.util.cio.use
|
||||
import io.ktor.util.cio.writeChannel
|
||||
import io.ktor.utils.io.copyTo
|
||||
import kotlinx.coroutines.job
|
||||
import java.io.File
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
suspend fun TelegramBot.downloadFileToTemp(
|
||||
filePath: String
|
||||
): File {
|
||||
return downloadFile(
|
||||
filePath,
|
||||
File.createTempFile(uuid4().toString(), "_temp").apply {
|
||||
deleteOnExit()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.downloadFileToTemp(
|
||||
pathedFile: PathedFile
|
||||
) = downloadFileToTemp(
|
||||
pathedFile.filePath
|
||||
).apply {
|
||||
runCatching {
|
||||
renameTo(File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}"))
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.downloadFileToTemp(
|
||||
fileId: FileId
|
||||
) = downloadFileToTemp(
|
||||
getFileAdditionalInfo(fileId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFileToTemp(
|
||||
file: TelegramMediaFile
|
||||
): File = downloadFileToTemp(
|
||||
getFileAdditionalInfo(file)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFileToTemp(
|
||||
file: MediaContent
|
||||
) = downloadFileToTemp(
|
||||
getFileAdditionalInfo(file.media)
|
||||
)
|
||||
@@ -1,56 +1,20 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
project.description = "Behaviour Builder extension with built-in FSM"
|
||||
project.description = "Behaviour Builder DSL"
|
||||
|
||||
apply from: "../publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api project(":tgbotapi.behaviour_builder")
|
||||
api "dev.inmo:micro_utils.fsm.common:$micro_utils_version"
|
||||
api libs.microutils.fsm.common
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.micro_utils.fsm.common.*
|
||||
import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler
|
||||
import dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
||||
@@ -46,16 +47,52 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
|
||||
broadcastChannelsSize: Int,
|
||||
onBufferOverflow: BufferOverflow,
|
||||
upstreamUpdatesFlow: Flow<Update>?,
|
||||
triggersHolder: TriggersHolder,
|
||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||
triggersHolder: TriggersHolder
|
||||
): BehaviourContextWithFSM<T>
|
||||
|
||||
fun copy(
|
||||
bot: TelegramBot = this.bot,
|
||||
scope: CoroutineScope = this.scope,
|
||||
broadcastChannelsSize: Int = 100,
|
||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||
): BehaviourContextWithFSM<T> = copy(
|
||||
bot,
|
||||
scope,
|
||||
broadcastChannelsSize,
|
||||
onBufferOverflow,
|
||||
upstreamUpdatesFlow,
|
||||
triggersHolder
|
||||
)
|
||||
|
||||
fun copy(
|
||||
bot: TelegramBot = this.bot,
|
||||
scope: CoroutineScope = this.scope,
|
||||
broadcastChannelsSize: Int = 100,
|
||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||
): BehaviourContextWithFSM<T> = copy(
|
||||
bot,
|
||||
scope,
|
||||
broadcastChannelsSize,
|
||||
onBufferOverflow,
|
||||
upstreamUpdatesFlow,
|
||||
triggersHolder,
|
||||
onStateHandlingErrorHandler
|
||||
)
|
||||
|
||||
companion object {
|
||||
operator fun <T : State> invoke(
|
||||
behaviourContext: BehaviourContext,
|
||||
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||
statesManager: StatesManager<T>
|
||||
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers)
|
||||
statesManager: StatesManager<T>,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, onStateHandlingErrorHandler)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,16 +121,22 @@ inline fun <reified I : O, O: State> BehaviourContextWithFSM<O>.strictlyOn(handl
|
||||
/**
|
||||
* Default realization of [BehaviourContextWithFSM]. It uses [behaviourContext] as a base for this object as
|
||||
* [BehaviourContext], but managing substates contexts updates for avoiding of updates lost between states
|
||||
* @param onStateHandlingErrorHandler Will be used in case if state handling has not been successfully completed in [launchStateHandling]
|
||||
*/
|
||||
class DefaultBehaviourContextWithFSM<T : State>(
|
||||
private val behaviourContext: BehaviourContext,
|
||||
private val statesManager: StatesManager<T>,
|
||||
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>
|
||||
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||
private val onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||
) : BehaviourContext by behaviourContext, BehaviourContextWithFSM<T> {
|
||||
private val updatesFlows = mutableMapOf<Any, DefaultBehaviourContextWithFSM<T>>()
|
||||
private val additionalHandlers = mutableListOf<BehaviourWithFSMStateHandlerHolder<*, T>>()
|
||||
private var actualHandlersList = additionalHandlers + handlers
|
||||
|
||||
override suspend fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>): T? {
|
||||
return launchStateHandling(state, handlers, onStateHandlingErrorHandler)
|
||||
}
|
||||
|
||||
private fun getSubContext(context: Any) = updatesFlows.getOrPut(context) {
|
||||
createSubContext()
|
||||
}
|
||||
@@ -169,11 +212,26 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
broadcastChannelsSize: Int,
|
||||
onBufferOverflow: BufferOverflow,
|
||||
upstreamUpdatesFlow: Flow<Update>?,
|
||||
triggersHolder: TriggersHolder,
|
||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||
triggersHolder: TriggersHolder
|
||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter),
|
||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
||||
handlers,
|
||||
statesManager
|
||||
statesManager,
|
||||
onStateHandlingErrorHandler
|
||||
)
|
||||
|
||||
override fun copy(
|
||||
bot: TelegramBot,
|
||||
scope: CoroutineScope,
|
||||
broadcastChannelsSize: Int,
|
||||
onBufferOverflow: BufferOverflow,
|
||||
upstreamUpdatesFlow: Flow<Update>?,
|
||||
triggersHolder: TriggersHolder,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T>
|
||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
||||
handlers,
|
||||
statesManager,
|
||||
onStateHandlingErrorHandler
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,18 +4,14 @@ import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.micro_utils.fsm.common.*
|
||||
import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager
|
||||
import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo
|
||||
import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler
|
||||
import dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Deprecated("Will be removed soon")
|
||||
typealias BehaviourContextWithFSMBuilder<T> = BehaviourContextWithFSM<T>
|
||||
|
||||
/**
|
||||
* Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot],
|
||||
@@ -33,6 +29,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||
DefaultBehaviourContext(
|
||||
@@ -41,7 +38,8 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
upstreamUpdatesFlow = upstreamUpdatesFlow
|
||||
),
|
||||
presetHandlers,
|
||||
statesManager
|
||||
statesManager,
|
||||
onStateHandlingErrorHandler
|
||||
).apply { block() }
|
||||
|
||||
/**
|
||||
@@ -55,6 +53,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): Pair<DefaultBehaviourContextWithFSM<T>, Job> = buildBehaviourWithFSM(
|
||||
upstreamUpdatesFlow,
|
||||
@@ -62,6 +61,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
onStateHandlingErrorHandler,
|
||||
block
|
||||
).run {
|
||||
this to scope.launch {
|
||||
@@ -94,6 +94,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||
DefaultBehaviourContext(
|
||||
@@ -102,7 +103,8 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow
|
||||
),
|
||||
presetHandlers,
|
||||
statesManager
|
||||
statesManager,
|
||||
onStateHandlingErrorHandler
|
||||
).apply { block() }
|
||||
|
||||
/**
|
||||
@@ -121,6 +123,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
) = FlowsUpdatesFilter().let {
|
||||
buildBehaviourWithFSM(
|
||||
@@ -129,6 +132,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
onStateHandlingErrorHandler,
|
||||
block
|
||||
).run {
|
||||
start()
|
||||
|
||||
@@ -5,6 +5,8 @@ import dev.inmo.micro_utils.fsm.common.State
|
||||
import dev.inmo.micro_utils.fsm.common.StatesManager
|
||||
import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager
|
||||
import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo
|
||||
import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler
|
||||
import dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
@@ -39,6 +41,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
testServer: Boolean = false,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): TelegramBot = telegramBot(
|
||||
token,
|
||||
@@ -52,6 +55,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
onStateHandlingErrorHandler,
|
||||
block
|
||||
)
|
||||
}
|
||||
@@ -76,6 +80,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
testServer: Boolean = false,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): Pair<TelegramBot, Job> {
|
||||
return telegramBot(
|
||||
@@ -89,6 +94,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
onStateHandlingErrorHandler,
|
||||
block
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ messages and filter messages for context which will be used in subcontext. Full
|
||||
telegramBotWithBehaviour(TOKEN) {
|
||||
onText(
|
||||
includeFilterByChatInBehaviourSubContext = true, // if false - last lambda will receive all messages instead of filtered by chat messages
|
||||
additionalFilter = { message: CommonMessage<TextContent> ->
|
||||
additionalFilter = { message: TextMessage ->
|
||||
// here you may check incoming message for any requirements before it will be passed to the main lambda
|
||||
}
|
||||
) { message: CommonMessage<TextContent> -> // this here is `BehaviourContext`
|
||||
) { message: TextMessage -> // this here is `BehaviourContext`
|
||||
// here put your actions and additional waiters
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ Waiters targeted to get some content "here and now", they must be used inside so
|
||||
|
||||
```kotlin
|
||||
telegramBotWithBehaviour(TOKEN) {
|
||||
onCommand("start") { message: CommonMessage<TextContent> ->
|
||||
onCommand("start") { message: TextMessage ->
|
||||
val userPhotos = waitPhoto(
|
||||
SendTextMessage(it.chat.id, "Ok, send me some photo, please"), // init request, can be any `Request` object
|
||||
{ update: Update -> // That is update which is NOT passed requirements. In current context we expect some photo, but received something else
|
||||
|
||||
@@ -1,55 +1,19 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
project.description = "Behaviour Builder DSL"
|
||||
|
||||
apply from: "../publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api project(":tgbotapi.utils")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.plus
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
/**
|
||||
* This function is used in [buildBehaviour] extensions to provide default [CoroutineScope] and allow to avoid all
|
||||
@@ -30,18 +28,18 @@ suspend fun TelegramBot.buildBehaviour(
|
||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
block: BehaviourContextReceiver<Unit>
|
||||
) {
|
||||
BehaviourContext(
|
||||
this,
|
||||
scope.let {
|
||||
if (defaultExceptionsHandler == null) {
|
||||
it
|
||||
} else {
|
||||
it + ContextSafelyExceptionHandler(defaultExceptionsHandler)
|
||||
}
|
||||
},
|
||||
flowUpdatesFilter
|
||||
).block()
|
||||
): BehaviourContext = BehaviourContext(
|
||||
this,
|
||||
scope.let {
|
||||
if (defaultExceptionsHandler == null) {
|
||||
it
|
||||
} else {
|
||||
it + ContextSafelyExceptionHandler(defaultExceptionsHandler)
|
||||
}
|
||||
},
|
||||
flowUpdatesFilter
|
||||
).apply {
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,15 +54,14 @@ suspend fun TelegramBot.buildBehaviourWithLongPolling(
|
||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
block: BehaviourContextReceiver<Unit>
|
||||
) = FlowsUpdatesFilter().let {
|
||||
buildBehaviour(
|
||||
it,
|
||||
scope,
|
||||
defaultExceptionsHandler,
|
||||
block
|
||||
): Job {
|
||||
val behaviourContext = buildBehaviour(
|
||||
scope = scope,
|
||||
defaultExceptionsHandler = defaultExceptionsHandler,
|
||||
block = block
|
||||
)
|
||||
longPolling(
|
||||
it,
|
||||
scope = scope
|
||||
return longPolling(
|
||||
behaviourContext,
|
||||
scope = behaviourContext
|
||||
)
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope {
|
||||
broadcastChannelsSize: Int = 100,
|
||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
triggersHolder: TriggersHolder = TriggersHolder(),
|
||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||
triggersHolder: TriggersHolder = TriggersHolder()
|
||||
): BehaviourContext
|
||||
}
|
||||
|
||||
@@ -66,21 +65,16 @@ class DefaultBehaviourContext(
|
||||
broadcastChannelsSize: Int = 100,
|
||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||
private val upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
override val triggersHolder: TriggersHolder = TriggersHolder(),
|
||||
private val updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||
override val triggersHolder: TriggersHolder = TriggersHolder()
|
||||
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
|
||||
|
||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
||||
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
||||
if (upstreamUpdatesFlow != null) {
|
||||
(it + upstreamUpdatesFlow).distinctUntilChanged { old, new -> old.updateId == new.updateId }
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.let {
|
||||
val updatesFilter = updatesFilter
|
||||
if (updatesFilter != null) {
|
||||
it.filter { updatesFilter(it) }
|
||||
var lastHandledUpdate = -1L
|
||||
(it + upstreamUpdatesFlow).filter {
|
||||
(it.updateId > lastHandledUpdate).also { passed -> if (passed) { lastHandledUpdate = it.updateId } }
|
||||
}
|
||||
} else {
|
||||
it
|
||||
}
|
||||
@@ -93,9 +87,8 @@ class DefaultBehaviourContext(
|
||||
broadcastChannelsSize: Int,
|
||||
onBufferOverflow: BufferOverflow,
|
||||
upstreamUpdatesFlow: Flow<Update>?,
|
||||
triggersHolder: TriggersHolder,
|
||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||
): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter)
|
||||
triggersHolder: TriggersHolder
|
||||
): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder)
|
||||
}
|
||||
|
||||
fun BehaviourContext(
|
||||
@@ -113,20 +106,17 @@ inline fun <T> BehaviourContext(
|
||||
crossinline block: BehaviourContext.() -> T
|
||||
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow, triggersHolder = triggersHolder).run(block)
|
||||
|
||||
/**
|
||||
* Creates new [BehaviourContext] using its [BehaviourContext.copy] method
|
||||
*
|
||||
* @param updatesFilter This param will not be used anymore
|
||||
*/
|
||||
fun <BC : BehaviourContext> BC.createSubContext(
|
||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>? = null,
|
||||
) = copy(
|
||||
scope = scope,
|
||||
updatesFilter = updatesFilter ?.let { _ ->
|
||||
{
|
||||
(this as? BC) ?.run {
|
||||
updatesFilter(it)
|
||||
} ?: true
|
||||
}
|
||||
},
|
||||
upstreamUpdatesFlow = updatesUpstreamFlow,
|
||||
triggersHolder = triggersHolder
|
||||
) as BC
|
||||
@@ -155,63 +145,19 @@ suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter
|
||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>? = null,
|
||||
stopOnCompletion: Boolean = true,
|
||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
||||
): T {
|
||||
return createSubContext(
|
||||
scope,
|
||||
triggersHolder,
|
||||
updatesUpstreamFlow,
|
||||
updatesFilter
|
||||
updatesUpstreamFlow
|
||||
).doInContext(
|
||||
stopOnCompletion,
|
||||
behaviourContextReceiver
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
|
||||
* using [doInContext]
|
||||
*
|
||||
* @param stopOnCompletion ___TRUE BY DEFAULT___
|
||||
*/
|
||||
@Deprecated("Renamed", ReplaceWith("createSubContextAndDoWithUpdatesFilter", "dev.inmo.tgbotapi.extensions.behaviour_builder.createSubContextAndDoWithUpdatesFilter"))
|
||||
suspend fun <T, BC : BehaviourContext> BC.doInSubContextWithUpdatesFilter(
|
||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
||||
stopOnCompletion: Boolean = true,
|
||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
||||
): T {
|
||||
return createSubContext(
|
||||
scope,
|
||||
triggersHolder,
|
||||
updatesUpstreamFlow,
|
||||
updatesFilter
|
||||
).doInContext(
|
||||
stopOnCompletion,
|
||||
behaviourContextReceiver
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Redundant", ReplaceWith("createSubContextAndDoWithUpdatesFilter", "dev.inmo.tgbotapi.extensions.behaviour_builder.createSubContextAndDoWithUpdatesFilter"))
|
||||
suspend fun <T> BehaviourContext.doInSubContext(
|
||||
stopOnCompletion: Boolean = true,
|
||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
behaviourContextReceiver: BehaviourContextReceiver<T>
|
||||
) = createSubContextAndDoWithUpdatesFilter(
|
||||
scope,
|
||||
triggersHolder,
|
||||
updatesUpstreamFlow,
|
||||
updatesFilter = null,
|
||||
stopOnCompletion,
|
||||
behaviourContextReceiver
|
||||
)
|
||||
|
||||
/**
|
||||
* This method will cancel ALL subsequent contexts, expectations and waiters
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.inmo.micro_utils.coroutines.safelyWithResult
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.flatMap
|
||||
import dev.inmo.tgbotapi.extensions.utils.flatten
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
@@ -20,7 +20,6 @@ typealias NullableRequestBuilder<T> = suspend (Update) -> Request<T>?
|
||||
|
||||
/**
|
||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
||||
* @param count If set, result [Flow] will return [count] elements on each [Flow.collect]
|
||||
* @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data
|
||||
* @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say
|
||||
* user that chain of scenario has been cancelled
|
||||
@@ -33,7 +32,6 @@ typealias NullableRequestBuilder<T> = suspend (Update) -> Request<T>?
|
||||
suspend fun <T> FlowsUpdatesFilter.expectFlow(
|
||||
bot: TelegramBot,
|
||||
initRequest: Request<*>? = null,
|
||||
count: Int? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
||||
@@ -55,19 +53,13 @@ suspend fun <T> FlowsUpdatesFilter.expectFlow(
|
||||
} else {
|
||||
result.getOrThrow()
|
||||
}
|
||||
}.flatMap()
|
||||
val result = if (count == null) {
|
||||
flow
|
||||
} else {
|
||||
flow.take(count)
|
||||
}
|
||||
}.flatten()
|
||||
initRequest ?.also { safelyWithoutExceptions { bot.execute(initRequest) } }
|
||||
return result
|
||||
return flow
|
||||
}
|
||||
|
||||
/**
|
||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
||||
* @param count If set, result [Flow] will return [count] elements on each [Flow.collect]
|
||||
* @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data
|
||||
* @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say
|
||||
* user that chain of scenario has been cancelled
|
||||
@@ -76,14 +68,14 @@ suspend fun <T> FlowsUpdatesFilter.expectFlow(
|
||||
* as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory]
|
||||
* will be called too), [errorFactory] and then will be returned null
|
||||
*/
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend fun <T> BehaviourContext.expectFlow(
|
||||
initRequest: Request<*>? = null,
|
||||
count: Int? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
||||
filter: suspend (Update) -> List<T>
|
||||
) = flowsUpdatesFilter.expectFlow(bot, initRequest, count, errorFactory, cancelRequestFactory, cancelTrigger, filter)
|
||||
) = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory, cancelRequestFactory, cancelTrigger, filter)
|
||||
|
||||
/**
|
||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
||||
@@ -103,7 +95,7 @@ suspend fun <T> FlowsUpdatesFilter.expectOne(
|
||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
||||
filter: suspend (Update) -> T?
|
||||
): T = expectFlow(bot, initRequest, 1, errorFactory, cancelRequestFactory, cancelTrigger) {
|
||||
): T = expectFlow(bot, initRequest, errorFactory, cancelRequestFactory, cancelTrigger) {
|
||||
listOfNotNull(filter.invoke(it))
|
||||
}.first()
|
||||
|
||||
@@ -117,6 +109,7 @@ suspend fun <T> FlowsUpdatesFilter.expectOne(
|
||||
* as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory]
|
||||
* will be called too), [errorFactory] and then will be returned null
|
||||
*/
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend fun <T> BehaviourContext.expectOne(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
|
||||
@@ -3,122 +3,60 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.callbackQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.queries.callback.*
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias CallbackQueryMapper<T> = suspend T.() -> T?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitCallbackQueries(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O> BehaviourContext.waitCallbackQueries(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CallbackQuery>? = null,
|
||||
mapper: suspend CallbackQuery.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asCallbackQueryUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
private suspend inline fun <reified T : CallbackQuery> BehaviourContext.waitCallbacks(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: CallbackQueryMapper<T>? = null
|
||||
) : List<T> = waitCallbackQueries<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
(it as? T) ?.let { filter(it) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (this is T) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
(it.callbackQueryUpdateOrNull() ?.data as O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitDataCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<DataCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<DataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<DataCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitGameShortNameCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<GameShortNameCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<GameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<GameShortNameCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitInlineMessageIdCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<InlineMessageIdCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<InlineMessageIdCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<InlineMessageIdCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitInlineMessageIdDataCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<InlineMessageIdDataCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<InlineMessageIdDataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<InlineMessageIdDataCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitInlineMessageIdGameShortNameCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<InlineMessageIdGameShortNameCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<InlineMessageIdGameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<InlineMessageIdGameShortNameCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitMessageCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<MessageCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<MessageCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<MessageCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitMessageDataCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<MessageDataCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<MessageDataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<MessageDataCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitMessageGameShortNameCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<MessageGameShortNameCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<MessageGameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<MessageGameShortNameCallbackQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitUnknownCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<UnknownCallbackQueryType>? = null,
|
||||
mapper: CallbackQueryMapper<UnknownCallbackQueryType>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCallbackQueries<UnknownCallbackQueryType>(initRequest, errorFactory)
|
||||
|
||||
@@ -1,49 +1,31 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatJoinRequestUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias ChatJoinRequestsMapper = suspend ChatJoinRequest.() -> ChatJoinRequest?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitChatJoinRequests(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O> BehaviourContext.internalWaitChatJoinRequests(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<ChatJoinRequest>? = null,
|
||||
mapper: suspend ChatJoinRequest.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asChatJoinRequestUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
(it.chatJoinRequestUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitChatJoinRequests(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatJoinRequest>? = null,
|
||||
mapper: ChatJoinRequestsMapper? = null
|
||||
) : List<ChatJoinRequest> = waitChatJoinRequests(
|
||||
count,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) : Flow<ChatJoinRequest> = internalWaitChatJoinRequests(
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter
|
||||
) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
}
|
||||
errorFactory
|
||||
)
|
||||
|
||||
@@ -1,74 +1,39 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
|
||||
import dev.inmo.tgbotapi.types.update.MyChatMemberUpdatedUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias ChatMemberUpdatedMapper<T> = suspend T.() -> T?
|
||||
|
||||
private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContext.waitChatMemberUpdated(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : ChatMemberUpdatedUpdate> BehaviourContext.waitChatMemberUpdatedWithFilter(
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>
|
||||
): List<ChatMemberUpdated> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<ChatMemberUpdated> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val casted = (it as? T) ?: return@expectFlow emptyList()
|
||||
if (filter == null || filter(casted)) {
|
||||
casted.data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContext.waitChatMemberUpdatedWithFilter(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter,
|
||||
) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
(it as? O) ?.data.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChatMemberUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatMemberUpdatedUpdate>? = null,
|
||||
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<ChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||
) = waitChatMemberUpdatedWithFilter<ChatMemberUpdatedUpdate>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitCommonChatMemberUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonChatMemberUpdatedUpdate>? = null,
|
||||
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<CommonChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||
) = waitChatMemberUpdatedWithFilter<CommonChatMemberUpdatedUpdate>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitMyChatMemberUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<MyChatMemberUpdatedUpdate>? = null,
|
||||
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<MyChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitChatMemberUpdatedWithFilter<MyChatMemberUpdatedUpdate>(initRequest, errorFactory)
|
||||
|
||||
@@ -1,81 +1,37 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.chosenInlineResultUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias ChosenInlineResultMapper<T> = suspend T.() -> T?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitChosenInlineResultsUpdates(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O> BehaviourContext.waitChosenInlineResults(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<ChosenInlineResult>? = null,
|
||||
mapper: suspend ChosenInlineResult.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asChosenInlineResultUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
private suspend inline fun <reified T : ChosenInlineResult> BehaviourContext.waitChosenInlineResults(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: ChosenInlineResultMapper<T>? = null
|
||||
) : List<T> = this@waitChosenInlineResults.waitChosenInlineResultsUpdates<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
(it as? T) ?.let { filter(it) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (this is T) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
(it.chosenInlineResultUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChosenInlineResult(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChosenInlineResult>? = null,
|
||||
mapper: ChosenInlineResultMapper<ChosenInlineResult>? = null
|
||||
) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitChosenInlineResults<ChosenInlineResult>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitLocationChosenInlineResult(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<LocationChosenInlineResult>? = null,
|
||||
mapper: PollMapper<LocationChosenInlineResult>? = null
|
||||
) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitChosenInlineResults<LocationChosenInlineResult>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitBaseChosenInlineResult(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<BaseChosenInlineResult>? = null,
|
||||
mapper: PollMapper<BaseChosenInlineResult>? = null
|
||||
) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitChosenInlineResults<BaseChosenInlineResult>(initRequest, errorFactory)
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
/**
|
||||
* Will filter all the messages and include required commands with [commandRegex].
|
||||
*
|
||||
* * In case you wish to get only the commands at the start of message, use [requireCommandAtStart]
|
||||
* * In case you wish to exclude messages with more than one command, you may use [requireSingleCommand]
|
||||
* * In case you wish to exclude messages with commands params, you may use [requireCommandsWithoutParams]
|
||||
*/
|
||||
suspend fun BehaviourContext.waitCommandMessage(
|
||||
commandRegex: Regex,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = channelFlow {
|
||||
triggersHolder.handleableCommandsHolder.doWithRegistration(
|
||||
commandRegex
|
||||
) {
|
||||
waitTextMessage(initRequest, errorFactory).filter {
|
||||
it.content.textSources.any { it.botCommandTextSourceOrNull() ?.command ?.matches(commandRegex) == true }
|
||||
}.collect {
|
||||
send(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitCommandMessage(
|
||||
command: String,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitCommandMessage(Regex(command), initRequest, errorFactory)
|
||||
|
||||
fun Flow<CommonMessage<TextContent>>.requireCommandAtStart() = filter {
|
||||
it.content.textSources.firstOrNull() is BotCommandTextSource
|
||||
}
|
||||
|
||||
/**
|
||||
* Subsequent [Flow] will retrieve only messages with ONE [BotCommandTextSource]. It does not guarantee that this
|
||||
* [BotCommandTextSource] will be at the start of the message
|
||||
*
|
||||
* @see requireCommandAtStart
|
||||
*/
|
||||
fun Flow<CommonMessage<TextContent>>.requireSingleCommand() = filter {
|
||||
var count = 0
|
||||
|
||||
it.content.textSources.forEach {
|
||||
if (it is BotCommandTextSource) {
|
||||
count++
|
||||
if (count > 1) {
|
||||
return@filter false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
count == 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Subsequent [Flow] will retrieve only messages without [TextContent.textSources] which are not [BotCommandTextSource]
|
||||
*/
|
||||
fun Flow<CommonMessage<TextContent>>.requireCommandsWithoutParams() = filter {
|
||||
it.content.textSources.none { it !is BotCommandTextSource }
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the commands with their arguments and source messages
|
||||
*/
|
||||
fun Flow<CommonMessage<TextContent>>.commandsWithParams(): Flow<Pair<CommonMessage<TextContent>, List<Pair<BotCommandTextSource, Array<TextSource>>>>> = mapNotNull {
|
||||
var currentCommandTextSource: BotCommandTextSource? = null
|
||||
val currentArgs = mutableListOf<TextSource>()
|
||||
val result = mutableListOf<Pair<BotCommandTextSource, Array<TextSource>>>()
|
||||
|
||||
fun addCurrentCommandToResult() {
|
||||
currentCommandTextSource ?.let {
|
||||
result.add(it to currentArgs.toTypedArray())
|
||||
currentArgs.clear()
|
||||
}
|
||||
}
|
||||
|
||||
it.content.textSources.forEach {
|
||||
it.ifBotCommandTextSource {
|
||||
addCurrentCommandToResult()
|
||||
currentCommandTextSource = it
|
||||
return@forEach
|
||||
}
|
||||
currentArgs.add(it)
|
||||
}
|
||||
addCurrentCommandToResult()
|
||||
|
||||
result.toList().takeIf { it.isNotEmpty() } ?.let { result ->
|
||||
it to result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flat [commandsWithParams]. Each [Pair] of [BotCommandTextSource] and its [Array] of arg text sources will
|
||||
* be associated with its source message
|
||||
*/
|
||||
fun Flow<CommonMessage<TextContent>>.flattenCommandsWithParams() = commandsWithParams().flatMapConcat { (message, commandsWithParams) ->
|
||||
commandsWithParams.map {
|
||||
message to it
|
||||
}.asFlow()
|
||||
}
|
||||
|
||||
/**
|
||||
* Use [flattenCommandsWithParams] and filter out the commands which do not [matches] to [commandRegex]
|
||||
*/
|
||||
fun Flow<CommonMessage<TextContent>>.commandParams(commandRegex: Regex) = flattenCommandsWithParams().filter { (_, commandWithParams) ->
|
||||
commandWithParams.first.command.matches(commandRegex)
|
||||
}
|
||||
@@ -2,276 +2,133 @@
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
typealias CommonMessageToContentMapper<T> = suspend CommonMessage<T>.() -> T?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitCommonContent(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitContent(
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: suspend CommonMessage<MessageContent>.() -> O?
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val messages = when (it) {
|
||||
is SentMediaGroupUpdate -> {
|
||||
if (includeMediaGroups) {
|
||||
it.data.map { it as CommonMessage<MessageContent> }
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
is BaseSentMessageUpdate -> listOf(it.data)
|
||||
else -> return@expectFlow emptyList()
|
||||
}
|
||||
messages.mapNotNull { message ->
|
||||
val asCommonMessage = message as CommonMessage<MessageContent>
|
||||
if (filter == null || filter(asCommonMessage)) {
|
||||
asCommonMessage.mapper()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal inline fun <reified T : MessageContent> contentConverter(
|
||||
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||
): suspend CommonMessage<MessageContent>.() -> T? = mapper ?.let {
|
||||
{
|
||||
if (content is T) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val message = (this as CommonMessage<T>)
|
||||
safelyWithoutExceptions { mapper(message) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
} ?: { content as? T }
|
||||
|
||||
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContent(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||
) : List<T> = waitCommonContent<T>(
|
||||
count,
|
||||
initRequest,
|
||||
includeMediaGroups,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
it.withContent<T>() ?.let { filter(it) } == true
|
||||
}
|
||||
},
|
||||
contentConverter(mapper)
|
||||
).toList()
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = waitContentMessage<O>(initRequest, includeMediaGroups, errorFactory).map { it.content }
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MessageContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<MessageContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitContact(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<ContactContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<ContactContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<ContactContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitDice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<DiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<DiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitGame(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<GameContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<GameContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<GameContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LocationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<LocationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<LocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitLiveLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LiveLocationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<LiveLocationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<LiveLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitStaticLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StaticLocationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<StaticLocationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<StaticLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitPoll(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<PollContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<PollContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<PollContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitText(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<TextContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<TextContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<TextContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitVenue(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VenueContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VenueContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<VenueContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<AudioMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AudioMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<DocumentMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DocumentMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitMedia(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<MediaContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MediaContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<MediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<VisualMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VisualMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitTextedMediaContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<TextedMediaContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<TextedMediaContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<TextedMediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitAnimation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<AnimationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AnimationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<AnimationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitAudio(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<AudioContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AudioContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<AudioContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitDocument(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<DocumentContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DocumentContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<DocumentContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitPhoto(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<PhotoContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<PhotoContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<PhotoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitSticker(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StickerContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<StickerContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<StickerContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideo(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<VideoContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VideoContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<VideoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoNote(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VideoNoteContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VideoNoteContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<VideoNoteContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitVoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VoiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VoiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<VoiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitInvoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<InvoiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<InvoiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<InvoiceContent>(initRequest, false, errorFactory)
|
||||
|
||||
@@ -4,33 +4,25 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias CommonMessageToCommonMessageMapper<T> = suspend CommonMessage<T>.() -> CommonMessage<T>?
|
||||
|
||||
internal suspend fun <O : MessageContent> BehaviourContext.waitCommonMessage(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: suspend CommonMessage<MessageContent>.() -> CommonMessage<O>?
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<CommonMessage<O>> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val messages = when (it) {
|
||||
@@ -45,13 +37,7 @@ internal suspend fun <O : MessageContent> BehaviourContext.waitCommonMessage(
|
||||
else -> return@expectFlow emptyList()
|
||||
}
|
||||
messages.mapNotNull { message ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val asCommonMessage = message as? CommonMessage<MessageContent> ?: return@mapNotNull null
|
||||
if (filter == null || filter(asCommonMessage)) {
|
||||
asCommonMessage.mapper()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
(message as? CommonMessage<*>) ?.withContent<O>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,209 +58,114 @@ internal inline fun <reified T : MessageContent> contentMessageConverter(
|
||||
if (content is T) this as CommonMessage<T> else null
|
||||
}
|
||||
|
||||
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContentMessage(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||
noinline mapper: CommonMessageToCommonMessageMapper<T>? = null
|
||||
) : List<CommonMessage<T>> = waitCommonMessage<T>(
|
||||
count,
|
||||
initRequest,
|
||||
includeMediaGroups,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
it.withContent<T>() ?.let { filter(it) } == true
|
||||
}
|
||||
},
|
||||
contentMessageConverter(mapper)
|
||||
).toList()
|
||||
|
||||
suspend fun BehaviourContext.waitContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<MessageContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<MessageContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitContactMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<ContactContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<ContactContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<ContactContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitDiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<DiceContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<DiceContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<DiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitGameMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<GameContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<GameContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<GameContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LocationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<LocationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<LocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitLiveLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LiveLocationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<LiveLocationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<LiveLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitStaticLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StaticLocationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<StaticLocationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<StaticLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitPollMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<PollContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<PollContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<PollContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitTextMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<TextContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<TextContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<TextContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitVenueMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VenueContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VenueContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<VenueContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<AudioMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<AudioMediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<DocumentMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<DocumentMediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitMediaMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<MediaContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<MediaContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<MediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<MediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<VisualMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VisualMediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<TextedMediaContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<TextedMediaContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<TextedMediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitAnimationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<AnimationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<AnimationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<AnimationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitAudioMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<AudioContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<AudioContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<AudioContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitDocumentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<DocumentContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<DocumentContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<DocumentContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitPhotoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<PhotoContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<PhotoContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<PhotoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitStickerMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StickerContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<StickerContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<StickerContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<VideoContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VideoContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<VideoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoNoteMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VideoNoteContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VideoNoteContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<VideoNoteContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitVoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VoiceContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VoiceContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<VoiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitInvoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<InvoiceContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<InvoiceContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<InvoiceContent>(initRequest, false, errorFactory)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.regularTextSourceOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.textsources.RegularTextSource
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
suspend fun BehaviourContext.waitDeepLinks(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
): Flow<Pair<CommonMessage<TextContent>, String>> = waitCommandMessage(
|
||||
"start",
|
||||
initRequest,
|
||||
errorFactory
|
||||
)
|
||||
.requireSingleCommand()
|
||||
.requireCommandAtStart()
|
||||
.flattenCommandsWithParams().mapNotNull {
|
||||
it.first to (it.second.second.singleOrNull() ?.regularTextSourceOrNull() ?.source ?.removePrefix(" ") ?: return@mapNotNull null)
|
||||
}
|
||||
@@ -3,250 +3,130 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asCommonMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitEditedCommonMessage(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedContent(
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = waitEditedContentMessage<O>(initRequest, includeMediaGroups, errorFactory).map { it.content }
|
||||
|
||||
suspend fun BehaviourContext.waitEditedMessageContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: suspend CommonMessage<MessageContent>.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val messages = when (it) {
|
||||
is BaseEditMessageUpdate -> {
|
||||
val commonMessage = it.data.asCommonMessage()
|
||||
if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) {
|
||||
listOf(commonMessage)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
else -> return@expectFlow emptyList()
|
||||
}
|
||||
messages.mapNotNull { message ->
|
||||
val asCommonMessage = message as CommonMessage<MessageContent>
|
||||
if (filter == null || filter(asCommonMessage)) {
|
||||
asCommonMessage.mapper()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitEditedContent(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||
) : List<T> = waitEditedCommonMessage<T>(
|
||||
count,
|
||||
initRequest,
|
||||
includeMediaGroups,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
it.withContent<T>() ?.let { filter(it) } == true
|
||||
}
|
||||
},
|
||||
contentConverter(mapper)
|
||||
)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContent<MessageContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitEditedContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MessageContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContent<MessageContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedContact(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<ContactContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<ContactContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<ContactContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedDice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<DiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DiceContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<DiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedGame(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<GameContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<GameContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<GameContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LocationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<LocationContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<LocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedLiveLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LiveLocationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<LiveLocationContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<LiveLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedStaticLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StaticLocationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<StaticLocationContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<StaticLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedText(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<TextContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<TextContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<TextContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVenue(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VenueContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VenueContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<VenueContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAudioMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<AudioMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AudioMediaGroupContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContent<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedDocumentMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<DocumentMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DocumentMediaGroupContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContent<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedMedia(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<MediaContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MediaContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContent<MediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAnyMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MediaGroupContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContent<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVisualMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<VisualMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VisualMediaGroupContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContent<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedTextedMediaContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<TextedMediaContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<TextedMediaContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContent<TextedMediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAnimation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<AnimationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AnimationContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<AnimationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAudio(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<AudioContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AudioContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContent<AudioContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedDocument(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<DocumentContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DocumentContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContent<DocumentContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedPhoto(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<PhotoContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<PhotoContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContent<PhotoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedSticker(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StickerContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<StickerContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<StickerContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVideo(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<VideoContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VideoContent>? = null
|
||||
) = waitEditedContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContent<VideoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVideoNote(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VideoNoteContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VideoNoteContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<VideoNoteContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VoiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VoiceContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<VoiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedInvoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<InvoiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<InvoiceContent>? = null
|
||||
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContent<InvoiceContent>(initRequest, false, errorFactory)
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<CommonMessage<O>> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
val messages = when (it) {
|
||||
is BaseEditMessageUpdate -> {
|
||||
val commonMessage = it.data.commonMessageOrNull() ?: return@expectFlow emptyList()
|
||||
if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) {
|
||||
listOf(commonMessage)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
else -> return@expectFlow emptyList()
|
||||
}
|
||||
messages.mapNotNull { message ->
|
||||
(message as CommonMessage<*>).withContent<O>()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitEditedMessageContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContentMessage<MessageContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitEditedContactMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<ContactContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedDiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<DiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedGameMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<GameContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<LocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedLiveLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<LiveLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedStaticLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<StaticLocationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedTextMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<TextContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVenueMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<VenueContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAudioMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContentMessage<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedDocumentMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContentMessage<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedMediaMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContentMessage<MediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAnyMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContentMessage<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVisualMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContentMessage<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedTextedMediaContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitEditedContentMessage<TextedMediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAnimationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<AnimationContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedAudioMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContentMessage<AudioContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedDocumentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContentMessage<DocumentContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedPhotoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContentMessage<PhotoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedStickerMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<StickerContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVideoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitEditedContentMessage<VideoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVideoNoteMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<VideoNoteContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedVoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<VoiceContent>(initRequest, false, errorFactory)
|
||||
suspend fun BehaviourContext.waitEditedInvoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEditedContentMessage<InvoiceContent>(initRequest, false, errorFactory)
|
||||
@@ -3,282 +3,136 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asBaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias EventMessageToEventMapper<T> = suspend ChatEventMessage<T>.() -> T?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitEventMessages(
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : ChatEvent> BehaviourContext.waitEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<ChatEvent>>? = null,
|
||||
mapper: suspend ChatEventMessage<ChatEvent>.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage()
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
private suspend inline fun <reified T : ChatEvent> BehaviourContext.waitEvents(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<ChatEventMessage<T>>? = null,
|
||||
noinline mapper: EventMessageToEventMapper<T>? = null
|
||||
) : List<T> = waitEventMessages<T>(
|
||||
initRequest,
|
||||
errorFactory,
|
||||
count,
|
||||
filter ?.let {
|
||||
{
|
||||
(it.chatEvent as? T) ?.let { filter(it as ChatEventMessage<T>) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (chatEvent is T) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val message = (this as ChatEventMessage<T>)
|
||||
if (mapper == null) {
|
||||
message.chatEvent
|
||||
} else {
|
||||
mapper(message)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.withEvent<O>() ?.chatEvent.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChannelEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<ChannelEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<ChannelEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChannelEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitPrivateEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<PrivateEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<PrivateEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<PrivateEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<ChatEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<ChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChatEvent>(initRequest, errorFactory)
|
||||
|
||||
@Deprecated("Renamed as Video instead of Voice")
|
||||
suspend fun BehaviourContext.waitVoiceChatEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
@Deprecated("Renamed as Video instead of Voice")
|
||||
suspend fun BehaviourContext.waitVoiceChatStartedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatStarted>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatStarted>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
@Deprecated("Renamed as Video instead of Voice")
|
||||
suspend fun BehaviourContext.waitVoiceChatEndedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatEnded>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatEnded>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
@Deprecated("Renamed as Video instead of Voice")
|
||||
suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatParticipantsInvited>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatParticipantsInvited>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitVideoChatEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<VideoChatEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoChatStartedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatStarted>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatStarted>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<VideoChatStarted>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoChatEndedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatEnded>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatEnded>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<VideoChatEnded>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoChatParticipantsInvitedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<VideoChatParticipantsInvited>>? = null,
|
||||
mapper: EventMessageToEventMapper<VideoChatParticipantsInvited>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<VideoChatParticipantsInvited>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<MessageAutoDeleteTimerChanged>>? = null,
|
||||
mapper: EventMessageToEventMapper<MessageAutoDeleteTimerChanged>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<MessageAutoDeleteTimerChanged>(initRequest, errorFactory)
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitPublicChatEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<PublicChatEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<PublicChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<PublicChatEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitCommonEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<CommonEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<CommonEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<CommonEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitGroupEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<GroupEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<GroupEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<GroupEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitSupergroupEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<SupergroupEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<SupergroupEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<SupergroupEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChannelChatCreatedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<ChannelChatCreated>>? = null,
|
||||
mapper: EventMessageToEventMapper<ChannelChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChannelChatCreated>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitDeleteChatPhotoEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<DeleteChatPhoto>>? = null,
|
||||
mapper: EventMessageToEventMapper<DeleteChatPhoto>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<DeleteChatPhoto>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitGroupChatCreatedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<GroupChatCreated>>? = null,
|
||||
mapper: EventMessageToEventMapper<GroupChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<GroupChatCreated>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<LeftChatMember>>? = null,
|
||||
mapper: EventMessageToEventMapper<LeftChatMember>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<LeftChatMember>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<NewChatPhoto>>? = null,
|
||||
mapper: EventMessageToEventMapper<NewChatPhoto>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<NewChatPhoto>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatMembersEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<NewChatMembers>>? = null,
|
||||
mapper: EventMessageToEventMapper<NewChatMembers>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<NewChatMembers>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatTitleEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<NewChatTitle>>? = null,
|
||||
mapper: EventMessageToEventMapper<NewChatTitle>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<NewChatTitle>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitPinnedMessageEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<PinnedMessage>>? = null,
|
||||
mapper: EventMessageToEventMapper<PinnedMessage>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<PinnedMessage>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitProximityAlertTriggeredEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<ProximityAlertTriggered>>? = null,
|
||||
mapper: EventMessageToEventMapper<ProximityAlertTriggered>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ProximityAlertTriggered>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitSupergroupChatCreatedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<SupergroupChatCreated>>? = null,
|
||||
mapper: EventMessageToEventMapper<SupergroupChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<SupergroupChatCreated>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitSuccessfulPaymentEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<SuccessfulPaymentEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<SuccessfulPaymentEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<SuccessfulPaymentEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitUserLoggedInEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<UserLoggedIn>>? = null,
|
||||
mapper: EventMessageToEventMapper<UserLoggedIn>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<UserLoggedIn>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitWebAppDataEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<PrivateEventMessage<WebAppData>>? = null,
|
||||
mapper: EventMessageToEventMapper<WebAppData>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter ?.let { { it is PrivateEventMessage && filter(it) } }, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<WebAppData>(initRequest, errorFactory)
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : ChatEvent> BehaviourContext.waitEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<ChatEventMessage<O>> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.withEvent<O>().let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChannelEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChannelEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitPrivateEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<PrivateEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitVideoChatEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<VideoChatEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoChatStartedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<VideoChatStarted>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoChatEndedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<VideoChatEnded>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoChatParticipantsInvitedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<VideoChatParticipantsInvited>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<MessageAutoDeleteTimerChanged>(initRequest, errorFactory)
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitPublicChatEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<PublicChatEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitCommonEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<CommonEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitGroupEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<GroupEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitSupergroupEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<SupergroupEvent>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChannelChatCreatedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChannelChatCreated>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitDeleteChatPhotoEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<DeleteChatPhoto>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitGroupChatCreatedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<GroupChatCreated>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitLeftChatMemberEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<LeftChatMember>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatPhotoEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<NewChatPhoto>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatMembersEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<NewChatMembers>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatTitleEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<NewChatTitle>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitPinnedMessageEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<PinnedMessage>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitProximityAlertTriggeredEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ProximityAlertTriggered>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitSupergroupChatCreatedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<SupergroupChatCreated>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitSuccessfulPaymentEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<SuccessfulPaymentEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitUserLoggedInEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<UserLoggedIn>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitWebAppDataEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<WebAppData>(initRequest, errorFactory)
|
||||
@@ -1,80 +1,36 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.inlineQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias InlineQueryMapper<T> = suspend T.() -> T?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitInlineQueries(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : InlineQuery> BehaviourContext.waitInlineQueries(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<InlineQuery>? = null,
|
||||
mapper: suspend InlineQuery.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asInlineQueryUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
private suspend inline fun <reified T : InlineQuery> BehaviourContext.waitInlines(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: InlineQueryMapper<T>? = null
|
||||
) : List<T> = waitInlineQueries<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
(it as? T) ?.let { casted -> filter(casted) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (this is T) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
(it.inlineQueryUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitAnyInlineQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<InlineQuery>? = null,
|
||||
mapper: InlineQueryMapper<InlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitInlineQueries<InlineQuery>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitBaseInlineQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<BaseInlineQuery>? = null,
|
||||
mapper: InlineQueryMapper<BaseInlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitInlineQueries<BaseInlineQuery>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitLocationInlineQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<LocationInlineQuery>? = null,
|
||||
mapper: InlineQueryMapper<LocationInlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitInlineQueries<LocationInlineQuery>(initRequest, errorFactory)
|
||||
|
||||
@@ -1,70 +1,45 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import kotlinx.coroutines.flow.take
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
typealias MediaGroupFilter<T> = suspend List<MediaGroupMessage<T>>.() -> Boolean
|
||||
typealias MediaGroupFilter<T> = SimpleFilter<List<MediaGroupMessage<T>>>
|
||||
|
||||
internal suspend inline fun <reified T : MediaGroupContent> BehaviourContext.buildMediaGroupWaiter(
|
||||
count: Int = 1,
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MediaGroupContent> BehaviourContext.buildMediaGroupWaiter(
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: MediaGroupFilter<T>? = null
|
||||
) = flowsUpdatesFilter.expectFlow(bot, initRequest, count, errorFactory) { update ->
|
||||
update.asSentMediaGroupUpdate() ?.data ?.let { mediaGroup ->
|
||||
if (mediaGroup.all { message -> message.content is T } && (filter == null || filter(mediaGroup as List<MediaGroupMessage<T>>))) {
|
||||
listOf(
|
||||
mediaGroup.map { it.content as T }
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} ?: emptyList()
|
||||
}.take(count).toList()
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<List<O>> = buildMediaGroupMessagesWaiter<O>(initRequest, errorFactory).map { it.map { it.content } }
|
||||
|
||||
suspend fun BehaviourContext.waitMediaGroup(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: MediaGroupFilter<MediaGroupContent>? = null
|
||||
) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupWaiter<MediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitPlaylist(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: MediaGroupFilter<AudioMediaGroupContent>? = null
|
||||
) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupWaiter<AudioMediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitDocumentsGroup(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: MediaGroupFilter<DocumentMediaGroupContent>? = null
|
||||
) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupWaiter<DocumentMediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVisualGallery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: MediaGroupFilter<VisualMediaGroupContent>? = null
|
||||
) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupWaiter<VisualMediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitPhotoGallery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: MediaGroupFilter<PhotoContent>? = null
|
||||
) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupWaiter<PhotoContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoGallery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: MediaGroupFilter<VideoContent>? = null
|
||||
) = buildMediaGroupWaiter(count, initRequest, errorFactory, filter)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupWaiter<VideoContent>(initRequest, errorFactory)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified T : MediaGroupContent> BehaviourContext.buildMediaGroupMessagesWaiter(
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<List<MediaGroupMessage<T>>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update ->
|
||||
update.sentMediaGroupUpdateOrNull() ?.data ?.let { mediaGroup ->
|
||||
val mapped = mediaGroup.mapNotNull { it.withContent<T>() }
|
||||
listOf(
|
||||
mapped
|
||||
)
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitMediaGroupMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupMessagesWaiter<MediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitPlaylistMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupMessagesWaiter<AudioMediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitDocumentsGroupMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupMessagesWaiter<DocumentMediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVisualGalleryMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupMessagesWaiter<VisualMediaGroupContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitPhotoGalleryMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupMessagesWaiter<PhotoContent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitVideoGalleryMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = buildMediaGroupMessagesWaiter<VideoContent>(initRequest, errorFactory)
|
||||
@@ -1,65 +1,30 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.messageUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.passportMessageOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.PassportMessage
|
||||
import dev.inmo.tgbotapi.types.passport.PassportData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportElement
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias PassportMessageMapper = suspend PassportMessage.() -> PassportData
|
||||
|
||||
@RiskFeature("Do not use this message directly, use waitPassportMessagesWith or waitAnyPassportMessages instead")
|
||||
suspend fun <O> BehaviourContext.waitPassportMessages(
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : EncryptedPassportElement> BehaviourContext.waitPassportMessagesWith(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<PassportMessage>? = null,
|
||||
mapper: suspend PassportMessage.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asMessageUpdate() ?.data ?.asPassportMessage() ?: return@expectFlow emptyList()
|
||||
if (filter == null || filter(data)) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
suspend inline fun <reified T : EncryptedPassportElement> BehaviourContext.waitPassportMessagesWith(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<PassportMessage>? = null,
|
||||
noinline mapper: PassportMessageMapper? = null
|
||||
) : List<PassportData> = waitPassportMessages(
|
||||
initRequest,
|
||||
errorFactory,
|
||||
count,
|
||||
filter
|
||||
) {
|
||||
if (passportData.data.any { it is T }) {
|
||||
if (mapper == null) {
|
||||
passportData
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
it.messageUpdateOrNull() ?.data ?.passportMessageOrNull() ?.passportData ?.data ?.filterIsInstance<O>() ?: emptyList()
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitAnyPassportMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<PassportMessage>? = null,
|
||||
mapper: PassportMessageMapper? = null
|
||||
) = waitPassportMessagesWith<EncryptedPassportElement>(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitPassportMessagesWith<EncryptedPassportElement>(initRequest, errorFactory)
|
||||
|
||||
@@ -1,64 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.pollAnswerUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitPollsAnswers(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<PollAnswer>? = null,
|
||||
mapper: suspend PollAnswer.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asPollAnswerUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
private suspend inline fun BehaviourContext.waitPollAnswers(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<PollAnswer>? = null,
|
||||
noinline mapper: PollAnswerMapper? = null
|
||||
) : List<PollAnswer> = this@waitPollAnswers.waitPollsAnswers<PollAnswer>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
(it as? PollAnswer) ?.let { filter(it) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This wait will be triggered only for stopped polls and polls, which are sent by the bot
|
||||
*/
|
||||
suspend fun BehaviourContext.waitPollAnswers(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<PollAnswer>? = null,
|
||||
mapper: PollAnswerMapper? = null
|
||||
) = waitPollAnswers(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<PollAnswer> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.pollAnswerUpdateOrNull() ?.data.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -1,59 +1,24 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.pollUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias PollMapper<T> = suspend T.() -> T?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitPollsUpdates(
|
||||
count: Int = 1,
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : Poll> BehaviourContext.waitPolls(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<Poll>? = null,
|
||||
mapper: suspend Poll.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asPollUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
private suspend inline fun <reified T : Poll> BehaviourContext.waitPolls(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: PollMapper<T>? = null
|
||||
) : List<T> = this@waitPolls.waitPollsUpdates<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
(it as? T) ?.let { filter(it) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (this is T) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
(it.pollUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,30 +26,21 @@ private suspend inline fun <reified T : Poll> BehaviourContext.waitPolls(
|
||||
*/
|
||||
suspend fun BehaviourContext.waitPollUpdates(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<Poll>? = null,
|
||||
mapper: PollMapper<Poll>? = null
|
||||
) = waitPolls(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitPolls<Poll>(initRequest, errorFactory)
|
||||
|
||||
/**
|
||||
* This wait will be triggered only for stopped polls and polls, which are sent by the bot
|
||||
*/
|
||||
suspend fun BehaviourContext.waitQuizPollUpdates(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<QuizPoll>? = null,
|
||||
mapper: PollMapper<QuizPoll>? = null
|
||||
) = waitPolls(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitPolls<QuizPoll>(initRequest, errorFactory)
|
||||
|
||||
/**
|
||||
* This wait will be triggered only for stopped polls and polls, which are sent by the bot
|
||||
*/
|
||||
suspend fun BehaviourContext.waitRegularPollUpdates(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<RegularPoll>? = null,
|
||||
mapper: PollMapper<RegularPoll>? = null
|
||||
) = waitPolls(count, initRequest, errorFactory, filter, mapper)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitPolls<RegularPoll>(initRequest, errorFactory)
|
||||
|
||||
@@ -1,49 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.preCheckoutQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitPreCheckoutQueries(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<PreCheckoutQuery>? = null,
|
||||
mapper: suspend PreCheckoutQuery.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asPreCheckoutQueryUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitPreCheckoutQueries(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<PreCheckoutQuery>? = null,
|
||||
mapper: PreCheckoutQueryMapper? = null
|
||||
) : List<PreCheckoutQuery> = waitPreCheckoutQueries(
|
||||
count,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<PreCheckoutQuery> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter
|
||||
errorFactory
|
||||
) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
it.preCheckoutQueryUpdateOrNull() ?.data.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -1,49 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.shippingQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
typealias ShippingQueryMapper = suspend ShippingQuery.() -> ShippingQuery?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitShippingQueries(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<ShippingQuery>? = null,
|
||||
mapper: suspend ShippingQuery.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val data = it.asShippingQueryUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitShippingQueries(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ShippingQuery>? = null,
|
||||
mapper: ShippingQueryMapper? = null
|
||||
) : List<ShippingQuery> = waitShippingQueries(
|
||||
count,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<ShippingQuery> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory,
|
||||
filter
|
||||
errorFactory
|
||||
) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
mapper(this)
|
||||
}
|
||||
(it.shippingQueryUpdateOrNull() ?.data).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user