mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 12:00:18 +00:00
Compare commits
299 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21f5808b12 | |||
| 64244a60fe | |||
| 4cd7fdb436 | |||
| 6daf98d47d | |||
| c260597799 | |||
| d59e204002 | |||
| 117d891ff2 | |||
| 1e451af508 | |||
| 051f5e22e7 | |||
| 6873c23309 | |||
| a65971be00 | |||
| 4b5baaff8c | |||
| 0840d2e083 | |||
| 085a225eb4 | |||
| b575871a8e | |||
| c96e162845 | |||
| c471d59b3c | |||
| 187f340e88 | |||
| 77ea1f741e | |||
| bff2713bbd | |||
| cf666aad11 | |||
| 93e72230a1 | |||
| b81308da8b | |||
| 0441b53da2 | |||
| 4853a5b3ad | |||
| 40a0d2c37d | |||
| 2e815a4c37 | |||
| 81ed820602 | |||
| b3a657b7d6 | |||
| 8247e7c69c | |||
| 67b7472868 | |||
| 13e4740d0a | |||
| 48db305541 | |||
| 6f512a144c | |||
| cf46139bef | |||
| 14a583e154 | |||
| 5b6753c484 | |||
| f153b31464 | |||
| 6f60ecbf2e | |||
| 9c57ba4da7 | |||
| d84d982eb4 | |||
|
|
2f6f40362a | ||
| e15b18fbcf | |||
| ad5cc6ade6 | |||
| 6b94215a7c | |||
| 9c98411bcb | |||
| b235ab1c28 | |||
| d4e11494e8 | |||
| e6dbf2bde9 | |||
| 5aa0284f28 | |||
| 8b2a50a21f | |||
| a7839df748 | |||
| 3155969954 | |||
| 067a0bf229 | |||
| 009991fa88 | |||
| ffbe8fc5e0 | |||
| 610ed95296 | |||
| d3f4a895ff | |||
| 51c7c376d7 | |||
| 393197eca1 | |||
| 67096f8e0e | |||
| c312a05d6b | |||
| b575695f90 | |||
| 65bcf83517 | |||
| f07a179448 | |||
| ed2c447730 | |||
| cb4c48d025 | |||
| 1a21fa85ac | |||
| 191fa5406d | |||
| 6959dacfc4 | |||
| ced11ab336 | |||
| 6686aef4fa | |||
| 9ede545e56 | |||
| a74066cf62 | |||
| 0a7e99bbb3 | |||
| 913f584469 | |||
| 20278804bf | |||
| 631f1b9427 | |||
| 5e0106beb5 | |||
| d37e01f93e | |||
|
|
d4492ec7ac | ||
| 60d24259f4 | |||
| 8e6b3b7260 | |||
| e2cbd5ee0b | |||
| 1e87677ea7 | |||
| cb3494cb39 | |||
| ce81be9dcb | |||
| 2cc02c8c85 | |||
| f5b2ee79d6 | |||
| 0ba6ebb20f | |||
| 3d2df4e255 | |||
| 33b6ff1c1e | |||
| 2859f8ca2f | |||
| f1aa67ceda | |||
| 1c66d1e2fc | |||
| 44e6d7adbc | |||
| 61a6d4a880 | |||
| e37237cb71 | |||
| 9a5a196e41 | |||
| 68f6d8553c | |||
| 6fe8e73fca | |||
| 241545c0cb | |||
| 3b2310ece1 | |||
| e1adde0978 | |||
| 3b17bce71a | |||
| 999efc64eb | |||
| 05c99642cb | |||
| cd6f4831ae | |||
| 2778315aed | |||
| ff8d67a780 | |||
| 2a5f9a629d | |||
| 75b27858dd | |||
| 034e2d7ff3 | |||
| 1f69c16f2a | |||
| 8d24512413 | |||
| 09009003e3 | |||
| 048486146c | |||
| b688fa570a | |||
| 0eba0c4e15 | |||
| f8bbfa2b1e | |||
| fec2715dc1 | |||
|
|
941a25b116 | ||
| 741d808db2 | |||
| 69683a4e6a | |||
| e5a48e9684 | |||
| 6722ab5f50 | |||
| 810b2ab5a1 | |||
| 5992fdd456 | |||
| 3c4f8787a6 | |||
| 0c24aa1270 | |||
| 988d9995c5 | |||
| f75df0a425 | |||
| 9f14eb2ca3 | |||
| 6f9f880b79 | |||
| 2d2310daca | |||
| dff04d26ca | |||
| 4390c12180 | |||
| 1b4d13e452 | |||
| afda5e0e7f | |||
| cd354e9456 | |||
| b0e32e8ad9 | |||
| 79c9e6258f | |||
| 90b9c66bea | |||
| e7b21dcd3d | |||
| e30361ad1e | |||
| d8c659f866 | |||
| 5533303d86 | |||
| 1633b9baaf | |||
| a9725eb439 | |||
| a0aadef31b | |||
| ac88fd1d02 | |||
| e3e318312d | |||
| 4c08fb7d26 | |||
| d83ff12560 | |||
| 818ef8481d | |||
| f8cd446133 | |||
| 804b991921 | |||
| 817068aa71 | |||
|
|
0cca343612 | ||
| 6532bf255b | |||
| 421d5ae9e3 | |||
| 54f1181a14 | |||
| f616a02f7c | |||
| f1deb93147 | |||
| 2300b44aae | |||
| fe88cf037a | |||
| 89920abe35 | |||
| 4c4aa491cb | |||
| f0a4425be9 | |||
| 6c8af4cab3 | |||
| 017d57e5e5 | |||
| 5a456bcdbf | |||
| 4182d8f3fe | |||
| c6e2cba09b | |||
| 8dd3eefd15 | |||
| b72d4da8f0 | |||
| ebd023669d | |||
| f7be4e557e | |||
| ec434c6af4 | |||
| 0398590de6 | |||
| 9ef1b54ada | |||
| c30ce5c803 | |||
| c0a50bccb0 | |||
| e0cd7dc512 | |||
| 6ff621b428 | |||
| 964a61749c | |||
| 17930091ac | |||
| 2271beadfb | |||
| 44c48a8462 | |||
| 4d35f89ad1 | |||
| 174706b189 | |||
| fe17312bb5 | |||
| d8b5789cd2 | |||
| f27d0916db | |||
| fa0a2818a0 | |||
| 2d3fe45389 | |||
| 02b5d282d3 | |||
| 7795bc2b50 | |||
| a95365a691 | |||
| 07082bf896 | |||
| 6a3fc47f62 | |||
| 1c94e86b40 | |||
| 0416b200b8 | |||
| 48c4e90912 | |||
| 5fc88e89b9 | |||
| dad42cf939 | |||
| 041c3ecc1b | |||
| 103dd949ce | |||
| e3acdf1802 | |||
| f81d28dd5f | |||
| 8e02a702f1 | |||
| cb7a343208 | |||
| 3be8ddae74 | |||
| 9cd1862300 | |||
| 81fdf50217 | |||
| 554d47e301 | |||
| b66ae7ad77 | |||
| 4ddced8e26 | |||
| d003047a6c | |||
| 1e4a78c812 | |||
| 2a3ffd707e | |||
| aca076381b | |||
| 12ac227d2d | |||
| e235280253 | |||
| 0da0c4e894 | |||
| 47f1509ecc | |||
| ae8ef0dd3c | |||
| 687f9e95fa | |||
| 6dbe5f024f | |||
| a39a276299 | |||
| 9f57e5685f | |||
| bdcba202c9 | |||
| 3c48dcb2a6 | |||
| b59d94d0a9 | |||
| db74b55c41 | |||
| 37b5af235a | |||
| e2b05ce575 | |||
| 49851ee3d7 | |||
|
|
cd596cc66d | ||
|
|
5667ae8095 | ||
| f29996aac8 | |||
| 32613bacc6 | |||
| cf9dba0ecc | |||
| a8c4879769 | |||
| f083e94c05 | |||
| c332413e5a | |||
| c9f3d99cd7 | |||
| cf3d07a20d | |||
| e40548e558 | |||
| 4cd8e823c6 | |||
| 9c7faec124 | |||
| 2856880a6e | |||
|
|
5445fdbfa5 | ||
| ba53d0c75d | |||
| 78f6cc5a97 | |||
| 6ab7c6f9d9 | |||
| cb6b33727e | |||
| bc4a2235c5 | |||
| 300f94fd48 | |||
| 40617ad9c8 | |||
| bea056bba3 | |||
| 9a33451f88 | |||
| c4659b558f | |||
| 5a30a07554 | |||
| b064becb8a | |||
| 463d5252bd | |||
| 8b5da90e28 | |||
| febd6ce63c | |||
| 8df8b87d54 | |||
| c882717bcc | |||
| 4aa5924615 | |||
| 2b8e728559 | |||
| 90ad34f114 | |||
| dbe2607994 | |||
| 692b668f92 | |||
| f2322e3e57 | |||
| ae002ead43 | |||
| 4197e13c54 | |||
| e09ea9a9b4 | |||
| 2a32654d57 | |||
| 0fff553ce1 | |||
| 33a1701f5b | |||
| f9a9f958ba | |||
| f686be0271 | |||
| 91307f3ebf | |||
| 8e64205f53 | |||
| 5434df1f02 | |||
| e56199ac9f | |||
| 3e199c6944 | |||
| b43d9aefb9 | |||
| fe133bbde0 | |||
| 332fe95adf | |||
| 1f416d4a28 | |||
| e626d8b5cc | |||
| b906d605f4 | |||
| d3584e793c | |||
| f71ac51461 | |||
| 5fe8cf948a | |||
| 85ea101641 |
4
.github/workflows/kdocs.yml
vendored
4
.github/workflows/kdocs.yml
vendored
@@ -12,10 +12,10 @@ jobs:
|
||||
with:
|
||||
java-version: 11
|
||||
- name: Build
|
||||
run: ./gradlew dokkaHtml
|
||||
run: ./gradlew dokkaHtmlMultiModule
|
||||
- name: Publish KDocs
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./docs/build/dokka/html
|
||||
publish_dir: ./build/dokka/htmlMultiModule
|
||||
publish_branch: kdocs
|
||||
|
||||
4
.github/workflows/packages_publishing.yml
vendored
4
.github/workflows/packages_publishing.yml
vendored
@@ -8,12 +8,16 @@ jobs:
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
- name: Setup LibCurl
|
||||
run: sudo apt install -y libcurl4-openssl-dev
|
||||
- name: Rewrite version
|
||||
run: |
|
||||
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
||||
cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
|
||||
rm gradle.properties
|
||||
mv gradle.properties.tmp gradle.properties
|
||||
- name: KotlinSymbolProcessing execution
|
||||
run: ./gradlew ksp
|
||||
- name: Build
|
||||
run: ./gradlew build
|
||||
- name: Publish to Gitea
|
||||
|
||||
271
CHANGELOG.md
271
CHANGELOG.md
@@ -1,5 +1,276 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 9.1.1
|
||||
|
||||
* `Core`:
|
||||
* Potential fix of incorrect parsing in `RawMessageEntity`
|
||||
|
||||
## 9.1.0
|
||||
|
||||
**This update contains adding of [Telegram Bot API 6.8](https://core.telegram.org/bots/api-changelog#august-18-2023) support**
|
||||
|
||||
* `Version`:
|
||||
* `Coroutines`: `1.7.2` -> `1.7.3`
|
||||
* `Ktor`: `2.3.2` -> `2.3.3`
|
||||
* `MicroUtils`: `0.19.7` -> `0.19.9`
|
||||
|
||||
## 9.0.0
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES: USERNAMES OF BOTS NOW BECAME NULLABLE**
|
||||
|
||||
* `Version`:
|
||||
* `Coroutines`: `1.6.4` -> `1.7.1`
|
||||
* `Ktor`: `2.3.1` -> `2.3.2`
|
||||
* `MicroUtils`: `0.19.4` -> `0.19.7`
|
||||
* `Core`:
|
||||
* **All bots now have nullable usernames just like common users ([#772](https://github.com/InsanusMokrassar/ktgbotapi/issues/772))**
|
||||
* Decrease possible errors in updates handling by additional handling of update deserialization wrapping ([#773](https://github.com/InsanusMokrassar/ktgbotapi/issues/773))
|
||||
* New interface `GetUpdatesRequest`. You may implement it to show default telegram bot ktor executor that this
|
||||
request is an updates request and should be handled in a different way
|
||||
* Now it is possible to get raw updates with `GetUpdatesRaw` request
|
||||
* `Utils`:
|
||||
* Improve extension `Update.sourceChat` to add opportunity to select some chats by logic different with the default
|
||||
|
||||
## 8.1.0
|
||||
|
||||
**PARTIALLY BREAKING CHANGES: Exclude `.*Impl` classcasts from `ClassCastsNew`**
|
||||
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.19.2` -> `0.19.4`
|
||||
* `Utils`:
|
||||
* Add deep links formatting for internal `tg://` prefix (thanks to [@klimatov](https://github.com/klimatov))
|
||||
* Exclude `.*Impl` classcasts from `ClassCastsNew`
|
||||
|
||||
## 8.0.1
|
||||
|
||||
* `Version`:
|
||||
* `UUID`: `0.7.0` -> `0.7.1`
|
||||
* `Ktor`: `2.3.0` -> `2.3.1`
|
||||
* `MicroUtils`: `0.19.1` -> `0.19.2`
|
||||
|
||||
## 8.0.0
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||
|
||||
**ALL PROJECT DEPRECATIONS HAVE BEEN REMOVED**
|
||||
|
||||
**IN THIS UPDATE KORLIBS HAVE BEEN UPDATED TO VERSION `4.0.2`. SINCE THAT VERSION A LOT OF PACKAGES HAVE BEEN RENAMED.
|
||||
MIGRATIONS USED IN THIS LIB:**
|
||||
|
||||
* `com.soywiz.klock` -> `korlibs.time`
|
||||
* `com.soywiz.krypto` -> `korlibs.crypto`
|
||||
|
||||
* `Versions`:
|
||||
* `Korlibs`: `3.4.0` -> `4.0.3`
|
||||
* `MicroUtils`: `0.18.4` -> `0.19.1`
|
||||
|
||||
## 7.1.3
|
||||
|
||||
* `Versions`:
|
||||
* `Serialization`: `1.5.0` -> `1.5.1`
|
||||
* `MicroUtils`: `0.18.1` -> `0.18.4`
|
||||
* `Core`:
|
||||
* Actualize kdocs in `InputFile`
|
||||
* `BehaviourBuilder`:
|
||||
* Now it is possible to use `waitMediaContent`/`waitMediaContentMessage`/`onMediaContent`
|
||||
* Add `onMention`/`waitMention` functionality
|
||||
* Add opportunity to map content with extensions to `Flow`
|
||||
|
||||
## 7.1.2
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.18.0` -> `0.18.1`
|
||||
* `Core`:
|
||||
* Now it is possible to serialize `Sticker`s
|
||||
|
||||
## 7.1.1
|
||||
|
||||
* `Versions`:
|
||||
* `Kotlin`: `1.8.20` -> `1.8.21`
|
||||
* `MicroUtils`: `0.17.8` -> `0.18.0`
|
||||
* `Utils`:
|
||||
* Fixes in `makeLinkToMessage`
|
||||
|
||||
## 7.1.0
|
||||
|
||||
**This update contains changes according to the [Telegram Bot API 6.7](https://core.telegram.org/bots/api-changelog#april-21-2023)**
|
||||
|
||||
* `API`:
|
||||
* Rename `editMessageCaption` to `editMessageMedia` due to wrong old naming
|
||||
* Add `edit` extensions for `InlineMessageIdentifier`s
|
||||
* `BehaviourBuilder`:
|
||||
* `BehaviourContext` extensions `onDeepLink` and `waitDeepLinks` now can be used with `Regex` or `String` as first parameters
|
||||
|
||||
## 7.0.2
|
||||
|
||||
_This update brings experimental support of `linuxX64` and `mingwX64` platforms_
|
||||
|
||||
* `Versions`:
|
||||
* `Kotlin`: `1.8.10` -> `1.8.20`
|
||||
* `MicroUtils`: `0.17.5` -> `0.17.8`
|
||||
* `Ktor`: `2.2.4` -> `2.3.0`
|
||||
* `Core`:
|
||||
* New `RequestsExecutor` - `MultipleClientKtorRequestsExecutor`
|
||||
* Old `KtorRequestsExecutor` has been renamed to `DefaultKtorRequestsExecutor`
|
||||
* `KtorRequestsExecutor` now is `expect class`
|
||||
* On `JS`, `JVM` and `MinGWX64` platforms it is `DefaultKtorRequestsExecutor`
|
||||
* On `LinuxX64` platform it is `MultipleClientKtorRequestsExecutor`
|
||||
|
||||
## 7.0.1
|
||||
|
||||
* `Core`:
|
||||
* New interface `WithChat` which contains `chat` field
|
||||
* `Message` now inherits `WithChat`
|
||||
* `ChatMemberUpdated` now inherits `WithChat`
|
||||
* `Utils`:
|
||||
* Improvements in `same`-notations
|
||||
|
||||
## 7.0.0
|
||||
|
||||
This update contains support of [Telegram Bot API 6.6](https://core.telegram.org/bots/api-changelog#march-9-2023)
|
||||
|
||||
**THIS VERSION CONTAINS BREAKING CHANGES**:
|
||||
|
||||
* All previous deprecations have been removed
|
||||
* Fully reworked mechanism of stickers creating and adding
|
||||
* All separations of stickers types like `Animeted` have been replaces with type `StickerFormat`
|
||||
* New `InputSticker` type (and all subtypes) as replacements for old raw fields in methods
|
||||
* Reworked mechanism of files uploading
|
||||
|
||||
Other changes
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.17.3` -> `0.17.5`
|
||||
|
||||
## 6.1.0
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.17.2` -> `0.17.3`
|
||||
* `API`:
|
||||
* Fix of [#732](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/732)
|
||||
|
||||
## 6.0.3
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.17.1` -> `0.17.2`
|
||||
* `Core`:
|
||||
* `User` in `CallbackQuery` now is `CommonUser` as well as in `from`
|
||||
* `User` in `InlineQuery` now is `CommonUser` as well as in `from`
|
||||
* `BehaviourBuilder`:
|
||||
* Fixes in `DeepLink` triggers and waiters
|
||||
|
||||
## 6.0.2
|
||||
|
||||
* `Core`:
|
||||
* Long polling now uses media groups debounce as in webhooks
|
||||
|
||||
## 6.0.1
|
||||
|
||||
* `Versions`:
|
||||
* `Ktor`: `2.2.3` -> `2.2.4`
|
||||
* `MicroUtils`: `0.17.0` -> `0.17.1`
|
||||
|
||||
## 6.0.0
|
||||
|
||||
* `Versions`:
|
||||
* `Kotlin`: `1.7.22` -> `1.8.10`
|
||||
* `MicroUtils`: `0.16.10` -> `0.17.0`
|
||||
* `Serialization`: `1.4.1` -> `1.5.0`
|
||||
* `uuid`: `0.6.0` -> `0.7.0`
|
||||
* `Core`:
|
||||
* `*.link` extensions have been deprecated with renaming to avoid collisions with `link` methods
|
||||
* `API`:
|
||||
* Add `TelegramBot.resend` methods
|
||||
* `BehaviourBuilder`:
|
||||
* Add triggers and waiters for `VisualMediaGroupPartContent`
|
||||
* `Utils`:
|
||||
* `*.link` extensions have been deprecated with renaming to avoid collisions with `link` methods
|
||||
|
||||
## 5.2.1
|
||||
|
||||
* `Core`:
|
||||
* All the `CallbackQuery`es now will receive `CommonUser` instead of `User` due inability of bots to trigger any
|
||||
inline interaction with others bots
|
||||
* `API`:
|
||||
* Now `sentMessageFlow` will take each sent message in `handleLiveLocation`
|
||||
|
||||
## 5.2.0
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.16.8` -> `0.16.10`
|
||||
|
||||
## 5.1.1
|
||||
|
||||
* `Core`:
|
||||
* Add opportunity to get user link with `makeUserLink`
|
||||
* `BehaviourBuilder`:
|
||||
* Fixes in content waiting expectators
|
||||
|
||||
## 5.1.0
|
||||
|
||||
[Bot API 6.5](https://core.telegram.org/bots/api-changelog#february-3-2023) support
|
||||
|
||||
* `Core`:
|
||||
* `ChatPermissions` now is interface and have two main realizations: `ChatPermissions.Granular` and
|
||||
`ChatPermissions.Common`
|
||||
* `RestrictedChatMember` now implements `ChatPermissions` too
|
||||
* `API`:
|
||||
* Now it is possible to pass all long polling parameters in all places used it
|
||||
* `Issues`:
|
||||
* Fix of [#697](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/697)
|
||||
|
||||
## 5.0.2
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.16.6` -> `0.16.8`
|
||||
* `Ktor`: `2.2.2` -> `2.2.3`
|
||||
* `BehaviourBuilder`:
|
||||
* Fixes in `BehaviourContext.onEditedContentMessage` - now it will trigger callback on channel post edits too
|
||||
|
||||
## 5.0.1
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.16.4` -> `0.16.6`
|
||||
* `Ktor`: `2.2.1` -> `2.2.2`
|
||||
* `Core`:
|
||||
* Fixes in `SendMediaGroup` request
|
||||
* Fixes in `SetChatAdministratorCustomTitle` request (thanks to [@madhead](https://github.com/madhead))
|
||||
|
||||
## 5.0.0
|
||||
|
||||
[Bot API 6.4](https://core.telegram.org/bots/api-changelog#december-30-2022) support!
|
||||
|
||||
* Long-polling improvements
|
||||
|
||||
## 4.2.4
|
||||
|
||||
* `Core`:
|
||||
* Fixes in webhook parts adapter
|
||||
* `BehaviourBuilderWithFSM`:
|
||||
* Fixes in `DefaultBehaviourContextWithFSM`
|
||||
|
||||
## 4.2.3
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.16.2` -> `0.16.4`
|
||||
* `Core`:
|
||||
* Simplify default `RequestsLimiter` (`ExceptionsOnlyLimiter`) (thanks to [@y9san9](https://github.com/y9san9) for help)
|
||||
|
||||
## 4.2.2
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.16.0` -> `0.16.2`
|
||||
* `Core`:
|
||||
* Fix of [#694](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/694): add opportunity to create `ChatId` and `ChatIdWithThreadId` from `IdChatIdentifier`
|
||||
|
||||
## 4.2.1
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.15.0` -> `0.16.0`
|
||||
* `Ktor`: `2.1.3` -> `2.2.1`
|
||||
* `Utils`:
|
||||
* Improve support of `makeLinkToMessage` extensions
|
||||
|
||||
## 4.2.0
|
||||
|
||||
* `Versions`:
|
||||
|
||||
16
README.md
16
README.md
@@ -1,14 +1,16 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#november-5-2022)
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#august-18-2023)
|
||||
|
||||
| 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) |
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
| 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) |
|
||||
| Platforms |   |
|
||||
| Experimental Platforms | [](https://kotlinlang.org/docs/native-target-support.html#tier-1) [](https://kotlinlang.org/docs/native-target-support.html#tier-1) |
|
||||
|
||||
<!--- [](https://t.me/InMoTelegramBotAPI) --->
|
||||
<!--- [](https://t.me/ktgbotapi) --->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://t.me/InMoTelegramBotAPI">
|
||||
<a href="https://t.me/ktgbotapi">
|
||||
<img src="./resources/tg_channel_qr.jpg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -14,12 +14,17 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.dokka)
|
||||
}
|
||||
|
||||
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven { url "https://git.inmo.dev/api/packages/InsanusMokrassar/maven" }
|
||||
}
|
||||
if (it != rootProject.findProject("docs")) {
|
||||
tasks.whenTaskAdded { task ->
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=4.2.0
|
||||
library_version=9.1.1
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "1.7.22"
|
||||
kotlin-serialization = "1.4.1"
|
||||
kotlin-coroutines = "1.6.4"
|
||||
kotlin = "1.8.22"
|
||||
kotlin-serialization = "1.5.1"
|
||||
kotlin-coroutines = "1.7.3"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "3.4.0"
|
||||
uuid = "0.6.0"
|
||||
ktor = "2.1.3"
|
||||
korlibs = "4.0.3"
|
||||
uuid = "0.7.1"
|
||||
ktor = "2.3.3"
|
||||
|
||||
ksp = "1.7.22-1.0.8"
|
||||
kotlin-poet = "1.12.0"
|
||||
ksp = "1.8.22-1.0.11"
|
||||
kotlin-poet = "1.14.2"
|
||||
|
||||
microutils = "0.15.0"
|
||||
microutils = "0.19.9"
|
||||
|
||||
github-release-plugin = "2.4.1"
|
||||
dokka = "1.7.20"
|
||||
dokka = "1.8.20"
|
||||
|
||||
[libraries]
|
||||
|
||||
@@ -31,6 +31,8 @@ kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref =
|
||||
|
||||
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-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
|
||||
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", 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" }
|
||||
|
||||
@@ -45,6 +47,7 @@ microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.re
|
||||
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-serialization-mapper = { module = "dev.inmo:micro_utils.serialization.mapper", 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" }
|
||||
@@ -67,3 +70,4 @@ github-release-plugin = { module = "com.github.breadmoirai:github-release", vers
|
||||
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" }
|
||||
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||
|
||||
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.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
|
||||
|
||||
@@ -13,6 +13,8 @@ kotlin {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
linuxX64()
|
||||
mingwX64()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
task javadocsJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
archiveClassifier.convention("javadoc")
|
||||
archiveClassifier.set("javadoc")
|
||||
}
|
||||
|
||||
publishing {
|
||||
@@ -19,22 +20,22 @@ publishing {
|
||||
}
|
||||
|
||||
developers {
|
||||
|
||||
|
||||
developer {
|
||||
id = "InsanusMokrassar"
|
||||
name = "Ovsiannikov Aleksei"
|
||||
email = "ovsyannikov.alexey95@gmail.com"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
licenses {
|
||||
|
||||
|
||||
license {
|
||||
name = "Apache Software License 2.0"
|
||||
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
@@ -42,55 +43,55 @@ publishing {
|
||||
maven {
|
||||
name = "GithubPackages"
|
||||
url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI")
|
||||
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER')
|
||||
password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) {
|
||||
maven {
|
||||
name = "Gitea"
|
||||
url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven")
|
||||
|
||||
|
||||
credentials(HttpHeaderCredentials) {
|
||||
name = "Authorization"
|
||||
value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN')
|
||||
}
|
||||
|
||||
|
||||
authentication {
|
||||
header(HttpHeaderAuthentication)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (project.hasProperty("signing.gnupg.keyName")) {
|
||||
apply plugin: 'signing'
|
||||
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
|
||||
|
||||
sign publishing.publications
|
||||
}
|
||||
|
||||
|
||||
task signAll {
|
||||
tasks.withType(Sign).forEach {
|
||||
dependsOn(it)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 593 KiB After Width: | Height: | Size: 448 KiB |
@@ -19,4 +19,3 @@ include ":tgbotapi.behaviour_builder"
|
||||
include ":tgbotapi.behaviour_builder.fsm"
|
||||
include ":tgbotapi"
|
||||
include ":tgbotapi.webapps"
|
||||
include ":docs"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "org.jetbrains.dokka"
|
||||
}
|
||||
|
||||
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor"
|
||||
|
||||
@@ -5,7 +5,10 @@ import dev.inmo.tgbotapi.requests.DeleteMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
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.MediaGroupCollectionContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
chatId: ChatIdentifier,
|
||||
@@ -21,7 +24,16 @@ suspend fun TelegramBot.deleteMessage(
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
message: Message
|
||||
) = deleteMessage(message.chat, message.messageId)
|
||||
): Boolean {
|
||||
val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>)
|
||||
if (mediaGroupContent == null) {
|
||||
return deleteMessage(message.chat, message.messageId)
|
||||
} else {
|
||||
return mediaGroupContent.group.map {
|
||||
deleteMessage(it.sourceMessage)
|
||||
}.all { it }
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chatId: ChatIdentifier,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||
import dev.inmo.tgbotapi.requests.GetUpdatesRaw
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
suspend fun TelegramBot.getRawUpdates(
|
||||
offset: UpdateIdentifier? = null,
|
||||
limit: Int = getUpdatesLimit.last,
|
||||
timeout: Seconds? = null,
|
||||
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
) = execute(
|
||||
GetUpdatesRaw(
|
||||
offset, limit, timeout, allowed_updates
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getRawUpdates(
|
||||
lastUpdate: Update,
|
||||
limit: Int = getUpdatesLimit.last,
|
||||
timeout: Seconds? = null,
|
||||
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
) = getRawUpdates(
|
||||
lastUpdate.updateId + 1, limit, timeout, allowed_updates
|
||||
)
|
||||
@@ -6,7 +6,6 @@ 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.edit
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.send.send
|
||||
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@@ -17,6 +16,7 @@ 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.FlowCollector
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.js.JsName
|
||||
@@ -45,7 +45,8 @@ suspend fun TelegramBot.handleLiveLocation(
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
sentMessageFlow: FlowCollector<ContentMessage<LocationContent>>? = null
|
||||
) {
|
||||
var currentLiveLocationMessage: ContentMessage<LocationContent>? = null
|
||||
val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
|
||||
@@ -73,7 +74,9 @@ suspend fun TelegramBot.handleLiveLocation(
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
it.replyMarkup
|
||||
)
|
||||
).also {
|
||||
sentMessageFlow ?.emit(it)
|
||||
}
|
||||
} else {
|
||||
edit(
|
||||
capturedLiveLocationMessage,
|
||||
@@ -83,7 +86,9 @@ suspend fun TelegramBot.handleLiveLocation(
|
||||
it.heading,
|
||||
it.proximityAlertRadius,
|
||||
it.replyMarkup
|
||||
)
|
||||
).also {
|
||||
sentMessageFlow ?.emit(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,7 +107,8 @@ suspend fun TelegramBot.handleLiveLocation(
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
sentMessageFlow: FlowCollector<ContentMessage<LocationContent>>? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
chatId,
|
||||
@@ -121,7 +127,8 @@ suspend fun TelegramBot.handleLiveLocation(
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply
|
||||
allowSendingWithoutReply,
|
||||
sentMessageFlow
|
||||
)
|
||||
}
|
||||
|
||||
@@ -139,7 +146,8 @@ suspend fun TelegramBot.handleLiveLocation(
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
sentMessageFlow: FlowCollector<ContentMessage<LocationContent>>? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
chatId,
|
||||
@@ -154,6 +162,7 @@ suspend fun TelegramBot.handleLiveLocation(
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply
|
||||
allowSendingWithoutReply,
|
||||
sentMessageFlow
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.TimeSpan
|
||||
import korlibs.time.DateTime
|
||||
import korlibs.time.TimeSpan
|
||||
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.edit
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.send.send
|
||||
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
|
||||
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
@@ -18,7 +25,15 @@ import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.currentCoroutineContext
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.math.ceil
|
||||
|
||||
val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
|
||||
@@ -45,7 +60,8 @@ class LiveLocationProvider internal constructor(
|
||||
private set
|
||||
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
|
||||
|
||||
private var message: ContentMessage<LocationContent> = initMessage
|
||||
var message: ContentMessage<LocationContent> = initMessage
|
||||
private set
|
||||
val lastLocation: LiveLocation
|
||||
get() = message.content.location as LiveLocation
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.answers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery
|
||||
import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
||||
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||
@@ -12,8 +13,37 @@ suspend fun TelegramBot.answerInlineQuery(
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
switchPmText: String? = null,
|
||||
switchPmParameter: String? = null
|
||||
button: InlineQueryResultsButton? = null
|
||||
) = execute(
|
||||
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, button)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.answerInlineQuery(
|
||||
inlineQuery: InlineQuery,
|
||||
results: List<InlineQueryResult> = emptyList(),
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
button: InlineQueryResultsButton? = null
|
||||
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
|
||||
|
||||
suspend fun TelegramBot.answer(
|
||||
inlineQuery: InlineQuery,
|
||||
results: List<InlineQueryResult> = emptyList(),
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
button: InlineQueryResultsButton? = null
|
||||
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
|
||||
|
||||
suspend fun TelegramBot.answerInlineQuery(
|
||||
inlineQueryID: InlineQueryIdentifier,
|
||||
results: List<InlineQueryResult> = emptyList(),
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
switchPmText: String?,
|
||||
switchPmParameter: String?
|
||||
) = execute(
|
||||
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||
)
|
||||
@@ -24,8 +54,8 @@ suspend fun TelegramBot.answerInlineQuery(
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
switchPmText: String? = null,
|
||||
switchPmParameter: String? = null
|
||||
switchPmText: String?,
|
||||
switchPmParameter: String?
|
||||
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||
|
||||
suspend fun TelegramBot.answer(
|
||||
@@ -34,6 +64,6 @@ suspend fun TelegramBot.answer(
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
switchPmText: String? = null,
|
||||
switchPmParameter: String? = null
|
||||
switchPmText: String?,
|
||||
switchPmParameter: String?
|
||||
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
|
||||
suspend fun TelegramBot.getMyDescription(
|
||||
languageCode: IetfLanguageCode? = null
|
||||
) = execute(GetMyDescription(languageCode))
|
||||
|
||||
suspend fun TelegramBot.getMyDescription(
|
||||
languageCode: String?
|
||||
) = getMyDescription(languageCode ?.let(::IetfLanguageCode))
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
|
||||
suspend fun TelegramBot.getMyName(
|
||||
languageCode: IetfLanguageCode? = null
|
||||
) = execute(GetMyName(languageCode))
|
||||
|
||||
suspend fun TelegramBot.getMyName(
|
||||
languageCode: String?
|
||||
) = getMyName(languageCode ?.let(::IetfLanguageCode))
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
|
||||
suspend fun TelegramBot.getMyShortDescription(
|
||||
languageCode: IetfLanguageCode? = null
|
||||
) = execute(GetMyShortDescription(languageCode))
|
||||
|
||||
suspend fun TelegramBot.getMyShortDescription(
|
||||
languageCode: String?
|
||||
) = getMyShortDescription(languageCode ?.let(::IetfLanguageCode))
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
||||
import dev.inmo.tgbotapi.requests.bot.SetMyDescription
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
|
||||
suspend fun TelegramBot.setMyDescription(
|
||||
description: String? = null,
|
||||
languageCode: IetfLanguageCode? = null
|
||||
) = execute(SetMyDescription(description, languageCode))
|
||||
|
||||
suspend fun TelegramBot.setMyDescription(
|
||||
description: String?,
|
||||
languageCode: String?
|
||||
) = setMyDescription(description, languageCode ?.let(::IetfLanguageCode))
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||
import dev.inmo.tgbotapi.requests.bot.SetMyName
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
|
||||
suspend fun TelegramBot.setMyName(
|
||||
name: String? = null,
|
||||
languageCode: IetfLanguageCode? = null
|
||||
) = execute(SetMyName(name, languageCode))
|
||||
|
||||
suspend fun TelegramBot.setMyName(
|
||||
name: String?,
|
||||
languageCode: String?
|
||||
) = setMyName(name, languageCode ?.let(::IetfLanguageCode))
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
|
||||
|
||||
suspend fun TelegramBot.setMyShortDescription(
|
||||
shortDescription: String? = null,
|
||||
languageCode: IetfLanguageCode? = null
|
||||
) = execute(SetMyShortDescription(shortDescription, languageCode))
|
||||
|
||||
suspend fun TelegramBot.setMyShortDescription(
|
||||
shortDescription: String?,
|
||||
languageCode: String?
|
||||
) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLanguageCode))
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.ForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.closeGeneralForumTopic(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(
|
||||
CloseGeneralForumTopic(chatId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.closeGeneralForumTopic(
|
||||
chat: Chat
|
||||
) = closeGeneralForumTopic(chat.id)
|
||||
@@ -11,8 +11,8 @@ import dev.inmo.tgbotapi.types.chat.Chat
|
||||
suspend fun TelegramBot.editForumTopic(
|
||||
chatId: ChatIdentifier,
|
||||
messageThreadId: MessageThreadId,
|
||||
name: String,
|
||||
iconEmojiId: CustomEmojiId
|
||||
name: String? = null,
|
||||
iconEmojiId: CustomEmojiId? = null
|
||||
) = execute(
|
||||
EditForumTopic(
|
||||
chatId,
|
||||
@@ -25,12 +25,12 @@ suspend fun TelegramBot.editForumTopic(
|
||||
suspend fun TelegramBot.editForumTopic(
|
||||
chat: Chat,
|
||||
messageThreadId: MessageThreadId,
|
||||
name: String,
|
||||
iconEmojiId: CustomEmojiId
|
||||
name: String? = null,
|
||||
iconEmojiId: CustomEmojiId? = null
|
||||
) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
|
||||
|
||||
suspend fun TelegramBot.editForumTopic(
|
||||
chatIdentifier: ChatIdentifier,
|
||||
forumTopic: ForumTopic,
|
||||
iconEmojiId: CustomEmojiId = forumTopic.iconEmojiId ?: error("Icon emoji id in forum topic should be presented when edit forum topic basing on other forum topic object")
|
||||
iconEmojiId: CustomEmojiId? = forumTopic.iconEmojiId
|
||||
) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.EditGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.ForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.editGeneralForumTopic(
|
||||
chatId: ChatIdentifier,
|
||||
name: String
|
||||
) = execute(
|
||||
EditGeneralForumTopic(
|
||||
chatId,
|
||||
name
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.editGeneralForumTopic(
|
||||
chat: Chat,
|
||||
name: String
|
||||
) = editGeneralForumTopic(chat.id, name)
|
||||
|
||||
suspend fun TelegramBot.editGeneralForumTopic(
|
||||
chatIdentifier: ChatIdentifier,
|
||||
forumTopic: ForumTopic,
|
||||
) = editGeneralForumTopic(chatIdentifier, forumTopic.name)
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.ForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.hideGeneralForumTopic(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(
|
||||
HideGeneralForumTopic(chatId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.hideGeneralForumTopic(
|
||||
chat: Chat
|
||||
) = hideGeneralForumTopic(chat.id)
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.ReopenGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.ForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.reopenGeneralForumTopic(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(
|
||||
ReopenGeneralForumTopic(chatId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.reopenGeneralForumTopic(
|
||||
chat: Chat
|
||||
) = reopenGeneralForumTopic(chat.id)
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.UnhideGeneralForumTopic
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.ForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.unhideGeneralForumTopic(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(
|
||||
UnhideGeneralForumTopic(chatId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.unhideGeneralForumTopic(
|
||||
chat: Chat
|
||||
) = unhideGeneralForumTopic(chat.id)
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllForumTopicMessages
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllGeneralForumTopicMessages
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.ForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(
|
||||
UnpinAllGeneralForumTopicMessages(
|
||||
chatId
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
|
||||
chat: Chat
|
||||
) = unpinAllGeneralForumTopicMessages(chat.id)
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.invite_links.CreateChatInviteLink
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.invite_links.EditChatInviteLink
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
|
||||
@@ -14,27 +14,31 @@ suspend fun TelegramBot.restrictChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
|
||||
permissions: ChatPermissions = ChatPermissions(),
|
||||
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
|
||||
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions, useIndependentChatPermissions))
|
||||
|
||||
suspend fun TelegramBot.restrictChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, userId, untilDate, permissions)
|
||||
permissions: ChatPermissions = ChatPermissions(),
|
||||
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
|
||||
) = restrictChatMember(chat.id, userId, untilDate, permissions, useIndependentChatPermissions)
|
||||
|
||||
suspend fun TelegramBot.restrictChatMember(
|
||||
chatId: IdChatIdentifier,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chatId, user.id, untilDate, permissions)
|
||||
permissions: ChatPermissions = ChatPermissions(),
|
||||
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
|
||||
) = restrictChatMember(chatId, user.id, untilDate, permissions, useIndependentChatPermissions)
|
||||
|
||||
suspend fun TelegramBot.restrictChatMember(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, user.id, untilDate, permissions)
|
||||
permissions: ChatPermissions = ChatPermissions(),
|
||||
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
|
||||
) = restrictChatMember(chat.id, user.id, untilDate, permissions, useIndependentChatPermissions)
|
||||
|
||||
|
||||
@@ -8,10 +8,12 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||
|
||||
suspend fun TelegramBot.setDefaultChatMembersPermissions(
|
||||
chatId: ChatIdentifier,
|
||||
permissions: ChatPermissions
|
||||
) = execute(SetChatPermissions(chatId, permissions))
|
||||
permissions: ChatPermissions,
|
||||
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
|
||||
) = execute(SetChatPermissions(chatId, permissions, useIndependentChatPermissions))
|
||||
|
||||
suspend fun TelegramBot.setDefaultChatMembersPermissions(
|
||||
chat: PublicChat,
|
||||
permissions: ChatPermissions
|
||||
) = setDefaultChatMembersPermissions(chat.id, permissions)
|
||||
permissions: ChatPermissions,
|
||||
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
|
||||
) = setDefaultChatMembersPermissions(chat.id, permissions, useIndependentChatPermissions)
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
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 TelegramBot.edit(
|
||||
messageId: InlineMessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(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(
|
||||
messageId: InlineMessageIdentifier,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(
|
||||
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(
|
||||
messageId: InlineMessageIdentifier,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(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(
|
||||
messageId: InlineMessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
messageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(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(
|
||||
messageId: InlineMessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(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(
|
||||
messageId: InlineMessageIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(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(
|
||||
messageId: InlineMessageIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
@@ -10,7 +10,7 @@ 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
|
||||
*/
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
suspend fun TelegramBot.editMessageMedia(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
|
||||
@@ -10,13 +10,6 @@ suspend fun TelegramBot.getStickerSet(
|
||||
GetStickerSet(name)
|
||||
)
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("getStickerSetOrThrow(sticker)", "dev.inmo.tgbotapi.extensions.api.get.getStickerSetOrThrow"))
|
||||
suspend fun TelegramBot.getStickerSet(
|
||||
sticker: Sticker
|
||||
) = getStickerSet(
|
||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getStickerSetOrNull(
|
||||
sticker: Sticker
|
||||
) = sticker.stickerSetName ?.let {
|
||||
|
||||
@@ -379,6 +379,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -392,6 +393,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -408,6 +410,7 @@ suspend inline fun TelegramBot.reply(
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -415,12 +418,13 @@ suspend inline fun TelegramBot.reply(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithAnimation(
|
||||
to: Message,
|
||||
animation: InputFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
thumb: InputFile? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
@@ -434,6 +438,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
|
||||
animation,
|
||||
thumb,
|
||||
entities,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -449,6 +454,7 @@ suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
animation: AnimationFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -456,7 +462,7 @@ suspend inline fun TelegramBot.reply(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(to.chat, animation, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Audio
|
||||
@@ -608,64 +614,70 @@ suspend inline fun TelegramBot.replyWithPhoto(
|
||||
fileId: InputFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, fileId, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
photo: Photo,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, photo, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
photoSize: PhotoSize,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, photoSize, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
suspend inline fun TelegramBot.replyWithPhoto(
|
||||
to: Message,
|
||||
fileId: InputFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, fileId, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
photo: Photo,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, photo, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
photoSize: PhotoSize,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, photoSize, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Sticker
|
||||
@@ -673,20 +685,22 @@ suspend inline fun TelegramBot.reply(
|
||||
suspend inline fun TelegramBot.replyWithSticker(
|
||||
to: Message,
|
||||
sticker: InputFile,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
sticker: Sticker,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Videos
|
||||
@@ -697,6 +711,7 @@ suspend inline fun TelegramBot.replyWithVideo(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -704,24 +719,26 @@ suspend inline fun TelegramBot.replyWithVideo(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(to.chat, video, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVideo(
|
||||
to: Message,
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -729,17 +746,18 @@ suspend inline fun TelegramBot.replyWithVideo(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(to.chat, video, thumb, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
video: VideoFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(to.chat, video, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(to.chat, video, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// VideoNotes
|
||||
|
||||
@@ -410,6 +410,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -424,6 +425,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -441,6 +443,7 @@ suspend inline fun TelegramBot.reply(
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -449,13 +452,14 @@ suspend inline fun TelegramBot.reply(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(toChatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithAnimation(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
animation: InputFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
thumb: InputFile? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
@@ -470,6 +474,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
|
||||
animation,
|
||||
thumb,
|
||||
entities,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -486,6 +491,7 @@ suspend inline fun TelegramBot.reply(
|
||||
toMessageId: MessageId,
|
||||
animation: AnimationFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -494,7 +500,7 @@ suspend inline fun TelegramBot.reply(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(toChatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Audio
|
||||
@@ -671,12 +677,13 @@ suspend inline fun TelegramBot.replyWithPhoto(
|
||||
fileId: InputFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(toChatId, fileId, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
@@ -684,12 +691,13 @@ suspend inline fun TelegramBot.reply(
|
||||
photo: Photo,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(toChatId, photo, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
@@ -697,12 +705,13 @@ suspend inline fun TelegramBot.reply(
|
||||
photoSize: PhotoSize,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(toChatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
suspend inline fun TelegramBot.replyWithPhoto(
|
||||
@@ -710,36 +719,39 @@ suspend inline fun TelegramBot.replyWithPhoto(
|
||||
toMessageId: MessageId,
|
||||
fileId: InputFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(toChatId, fileId, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
photo: Photo,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(toChatId, photo, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
photoSize: PhotoSize,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(toChatId, photoSize, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Sticker
|
||||
@@ -749,22 +761,24 @@ suspend inline fun TelegramBot.replyWithSticker(
|
||||
toMessageId: MessageId,
|
||||
sticker: InputFile,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
sticker: Sticker,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Videos
|
||||
@@ -776,6 +790,7 @@ suspend inline fun TelegramBot.replyWithVideo(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -784,7 +799,7 @@ suspend inline fun TelegramBot.replyWithVideo(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(toChatId, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
@@ -792,12 +807,13 @@ suspend inline fun TelegramBot.reply(
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(toChatId, video, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVideo(
|
||||
toChatId: IdChatIdentifier,
|
||||
@@ -805,6 +821,7 @@ suspend inline fun TelegramBot.replyWithVideo(
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -813,19 +830,20 @@ suspend inline fun TelegramBot.replyWithVideo(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(toChatId, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
video: VideoFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(toChatId, video, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// VideoNotes
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import dev.inmo.tgbotapi.types.threadId
|
||||
|
||||
/**
|
||||
* This method will send [content] to the [chatId] as is
|
||||
*/
|
||||
suspend inline fun <T : MessageContent> TelegramBot.resend(
|
||||
chatId: ChatIdentifier,
|
||||
content: T,
|
||||
messageThreadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
content.createResend(
|
||||
chatId = chatId,
|
||||
messageThreadId = messageThreadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
replyToMessageId = replyToMessageId,
|
||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
) as ContentMessage<T>
|
||||
|
||||
/**
|
||||
* This method will send [content] to the [chatId] as is
|
||||
*/
|
||||
suspend inline fun <T : MessageContent> TelegramBot.resend(
|
||||
chat: Chat,
|
||||
content: T,
|
||||
messageThreadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = resend(
|
||||
chatId = chat.id,
|
||||
content = content,
|
||||
messageThreadId = messageThreadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
replyToMessageId = replyToMessageId,
|
||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* This method will send [message] content to the [chatId]. In difference with [copyMessage], this method will use
|
||||
* native methods for data sending (like [dev.inmo.tgbotapi.extensions.api.send.media.sendPhoto] if inoming content is
|
||||
* [dev.inmo.tgbotapi.types.message.content.PhotoContent])
|
||||
*/
|
||||
suspend inline fun <T : MessageContent> TelegramBot.resend(
|
||||
chatId: ChatIdentifier,
|
||||
message: ContentMessage<T>,
|
||||
messageThreadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = resend(
|
||||
chatId = chatId,
|
||||
content = message.content,
|
||||
messageThreadId = messageThreadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
replyToMessageId = replyToMessageId,
|
||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* This method will send [message] content to the [chat]. In difference with [copyMessage], this method will use
|
||||
* native methods for data sending (like [dev.inmo.tgbotapi.extensions.api.send.media.sendPhoto] if inoming content is
|
||||
* [dev.inmo.tgbotapi.types.message.content.PhotoContent])
|
||||
*/
|
||||
suspend inline fun <T : MessageContent> TelegramBot.resend(
|
||||
chat: Chat,
|
||||
message: ContentMessage<T>,
|
||||
messageThreadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = resend(
|
||||
chatId = chat.id,
|
||||
message = message,
|
||||
messageThreadId = messageThreadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
replyToMessageId = replyToMessageId,
|
||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
@@ -3,104 +3,129 @@ package dev.inmo.tgbotapi.extensions.api.send
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendAction
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.actions.*
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.threadId
|
||||
|
||||
suspend fun TelegramBot.sendBotAction(
|
||||
chatId: ChatIdentifier,
|
||||
action: BotAction
|
||||
action: BotAction,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = execute(
|
||||
SendAction(chatId, action)
|
||||
SendAction(chatId, action, threadId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendBotAction(
|
||||
chat: Chat,
|
||||
action: BotAction
|
||||
) = sendBotAction(chat.id, action)
|
||||
action: BotAction,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat.id, action, threadId)
|
||||
|
||||
|
||||
suspend fun TelegramBot.sendActionTyping(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, TypingAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, TypingAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadPhoto(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadPhotoAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, UploadPhotoAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideo(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordVideoAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, RecordVideoAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideo(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadVideoAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, UploadVideoAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVoice(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordVoiceAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, RecordVoiceAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVoice(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadVoiceAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, UploadVoiceAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadDocument(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadDocumentAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, UploadDocumentAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionFindLocation(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, FindLocationAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, FindLocationAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideoNote(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordVideoNoteAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, RecordVideoNoteAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideoNote(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadVideoNoteAction)
|
||||
chatId: ChatIdentifier,
|
||||
threadId: MessageThreadId? = chatId.threadId
|
||||
) = sendBotAction(chatId, UploadVideoNoteAction, threadId)
|
||||
|
||||
|
||||
suspend fun TelegramBot.sendActionTyping(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, TypingAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, TypingAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadPhoto(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadPhotoAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, UploadPhotoAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideo(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordVideoAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, RecordVideoAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideo(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadVideoAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, UploadVideoAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVoice(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordVoiceAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, RecordVoiceAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVoice(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadVoiceAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, UploadVoiceAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadDocument(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadDocumentAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, UploadDocumentAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionFindLocation(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, FindLocationAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, FindLocationAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideoNote(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordVideoNoteAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, RecordVideoNoteAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideoNote(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadVideoNoteAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, UploadVideoNoteAction, threadId)
|
||||
|
||||
suspend fun TelegramBot.sendActionChooseStickerAction(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, ChooseStickerAction)
|
||||
chat: Chat,
|
||||
threadId: MessageThreadId? = chat.id.threadId
|
||||
) = sendBotAction(chat, ChooseStickerAction, threadId)
|
||||
|
||||
|
||||
@@ -38,13 +38,14 @@ suspend fun <T> TelegramBot.withAction(
|
||||
suspend fun <T> TelegramBot.withAction(
|
||||
chatId: IdChatIdentifier,
|
||||
action: BotAction,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
block: TelegramBotActionCallback<T>
|
||||
): T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(
|
||||
SendAction(chatId, action),
|
||||
SendAction(chatId, action, threadId),
|
||||
block
|
||||
)
|
||||
}
|
||||
@@ -53,6 +54,7 @@ suspend fun <T> TelegramBot.withAction(
|
||||
suspend fun <T> TelegramBot.withAction(
|
||||
chat: Chat,
|
||||
action: BotAction,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
block: TelegramBotActionCallback<T>
|
||||
): T {
|
||||
contract {
|
||||
@@ -61,163 +63,164 @@ suspend fun <T> TelegramBot.withAction(
|
||||
return withAction(
|
||||
chat.id,
|
||||
action,
|
||||
threadId,
|
||||
block
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withTypingAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withTypingAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, TypingAction, block)
|
||||
return withAction(chatId, TypingAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, UploadPhotoAction, block)
|
||||
return withAction(chatId, UploadPhotoAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, RecordVideoAction, block)
|
||||
return withAction(chatId, RecordVideoAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, UploadVideoAction, block)
|
||||
return withAction(chatId, UploadVideoAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, RecordVoiceAction, block)
|
||||
return withAction(chatId, RecordVoiceAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, UploadVoiceAction, block)
|
||||
return withAction(chatId, UploadVoiceAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, UploadDocumentAction, block)
|
||||
return withAction(chatId, UploadDocumentAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, FindLocationAction, block)
|
||||
return withAction(chatId, FindLocationAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, RecordVideoNoteAction, block)
|
||||
return withAction(chatId, RecordVideoNoteAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, UploadVideoNoteAction, block)
|
||||
return withAction(chatId, UploadVideoNoteAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chatId, ChooseStickerAction, block)
|
||||
return withAction(chatId, ChooseStickerAction, threadId, block)
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withTypingAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withTypingAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, TypingAction, block)
|
||||
return withAction(chat, TypingAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, UploadPhotoAction, block)
|
||||
return withAction(chat, UploadPhotoAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withRecordVideoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, RecordVideoAction, block)
|
||||
return withAction(chat, RecordVideoAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadVideoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, UploadVideoAction, block)
|
||||
return withAction(chat, UploadVideoAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, RecordVoiceAction, block)
|
||||
return withAction(chat, RecordVoiceAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, UploadVoiceAction, block)
|
||||
return withAction(chat, UploadVoiceAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, UploadDocumentAction, block)
|
||||
return withAction(chat, UploadDocumentAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withFindLocationAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withFindLocationAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, FindLocationAction, block)
|
||||
return withAction(chat, FindLocationAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, RecordVideoNoteAction, block)
|
||||
return withAction(chat, RecordVideoNoteAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, UploadVideoNoteAction, block)
|
||||
return withAction(chat, UploadVideoNoteAction, threadId, block)
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
suspend fun <T> TelegramBot.withChooseStickerAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
||||
suspend fun <T> TelegramBot.withChooseStickerAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return withAction(chat, ChooseStickerAction, block)
|
||||
return withAction(chat, ChooseStickerAction, threadId, block)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ suspend fun TelegramBot.send(
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -65,7 +66,7 @@ suspend fun TelegramBot.send(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendAnimation] request
|
||||
@@ -77,6 +78,7 @@ suspend fun TelegramBot.send(
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -86,7 +88,7 @@ suspend fun TelegramBot.send(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chat, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendAnimation] request
|
||||
@@ -97,6 +99,7 @@ suspend fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
animation: AnimationFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -106,7 +109,7 @@ suspend fun TelegramBot.send(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendAnimation] request
|
||||
@@ -117,6 +120,7 @@ suspend fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
animation: AnimationFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -126,7 +130,7 @@ suspend fun TelegramBot.send(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chat, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendAudio] request
|
||||
@@ -688,13 +692,14 @@ suspend fun TelegramBot.send(
|
||||
photo: Photo,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
@@ -706,13 +711,14 @@ suspend fun TelegramBot.send(
|
||||
photo: Photo,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
@@ -724,13 +730,14 @@ suspend fun TelegramBot.send(
|
||||
photoSize: PhotoSize,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
@@ -742,13 +749,14 @@ suspend fun TelegramBot.send(
|
||||
photoSize: PhotoSize,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
@@ -759,13 +767,14 @@ suspend inline fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
photo: Photo,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
@@ -776,13 +785,14 @@ suspend inline fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
photo: Photo,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
@@ -793,13 +803,14 @@ suspend inline fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
photoSize: PhotoSize,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
@@ -810,13 +821,14 @@ suspend inline fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
photoSize: PhotoSize,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendRegularPoll] request
|
||||
@@ -1099,12 +1111,13 @@ suspend fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: Sticker,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendSticker] request
|
||||
@@ -1115,12 +1128,13 @@ suspend fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
sticker: Sticker,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(chat, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -1357,13 +1371,14 @@ suspend fun TelegramBot.send(
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chatId, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendVideo] request
|
||||
@@ -1375,13 +1390,14 @@ suspend fun TelegramBot.send(
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chat, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendVideo] request
|
||||
@@ -1392,13 +1408,14 @@ suspend inline fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
video: VideoFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chatId, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chatId, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendVideo] request
|
||||
@@ -1409,13 +1426,14 @@ suspend inline fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
video: VideoFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chat, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendVideoNote] request
|
||||
|
||||
@@ -23,6 +23,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -39,6 +40,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -60,6 +62,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -70,7 +73,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
chatId, animation.fileId, animation.thumbnail ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -83,6 +86,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -92,7 +96,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chat.id, animation, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -103,6 +107,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -112,7 +117,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chat.id, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,6 +129,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -139,6 +145,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
animation,
|
||||
thumb,
|
||||
entities,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -159,6 +166,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: AnimationFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -169,7 +177,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
chatId, animation.fileId, animation.thumbnail ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -181,6 +189,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -190,7 +199,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chat.id, animation, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -200,6 +209,7 @@ suspend fun TelegramBot.sendAnimation(
|
||||
chat: Chat,
|
||||
animation: AnimationFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -209,4 +219,4 @@ suspend fun TelegramBot.sendAnimation(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAnimation(chat.id, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -88,7 +88,7 @@ suspend fun TelegramBot.sendAudio(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -180,7 +180,7 @@ suspend inline fun TelegramBot.sendAudio(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
|
||||
@@ -83,7 +83,7 @@ suspend fun TelegramBot.sendDocument(
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
) = sendDocument(
|
||||
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
||||
chatId, document.fileId, document.thumbnail ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ suspend inline fun TelegramBot.sendDocument(
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
) = sendDocument(
|
||||
chatId, document.fileId, document.thumb ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
||||
chatId, document.fileId, document.thumbnail ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
fileId: InputFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -34,6 +35,7 @@ suspend fun TelegramBot.sendPhoto(
|
||||
fileId,
|
||||
text,
|
||||
parseMode,
|
||||
spoilered,
|
||||
threadId,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@@ -52,13 +54,14 @@ suspend fun TelegramBot.sendPhoto(
|
||||
fileId: InputFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat.id, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -69,13 +72,14 @@ suspend fun TelegramBot.sendPhoto(
|
||||
photo: Photo,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -86,13 +90,14 @@ suspend fun TelegramBot.sendPhoto(
|
||||
photo: Photo,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat.id, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -103,13 +108,14 @@ suspend fun TelegramBot.sendPhoto(
|
||||
photoSize: PhotoSize,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -120,13 +126,14 @@ suspend fun TelegramBot.sendPhoto(
|
||||
photoSize: PhotoSize,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat.id, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -137,6 +144,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
fileId: InputFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -148,6 +156,7 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
chatId,
|
||||
fileId,
|
||||
entities,
|
||||
spoilered,
|
||||
threadId,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@@ -165,13 +174,14 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
chat: Chat,
|
||||
fileId: InputFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat.id, fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -181,13 +191,14 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: Photo,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -197,13 +208,14 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
chat: Chat,
|
||||
photo: Photo,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat.id, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -213,13 +225,14 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photoSize: PhotoSize,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photoSize.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chatId, photoSize.fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -229,10 +242,11 @@ suspend inline fun TelegramBot.sendPhoto(
|
||||
chat: Chat,
|
||||
photoSize: PhotoSize,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendPhoto(chat.id, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -19,13 +19,14 @@ suspend fun TelegramBot.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: InputFile,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
SendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -36,12 +37,13 @@ suspend fun TelegramBot.sendSticker(
|
||||
chat: Chat,
|
||||
sticker: InputFile,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat.id, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(chat.id, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -51,12 +53,13 @@ suspend fun TelegramBot.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: Sticker,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chatId, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(chatId, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -66,9 +69,10 @@ suspend fun TelegramBot.sendSticker(
|
||||
chat: Chat,
|
||||
sticker: Sticker,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
emoji: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendSticker(chat, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -23,6 +23,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -39,6 +40,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -61,13 +63,14 @@ suspend fun TelegramBot.sendVideo(
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -79,6 +82,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -88,7 +92,7 @@ suspend fun TelegramBot.sendVideo(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chat.id, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -100,13 +104,14 @@ suspend fun TelegramBot.sendVideo(
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chat.id, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -117,6 +122,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -132,6 +138,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
video,
|
||||
thumb,
|
||||
entities,
|
||||
spoilered,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
@@ -153,13 +160,14 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: VideoFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -170,6 +178,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@@ -179,7 +188,7 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chat.id, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -190,10 +199,11 @@ suspend inline fun TelegramBot.sendVideo(
|
||||
chat: Chat,
|
||||
video: VideoFile,
|
||||
entities: TextSourcesList,
|
||||
spoilered: Boolean = false,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendVideo(chat.id, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -57,7 +57,7 @@ suspend fun TelegramBot.sendVideoNote(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(
|
||||
chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
chatId, videoNote.fileId, videoNote.thumbnail ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
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.AddAnimatedStickerToSet
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
@@ -1,90 +0,0 @@
|
||||
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.AddStaticStickerToSet
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
@@ -0,0 +1,116 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.AddStickerToSet
|
||||
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||
import dev.inmo.tgbotapi.types.StickerType
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
inputSticker: InputSticker
|
||||
) = execute(
|
||||
AddStickerToSet(userId, stickerSetName, inputSticker)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: InputSticker
|
||||
) = addStickerToSet(
|
||||
userId,
|
||||
stickerSet.name,
|
||||
sticker
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: InputFile,
|
||||
emojis: List<String>,
|
||||
keywords: List<String> = emptyList()
|
||||
) = addStickerToSet(
|
||||
userId,
|
||||
stickerSet,
|
||||
when (stickerSet.stickerType) {
|
||||
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||
sticker,
|
||||
emojis,
|
||||
keywords
|
||||
)
|
||||
StickerType.Mask -> InputSticker.Mask(
|
||||
sticker,
|
||||
emojis
|
||||
)
|
||||
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||
sticker,
|
||||
emojis,
|
||||
keywords
|
||||
)
|
||||
is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}")
|
||||
}
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: InputFile,
|
||||
emojis: List<String>,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
userId,
|
||||
stickerSet.name,
|
||||
when (stickerSet.stickerType) {
|
||||
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||
sticker,
|
||||
emojis,
|
||||
emptyList()
|
||||
)
|
||||
StickerType.Mask -> InputSticker.Mask(
|
||||
sticker,
|
||||
emojis,
|
||||
maskPosition
|
||||
)
|
||||
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||
sticker,
|
||||
emojis,
|
||||
emptyList()
|
||||
)
|
||||
is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}")
|
||||
}
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: InputSticker
|
||||
) = addStickerToSet(
|
||||
user.id,
|
||||
stickerSet.name,
|
||||
sticker
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: InputFile,
|
||||
emojis: List<String>,
|
||||
keywords: List<String> = emptyList()
|
||||
) = addStickerToSet(
|
||||
user.id, stickerSet, sticker, emojis, keywords
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: InputFile,
|
||||
emojis: List<String>,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
user.id, stickerSet, sticker, emojis, maskPosition
|
||||
)
|
||||
@@ -1,90 +0,0 @@
|
||||
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.AddVideoStickerToSet
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addVideoStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addVideoStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addVideoStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addVideoStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addVideoStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addVideoStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addVideoStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
@@ -1,58 +0,0 @@
|
||||
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.CreateNewAnimatedStickerSet
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewAnimatedStickerSet(
|
||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewAnimatedStickerSet(
|
||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
@@ -1,54 +0,0 @@
|
||||
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
|
||||
)
|
||||
@@ -1,54 +0,0 @@
|
||||
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
|
||||
)
|
||||
@@ -1,54 +0,0 @@
|
||||
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
|
||||
)
|
||||
@@ -1,50 +0,0 @@
|
||||
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
|
||||
)
|
||||
@@ -1,50 +0,0 @@
|
||||
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
|
||||
)
|
||||
@@ -1,50 +0,0 @@
|
||||
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
|
||||
)
|
||||
@@ -1,58 +0,0 @@
|
||||
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.CreateNewStaticStickerSet
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStaticStickerSet(
|
||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStaticStickerSet(
|
||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewStickerSet
|
||||
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||
import dev.inmo.tgbotapi.types.StickerFormat
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
|
||||
suspend fun TelegramBot.createNewStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
stickersFormat: StickerFormat,
|
||||
stickers: List<InputSticker>,
|
||||
needsRepainting: Boolean = false
|
||||
) = execute(
|
||||
CreateNewStickerSet(userId, name, title, stickersFormat, stickers, needsRepainting)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
stickersFormat: StickerFormat,
|
||||
stickers: List<InputSticker>,
|
||||
needsRepainting: Boolean = false,
|
||||
) = createNewStickerSet(
|
||||
user.id, name, title, stickersFormat, stickers, needsRepainting
|
||||
)
|
||||
@@ -1,58 +0,0 @@
|
||||
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.CreateNewVideoStickerSet
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewVideoStickerSet(
|
||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
title: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewVideoStickerSet(
|
||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
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.stickers.DeleteStickerFromSet
|
||||
import dev.inmo.tgbotapi.requests.stickers.DeleteStickerSet
|
||||
import dev.inmo.tgbotapi.types.StickerSetName
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.deleteStickerSet(
|
||||
name: StickerSetName
|
||||
) = execute(
|
||||
DeleteStickerSet(name)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.deleteStickerSet(
|
||||
sticker: Sticker
|
||||
) = deleteStickerSet(
|
||||
sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker")
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.deleteStickerSet(
|
||||
stickerSet: StickerSet,
|
||||
) = deleteStickerSet(stickerSet.name)
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.thumbs
|
||||
|
||||
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.SetCustomEmojiStickerSetThumbnail
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.StickerSetName
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
|
||||
stickerSetName: StickerSetName,
|
||||
customEmojiId: CustomEmojiId
|
||||
) = execute(
|
||||
SetCustomEmojiStickerSetThumbnail(stickerSetName, customEmojiId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
|
||||
stickerSet: StickerSet,
|
||||
customEmojiId: CustomEmojiId
|
||||
) = setCustomEmojiStickerSetThumbnail(
|
||||
stickerSet.name, customEmojiId
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
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.stickers.SetStickerEmojiList
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
|
||||
suspend fun TelegramBot.setStickerEmojiList(
|
||||
sticker: FileId,
|
||||
emojis: List<String>
|
||||
) = execute(
|
||||
SetStickerEmojiList(
|
||||
sticker,
|
||||
emojis
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerEmojiList(
|
||||
sticker: Sticker,
|
||||
vararg emojis: String
|
||||
) = setStickerEmojiList(
|
||||
sticker.fileId,
|
||||
emojis.toList()
|
||||
)
|
||||
@@ -0,0 +1,26 @@
|
||||
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.stickers.SetStickerEmojiList
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerKeywords
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
|
||||
suspend fun TelegramBot.setStickerKeywords(
|
||||
sticker: FileId,
|
||||
keywords: List<String>
|
||||
) = execute(
|
||||
SetStickerKeywords(
|
||||
sticker,
|
||||
keywords
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerKeywords(
|
||||
sticker: Sticker,
|
||||
vararg keywords: String
|
||||
) = setStickerKeywords(
|
||||
sticker.fileId,
|
||||
keywords.toList()
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
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.stickers.SetStickerEmojiList
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerMaskPosition
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.setStickerMaskPosition(
|
||||
sticker: FileId,
|
||||
maskPosition: MaskPosition
|
||||
) = execute(
|
||||
SetStickerMaskPosition(
|
||||
sticker,
|
||||
maskPosition
|
||||
)
|
||||
)
|
||||
@@ -3,72 +3,72 @@ package dev.inmo.tgbotapi.extensions.api.thumbs
|
||||
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.SetStickerSetThumb
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail
|
||||
import dev.inmo.tgbotapi.types.StickerSetName
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
userId: UserId,
|
||||
thumbSetName: String,
|
||||
thumb: FileId
|
||||
stickerSetName: StickerSetName,
|
||||
thumbnail: FileId
|
||||
) = execute(
|
||||
SetStickerSetThumb(userId, thumbSetName, thumb)
|
||||
SetStickerSetThumbnail(userId, stickerSetName, thumbnail)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
userId: UserId,
|
||||
thumbSetName: String,
|
||||
thumb: MultipartFile
|
||||
stickerSetName: StickerSetName,
|
||||
thumbnail: MultipartFile
|
||||
) = execute(
|
||||
SetStickerSetThumb(userId, thumbSetName, thumb)
|
||||
SetStickerSetThumbnail(userId, stickerSetName, thumbnail)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
user: CommonUser,
|
||||
thumbSetName: String,
|
||||
thumb: FileId
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSetName, thumb
|
||||
stickerSetName: StickerSetName,
|
||||
thumbnail: FileId
|
||||
) = setStickerSetThumbnail(
|
||||
user.id, stickerSetName, thumbnail
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
user: CommonUser,
|
||||
thumbSetName: String,
|
||||
thumb: MultipartFile
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSetName, thumb
|
||||
stickerSetName: StickerSetName,
|
||||
thumbnail: MultipartFile
|
||||
) = setStickerSetThumbnail(
|
||||
user.id, stickerSetName, thumbnail
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
userId: UserId,
|
||||
thumbSet: StickerSet,
|
||||
thumb: FileId
|
||||
) = setStickerSetThumb(
|
||||
userId, thumbSet.name, thumb
|
||||
stickerSet: StickerSet,
|
||||
thumbnail: FileId
|
||||
) = setStickerSetThumbnail(
|
||||
userId, stickerSet.name, thumbnail
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
userId: UserId,
|
||||
thumbSet: StickerSet,
|
||||
thumb: MultipartFile
|
||||
) = setStickerSetThumb(
|
||||
userId, thumbSet.name, thumb
|
||||
stickerSet: StickerSet,
|
||||
thumbnail: MultipartFile
|
||||
) = setStickerSetThumbnail(
|
||||
userId, stickerSet.name, thumbnail
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
user: CommonUser,
|
||||
thumbSet: StickerSet,
|
||||
thumb: FileId
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSet.name, thumb
|
||||
stickerSet: StickerSet,
|
||||
thumbnail: FileId
|
||||
) = setStickerSetThumbnail(
|
||||
user.id, stickerSet.name, thumbnail
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||
user: CommonUser,
|
||||
thumbSet: StickerSet,
|
||||
thumb: MultipartFile
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSet.name, thumb
|
||||
stickerSet: StickerSet,
|
||||
thumbnail: MultipartFile
|
||||
) = setStickerSetThumbnail(
|
||||
user.id, stickerSet.name, thumbnail
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetTitle
|
||||
import dev.inmo.tgbotapi.types.StickerSetName
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.setStickerSetTitle(
|
||||
name: StickerSetName,
|
||||
title: String
|
||||
) = execute(SetStickerSetTitle(name, title))
|
||||
|
||||
suspend fun TelegramBot.setStickerSetTitle(
|
||||
sticker: Sticker,
|
||||
title: String
|
||||
) = setStickerSetTitle(sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker"), title)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetTitle(
|
||||
stickerSet: StickerSet,
|
||||
title: String
|
||||
) = setStickerSetTitle(stickerSet.name, title)
|
||||
@@ -3,19 +3,22 @@ package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
||||
import dev.inmo.tgbotapi.types.StickerFormat
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
|
||||
suspend fun TelegramBot.uploadStickerFile(
|
||||
userId: UserId,
|
||||
sticker: MultipartFile
|
||||
sticker: MultipartFile,
|
||||
stickerFormat: StickerFormat
|
||||
) = execute(
|
||||
UploadStickerFile(userId, sticker)
|
||||
UploadStickerFile(userId, sticker, stickerFormat)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.uploadStickerFile(
|
||||
user: CommonUser,
|
||||
sticker: MultipartFile
|
||||
sticker: MultipartFile,
|
||||
stickerFormat: StickerFormat
|
||||
) = execute(
|
||||
UploadStickerFile(user.id, sticker)
|
||||
UploadStickerFile(user.id, sticker, stickerFormat)
|
||||
)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.utils
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.extensions.api.InternalUtils.convertWithMediaGroupUpdates
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.updateshandlers.UpdateReceiver
|
||||
@@ -28,26 +29,18 @@ fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(
|
||||
)
|
||||
|
||||
launch {
|
||||
launch {
|
||||
launchSafelyWithoutExceptions {
|
||||
for (update in updatesChannel) {
|
||||
val dataAsPossiblySentViaBotCommonMessage = update.data as? PossiblySentViaBotCommonMessage<*>
|
||||
|
||||
if (dataAsPossiblySentViaBotCommonMessage == null) {
|
||||
output(update)
|
||||
continue
|
||||
val data = update.data
|
||||
when {
|
||||
data is PossiblyMediaGroupMessage<*> && data.mediaGroupId != null -> {
|
||||
mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate)
|
||||
}
|
||||
else -> output(update)
|
||||
}
|
||||
|
||||
val mediaGroupId = dataAsPossiblySentViaBotCommonMessage.mediaGroupId
|
||||
|
||||
if (mediaGroupId == null) {
|
||||
output(update)
|
||||
continue
|
||||
}
|
||||
|
||||
mediaGroupChannel.send("${mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate)
|
||||
}
|
||||
}
|
||||
launch {
|
||||
launchSafelyWithoutExceptions {
|
||||
for ((_, mediaGroup) in mediaGroupAccumulatedChannel) {
|
||||
mediaGroup.convertWithMediaGroupUpdates().forEach {
|
||||
output(it)
|
||||
|
||||
@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||
import io.ktor.util.cio.use
|
||||
import io.ktor.util.cio.writeChannel
|
||||
import io.ktor.utils.io.copyAndClose
|
||||
import io.ktor.utils.io.copyTo
|
||||
import kotlinx.coroutines.job
|
||||
import java.io.File
|
||||
@@ -25,7 +26,7 @@ suspend fun TelegramBot.downloadFile(
|
||||
doOutsideOfCoroutine { destFile.createNewFile() }
|
||||
|
||||
destFile.writeChannel(coroutineContext.job).use {
|
||||
readChannel.copyTo(this)
|
||||
readChannel.copyAndClose(this)
|
||||
}
|
||||
|
||||
return destFile
|
||||
|
||||
@@ -30,11 +30,17 @@ suspend fun TelegramBot.downloadFileToTemp(
|
||||
|
||||
suspend fun TelegramBot.downloadFileToTemp(
|
||||
pathedFile: PathedFile
|
||||
) = downloadFileToTemp(
|
||||
): File = downloadFileToTemp(
|
||||
pathedFile.filePath
|
||||
).apply {
|
||||
runCatching {
|
||||
renameTo(File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}"))
|
||||
).run {
|
||||
val newFile = File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}")
|
||||
val success = runCatching {
|
||||
renameTo(newFile)
|
||||
}.getOrElse { false }
|
||||
if (success) {
|
||||
newFile
|
||||
} else {
|
||||
this@run
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "org.jetbrains.dokka"
|
||||
}
|
||||
|
||||
project.description = "Behaviour Builder DSL"
|
||||
|
||||
@@ -10,6 +10,8 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.T
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
@@ -91,8 +93,9 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
|
||||
behaviourContext: BehaviourContext,
|
||||
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||
statesManager: StatesManager<T>,
|
||||
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, onStateHandlingErrorHandler)
|
||||
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, fallbackHandler, onStateHandlingErrorHandler)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,11 +130,15 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
private val behaviourContext: BehaviourContext,
|
||||
private val statesManager: StatesManager<T>,
|
||||
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||
private val fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
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
|
||||
private var actualHandlersList = additionalHandlers + handlers + listOfNotNull(fallbackHandler)
|
||||
|
||||
protected val statesJobs = mutableMapOf<T, Job>()
|
||||
protected val statesJobsMutex = Mutex()
|
||||
|
||||
override suspend fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>): T? {
|
||||
return launchStateHandling(state, handlers, onStateHandlingErrorHandler)
|
||||
@@ -164,21 +171,49 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
statesManager.endChain(state)
|
||||
}
|
||||
}
|
||||
|
||||
fun Job.enableRemoveOnCompletion(state: T) {
|
||||
invokeOnCompletion {
|
||||
launchSafelyWithoutExceptions {
|
||||
statesJobsMutex.withLock {
|
||||
if (this@enableRemoveOnCompletion === statesJobs[state]) {
|
||||
statesJobs.remove(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
statesManager.onStartChain.subscribeSafelyWithoutExceptions(this) {
|
||||
launch { statePerformer(it) }
|
||||
statesJobsMutex.withLock {
|
||||
runCatchingSafely { statesJobs.remove(it) ?.cancel() }
|
||||
|
||||
statesJobs[it] = launch { statePerformer(it) }.apply { enableRemoveOnCompletion(it) }
|
||||
}
|
||||
}
|
||||
statesManager.onEndChain.subscribeSafelyWithoutExceptions(this) {
|
||||
statesJobsMutex.withLock {
|
||||
runCatchingSafely { statesJobs.remove(it) ?.cancel() }
|
||||
}
|
||||
updatesFlows.remove(it.context)
|
||||
}
|
||||
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) ->
|
||||
statesJobsMutex.withLock {
|
||||
runCatchingSafely { statesJobs.remove(old) ?.cancel() }
|
||||
runCatchingSafely { statesJobs.remove(new) ?.cancel() }
|
||||
statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(new) }
|
||||
}
|
||||
if (old.context != new.context) {
|
||||
updatesFlows.remove(old.context)
|
||||
}
|
||||
launch { statePerformer(new) }
|
||||
}
|
||||
statesManager.onEndChain.subscribeSafelyWithoutExceptions(this) {
|
||||
updatesFlows.remove(it.context)
|
||||
}
|
||||
|
||||
statesManager.getActiveStates().forEach {
|
||||
launch { statePerformer(it) }
|
||||
statesJobsMutex.withLock {
|
||||
runCatchingSafely { statesJobs.remove(it) ?.cancel() }
|
||||
|
||||
statesJobs[it] = launch { statePerformer(it) }.apply { enableRemoveOnCompletion(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -217,6 +252,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
||||
handlers,
|
||||
statesManager,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler
|
||||
)
|
||||
|
||||
@@ -232,6 +268,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
||||
handlers,
|
||||
statesManager,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ 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.updateHandlerWithMediaGroupsAdaptation
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import kotlinx.coroutines.*
|
||||
@@ -29,6 +31,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||
@@ -39,6 +42,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
),
|
||||
presetHandlers,
|
||||
statesManager,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler
|
||||
).apply { block() }
|
||||
|
||||
@@ -46,6 +50,10 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
* Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates
|
||||
* using [longPolling]. For [longPolling] will be used result [BehaviourContextWithFSM] for both parameters
|
||||
* flowsUpdatesFilter and scope
|
||||
*
|
||||
* @param mediaGroupsDebounceTimeMillis Will be used for calling of [updateHandlerWithMediaGroupsAdaptation]. Pass null
|
||||
* in case you wish to enable classic way of updates handling, but in that mode some media group messages can be
|
||||
* retrieved in different updates
|
||||
*/
|
||||
suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
@@ -53,7 +61,12 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
timeoutSeconds: Seconds = 30,
|
||||
autoDisableWebhooks: Boolean = true,
|
||||
autoSkipTimeoutExceptions: Boolean = true,
|
||||
mediaGroupsDebounceTimeMillis: Long? = 1000L,
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): Pair<DefaultBehaviourContextWithFSM<T>, Job> = buildBehaviourWithFSM(
|
||||
upstreamUpdatesFlow,
|
||||
@@ -61,12 +74,13 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler,
|
||||
block
|
||||
).run {
|
||||
this to scope.launch {
|
||||
start()
|
||||
longPolling(flowsUpdatesFilter, scope = scope)
|
||||
longPolling(flowsUpdatesFilter, timeoutSeconds, scope, autoDisableWebhooks, autoSkipTimeoutExceptions, mediaGroupsDebounceTimeMillis, defaultExceptionsHandler)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +108,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||
@@ -104,6 +119,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
),
|
||||
presetHandlers,
|
||||
statesManager,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler
|
||||
).apply { block() }
|
||||
|
||||
@@ -112,6 +128,10 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||
* using [longPolling]. For [longPolling] will be used result [BehaviourContextWithFSM] for both parameters
|
||||
* flowsUpdatesFilter and scope
|
||||
*
|
||||
* @param mediaGroupsDebounceTimeMillis Will be used for calling of [updateHandlerWithMediaGroupsAdaptation]. Pass null
|
||||
* in case you wish to enable classic way of updates handling, but in that mode some media group messages can be
|
||||
* retrieved in different updates
|
||||
*
|
||||
* @see buildBehaviourWithFSMAndStartLongPolling
|
||||
* @see BehaviourContext
|
||||
* @see longPolling
|
||||
@@ -123,7 +143,12 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
timeoutSeconds: Seconds = 30,
|
||||
autoDisableWebhooks: Boolean = true,
|
||||
autoSkipTimeoutExceptions: Boolean = true,
|
||||
mediaGroupsDebounceTimeMillis: Long? = 1000L,
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
) = FlowsUpdatesFilter().let {
|
||||
buildBehaviourWithFSM(
|
||||
@@ -132,13 +157,19 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler,
|
||||
block
|
||||
).run {
|
||||
start()
|
||||
longPolling(
|
||||
flowsUpdatesFilter,
|
||||
scope = scope
|
||||
timeoutSeconds,
|
||||
scope,
|
||||
autoDisableWebhooks,
|
||||
autoSkipTimeoutExceptions,
|
||||
mediaGroupsDebounceTimeMillis,
|
||||
defaultExceptionsHandler
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ 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.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -25,6 +27,10 @@ import kotlin.coroutines.coroutineContext
|
||||
* **WARNING** This method WILL NOT launch any listening of updates. Use something like
|
||||
* [startGettingOfUpdatesByLongPolling] or tools for work with webhooks
|
||||
*
|
||||
* @param mediaGroupsDebounceTimeMillis Will be used for calling of [updateHandlerWithMediaGroupsAdaptation]. Pass null
|
||||
* in case you wish to enable classic way of updates handling, but in that mode some media group messages can be
|
||||
* retrieved in different updates
|
||||
*
|
||||
* @return Created bot which has been used to create [BehaviourContext] via [buildBehaviourWithFSM]
|
||||
*
|
||||
* @see [BehaviourContext]
|
||||
@@ -40,8 +46,13 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
testServer: Boolean = false,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
timeoutSeconds: Seconds = 30,
|
||||
autoDisableWebhooks: Boolean = true,
|
||||
autoSkipTimeoutExceptions: Boolean = true,
|
||||
mediaGroupsDebounceTimeMillis: Long? = 1000L,
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): TelegramBot = telegramBot(
|
||||
token,
|
||||
@@ -55,7 +66,12 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler,
|
||||
timeoutSeconds,
|
||||
autoDisableWebhooks,
|
||||
autoSkipTimeoutExceptions,
|
||||
mediaGroupsDebounceTimeMillis,
|
||||
block
|
||||
)
|
||||
}
|
||||
@@ -64,6 +80,10 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
||||
* Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithFSMAndStartLongPolling]. This
|
||||
* method will launch updates retrieving via long polling inside of [buildBehaviourWithFSMAndStartLongPolling]
|
||||
*
|
||||
* @param mediaGroupsDebounceTimeMillis Will be used for calling of [updateHandlerWithMediaGroupsAdaptation]. Pass null
|
||||
* in case you wish to enable classic way of updates handling, but in that mode some media group messages can be
|
||||
* retrieved in different updates
|
||||
*
|
||||
* @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed
|
||||
* here
|
||||
*
|
||||
@@ -79,8 +99,13 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||
testServer: Boolean = false,
|
||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||
timeoutSeconds: Seconds = 30,
|
||||
autoDisableWebhooks: Boolean = true,
|
||||
autoSkipTimeoutExceptions: Boolean = true,
|
||||
mediaGroupsDebounceTimeMillis: Long? = 1000L,
|
||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||
): Pair<TelegramBot, Job> {
|
||||
return telegramBot(
|
||||
@@ -94,7 +119,12 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
||||
defaultExceptionsHandler,
|
||||
statesManager,
|
||||
presetHandlers,
|
||||
fallbackHandler,
|
||||
onStateHandlingErrorHandler,
|
||||
timeoutSeconds,
|
||||
autoDisableWebhooks,
|
||||
autoSkipTimeoutExceptions,
|
||||
mediaGroupsDebounceTimeMillis,
|
||||
block
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "org.jetbrains.dokka"
|
||||
}
|
||||
|
||||
project.description = "Behaviour Builder DSL"
|
||||
|
||||
@@ -5,6 +5,8 @@ import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
||||
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.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
@@ -46,6 +48,10 @@ suspend fun TelegramBot.buildBehaviour(
|
||||
* Use this method to build bot behaviour and run it via long polling. In case you wish to get [FlowsUpdatesFilter] for
|
||||
* additional manipulations, you must provide external [FlowsUpdatesFilter] in other [buildBehaviour] function.
|
||||
*
|
||||
* @param mediaGroupsDebounceTimeMillis Will be used for calling of [updateHandlerWithMediaGroupsAdaptation]. Pass null
|
||||
* in case you wish to enable classic way of updates handling, but in that mode some media group messages can be
|
||||
* retrieved in different updates
|
||||
*
|
||||
* @see buildBehaviour
|
||||
* @see BehaviourContext
|
||||
* @see startGettingOfUpdatesByLongPolling
|
||||
@@ -53,6 +59,10 @@ suspend fun TelegramBot.buildBehaviour(
|
||||
suspend fun TelegramBot.buildBehaviourWithLongPolling(
|
||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
timeoutSeconds: Seconds = 30,
|
||||
autoDisableWebhooks: Boolean = true,
|
||||
autoSkipTimeoutExceptions: Boolean = true,
|
||||
mediaGroupsDebounceTimeMillis: Long? = 1000L,
|
||||
block: BehaviourContextReceiver<Unit>
|
||||
): Job {
|
||||
val behaviourContext = buildBehaviour(
|
||||
@@ -62,6 +72,10 @@ suspend fun TelegramBot.buildBehaviourWithLongPolling(
|
||||
)
|
||||
return longPolling(
|
||||
behaviourContext,
|
||||
scope = behaviourContext
|
||||
scope = behaviourContext,
|
||||
timeoutSeconds = timeoutSeconds,
|
||||
autoDisableWebhooks = autoDisableWebhooks,
|
||||
autoSkipTimeoutExceptions = autoSkipTimeoutExceptions,
|
||||
mediaGroupsDebounceTimeMillis = mediaGroupsDebounceTimeMillis
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.updateshandlers.*
|
||||
import kotlinx.coroutines.*
|
||||
@@ -71,9 +72,17 @@ class DefaultBehaviourContext(
|
||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
||||
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
||||
if (upstreamUpdatesFlow != null) {
|
||||
var lastHandledUpdate = -1L
|
||||
val handledUpdates = mutableSetOf<UpdateIdentifier>()
|
||||
(it + upstreamUpdatesFlow).filter {
|
||||
(it.updateId > lastHandledUpdate).also { passed -> if (passed) { lastHandledUpdate = it.updateId } }
|
||||
val passed = handledUpdates.add(it.updateId)
|
||||
(passed).also { passed ->
|
||||
val needToDropCount = handledUpdates.size - broadcastChannelsSize
|
||||
if (needToDropCount > 0) {
|
||||
handledUpdates.removeAll(
|
||||
handledUpdates.take(needToDropCount).ifEmpty { return@also }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it
|
||||
|
||||
@@ -5,6 +5,8 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
||||
import kotlinx.coroutines.*
|
||||
@@ -52,6 +54,10 @@ suspend fun telegramBotWithBehaviour(
|
||||
*
|
||||
* **WARNING** This method WILL launch updates listening inside of calling [buildBehaviourWithLongPolling]
|
||||
*
|
||||
* @param mediaGroupsDebounceTimeMillis Will be used for calling of [updateHandlerWithMediaGroupsAdaptation]. Pass null
|
||||
* in case you wish to enable classic way of updates handling, but in that mode some media group messages can be
|
||||
* retrieved in different updates
|
||||
*
|
||||
* @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed
|
||||
* here
|
||||
*
|
||||
@@ -66,6 +72,10 @@ suspend fun telegramBotWithBehaviourAndLongPolling(
|
||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
testServer: Boolean = false,
|
||||
timeoutSeconds: Seconds = 30,
|
||||
autoDisableWebhooks: Boolean = true,
|
||||
autoSkipTimeoutExceptions: Boolean = true,
|
||||
mediaGroupsDebounceTimeMillis: Long? = 1000L,
|
||||
block: BehaviourContextReceiver<Unit>
|
||||
): Pair<TelegramBot, Job> {
|
||||
return telegramBot(
|
||||
@@ -77,6 +87,10 @@ suspend fun telegramBotWithBehaviourAndLongPolling(
|
||||
it to it.buildBehaviourWithLongPolling(
|
||||
scope ?: CoroutineScope(coroutineContext),
|
||||
defaultExceptionsHandler,
|
||||
timeoutSeconds,
|
||||
autoDisableWebhooks,
|
||||
autoSkipTimeoutExceptions,
|
||||
mediaGroupsDebounceTimeMillis,
|
||||
block
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,125 +10,131 @@ import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
|
||||
typealias CommonMessageToContentMapper<T> = suspend CommonMessage<T>.() -> T?
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitContent(
|
||||
suspend inline fun BehaviourContext.waitContent(
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = waitContentMessage<O>(initRequest, includeMediaGroups, errorFactory).map { it.content }
|
||||
): Flow<MessageContent> = waitContentMessage(initRequest, errorFactory).map { it.content }
|
||||
|
||||
inline fun <reified T : MessageContent> Flow<MessageContent>.mapContent() = mapNotNull { it as? T }
|
||||
|
||||
suspend fun BehaviourContext.waitContent(
|
||||
suspend fun BehaviourContext.waitAnyContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<MessageContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitTextedContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<TextedContent>()
|
||||
suspend fun BehaviourContext.waitContact(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<ContactContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<ContactContent>()
|
||||
suspend fun BehaviourContext.waitDice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<DiceContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<DiceContent>()
|
||||
suspend fun BehaviourContext.waitGame(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<GameContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<GameContent>()
|
||||
suspend fun BehaviourContext.waitLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<LocationContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<LocationContent>()
|
||||
suspend fun BehaviourContext.waitLiveLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<LiveLocationContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<LiveLocationContent>()
|
||||
suspend fun BehaviourContext.waitStaticLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<StaticLocationContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<StaticLocationContent>()
|
||||
suspend fun BehaviourContext.waitPoll(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<PollContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<PollContent>()
|
||||
suspend fun BehaviourContext.waitText(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<TextContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<TextContent>()
|
||||
suspend fun BehaviourContext.waitStory(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<StoryContent>()
|
||||
suspend fun BehaviourContext.waitVenue(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<VenueContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<VenueContent>()
|
||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<AudioMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<AudioMediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<DocumentMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<DocumentMediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitMedia(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<MediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<MediaContent>()
|
||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<MediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<MediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<VisualMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<VisualMediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitTextedMediaContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContent<TextedMediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<TextedMediaContent>()
|
||||
suspend fun BehaviourContext.waitAnimation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<AnimationContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<AnimationContent>()
|
||||
suspend fun BehaviourContext.waitAudio(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<AudioContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<AudioContent>()
|
||||
suspend fun BehaviourContext.waitDocument(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<DocumentContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<DocumentContent>()
|
||||
suspend fun BehaviourContext.waitPhoto(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<PhotoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<PhotoContent>()
|
||||
suspend fun BehaviourContext.waitSticker(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<StickerContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<StickerContent>()
|
||||
suspend fun BehaviourContext.waitVideo(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContent<VideoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<VideoContent>()
|
||||
suspend fun BehaviourContext.waitVideoNote(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<VideoNoteContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<VideoNoteContent>()
|
||||
suspend fun BehaviourContext.waitVoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<VoiceContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<VoiceContent>()
|
||||
suspend fun BehaviourContext.waitInvoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent<InvoiceContent>(initRequest, false, errorFactory)
|
||||
) = waitContent(initRequest, errorFactory).mapContent<InvoiceContent>()
|
||||
suspend fun BehaviourContext.waitVisualContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<VisualMediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitMediaContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<MediaContent>()
|
||||
|
||||
@@ -5,6 +5,7 @@ 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.utils.withContent
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
@@ -12,146 +13,142 @@ 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.filter
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
|
||||
typealias CommonMessageToCommonMessageMapper<T> = suspend CommonMessage<T>.() -> CommonMessage<T>?
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitContentMessage(
|
||||
suspend inline fun BehaviourContext.waitContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<CommonMessage<O>> = expectFlow(
|
||||
): Flow<CommonMessage<MessageContent>> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
listOfNotNull((it.data as? CommonMessage<*>) ?.withContent<O>())
|
||||
}
|
||||
|
||||
internal inline fun <reified T : MessageContent> contentMessageConverter(
|
||||
noinline mapper: CommonMessageToCommonMessageMapper<T>? = null
|
||||
): suspend CommonMessage<MessageContent>.() -> CommonMessage<T>? = mapper ?.let {
|
||||
{
|
||||
if (content is T) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val message = (this as CommonMessage<T>)
|
||||
safelyWithoutExceptions { mapper(message) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
if (it !is BaseSentMessageUpdate) {
|
||||
return@expectFlow emptyList()
|
||||
}
|
||||
} ?: {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
if (content is T) this as CommonMessage<T> else null
|
||||
listOfNotNull((it.data as? CommonMessage<*>))
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitContentMessage(
|
||||
inline fun <reified T : MessageContent> Flow<CommonMessage<MessageContent>>.mapWithContent() = mapNotNull { it.withContentOrNull<T>() }
|
||||
|
||||
suspend fun BehaviourContext.waitAnyContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<MessageContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitTextedContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextedContent>()
|
||||
suspend fun BehaviourContext.waitContactMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<ContactContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<ContactContent>()
|
||||
suspend fun BehaviourContext.waitDiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<DiceContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<DiceContent>()
|
||||
suspend fun BehaviourContext.waitGameMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<GameContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<GameContent>()
|
||||
suspend fun BehaviourContext.waitLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<LocationContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<LocationContent>()
|
||||
suspend fun BehaviourContext.waitLiveLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<LiveLocationContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<LiveLocationContent>()
|
||||
suspend fun BehaviourContext.waitStaticLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<StaticLocationContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<StaticLocationContent>()
|
||||
suspend fun BehaviourContext.waitPollMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<PollContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<PollContent>()
|
||||
suspend fun BehaviourContext.waitTextMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<TextContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextContent>()
|
||||
suspend fun BehaviourContext.waitStoryMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<StoryContent>()
|
||||
suspend fun BehaviourContext.waitVenueMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<VenueContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<VenueContent>()
|
||||
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<AudioMediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<DocumentMediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitMediaMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<MediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<MediaContent>()
|
||||
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<MediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<MediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<VisualMediaGroupPartContent>()
|
||||
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = true
|
||||
) = waitContentMessage<TextedMediaContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextedMediaContent>()
|
||||
suspend fun BehaviourContext.waitAnimationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<AnimationContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<AnimationContent>()
|
||||
suspend fun BehaviourContext.waitAudioMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<AudioContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<AudioContent>()
|
||||
suspend fun BehaviourContext.waitDocumentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<DocumentContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<DocumentContent>()
|
||||
suspend fun BehaviourContext.waitPhotoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<PhotoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<PhotoContent>()
|
||||
suspend fun BehaviourContext.waitStickerMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<StickerContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<StickerContent>()
|
||||
suspend fun BehaviourContext.waitVideoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
includeMediaGroups: Boolean = false
|
||||
) = waitContentMessage<VideoContent>(initRequest, includeMediaGroups, errorFactory)
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<VideoContent>()
|
||||
suspend fun BehaviourContext.waitVideoNoteMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<VideoNoteContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<VideoNoteContent>()
|
||||
suspend fun BehaviourContext.waitVoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<VoiceContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<VoiceContent>()
|
||||
suspend fun BehaviourContext.waitInvoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage<InvoiceContent>(initRequest, false, errorFactory)
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<InvoiceContent>()
|
||||
|
||||
suspend fun BehaviourContext.waitVisualContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<VisualMediaGroupPartContent>()
|
||||
|
||||
suspend fun BehaviourContext.waitMediaContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<MediaContent>()
|
||||
|
||||
@@ -21,3 +21,17 @@ suspend fun BehaviourContext.waitDeepLinks(
|
||||
.flattenCommandsWithParams().mapNotNull {
|
||||
it.first to (it.second.second.singleOrNull() ?.regularTextSourceOrNull() ?.source ?.removePrefix(" ") ?: return@mapNotNull null)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitDeepLinks(
|
||||
regex: Regex,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
): Flow<Pair<CommonMessage<TextContent>, String>> = waitDeepLinks(initRequest, errorFactory).filter {
|
||||
regex.matches(it.second)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitDeepLinks(
|
||||
deepLink: String,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
): Flow<Pair<CommonMessage<TextContent>, String>> = waitDeepLinks(Regex("^$deepLink$"), initRequest, errorFactory)
|
||||
|
||||
@@ -9,10 +9,17 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
|
||||
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.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -102,7 +109,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEvents(
|
||||
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<LeftChatMember>(initRequest, errorFactory)
|
||||
) = waitEvents<LeftChatMemberEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
@@ -151,3 +158,34 @@ suspend fun BehaviourContext.waitForumTopicReopened(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ForumTopicReopened>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitForumTopicEdited(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ForumTopicEdited>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitGeneralForumTopicHidden(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<GeneralForumTopicHidden>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitGeneralForumTopicUnhidden(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<GeneralForumTopicUnhidden>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitWriteAccessAllowed(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<WriteAccessAllowed>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatSharedRequest(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChatSharedRequest>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitUserShared(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<UserShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatShared(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChatShared>(initRequest, errorFactory)
|
||||
|
||||
@@ -9,10 +9,17 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
|
||||
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.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -99,7 +106,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEventsMessages(
|
||||
suspend fun BehaviourContext.waitLeftChatMemberEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<LeftChatMember>(initRequest, errorFactory)
|
||||
) = waitEventsMessages<LeftChatMemberEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitNewChatPhotoEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
@@ -148,3 +155,34 @@ suspend fun BehaviourContext.waitForumTopicReopenedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ForumTopicReopened>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitForumTopicEditedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ForumTopicEdited>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitGeneralForumTopicHiddenEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<GeneralForumTopicHidden>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitGeneralForumTopicUnhiddenEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<GeneralForumTopicUnhidden>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitWriteAccessAllowedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<WriteAccessAllowed>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatSharedRequestEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatSharedRequest>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitUserSharedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<UserShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatShared>(initRequest, errorFactory)
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.whenMentionTextSource
|
||||
import dev.inmo.tgbotapi.extensions.utils.whenTextMentionTextSource
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import dev.inmo.tgbotapi.types.message.content.TextedContent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
|
||||
/**
|
||||
* Check, that [TextedContent.textSources] contains:
|
||||
*
|
||||
* * Any [dev.inmo.tgbotapi.types.message.textsources.MentionTextSource] with [dev.inmo.tgbotapi.types.message.textsources.MentionTextSource.username]
|
||||
* equal to [username]
|
||||
* * Any [dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource] with [dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource.user]
|
||||
* with the same [username]
|
||||
*/
|
||||
fun TextedContent.isWithMention(username: Username) = textSources.any {
|
||||
it.whenMentionTextSource {
|
||||
it.username == username
|
||||
} ?: it.whenTextMentionTextSource {
|
||||
it.user.username == username
|
||||
} ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* Check, that [TextedContent.textSources] contains:
|
||||
*
|
||||
* * Any [dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource] with [dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource.user]
|
||||
* with the same [userId]
|
||||
*/
|
||||
fun TextedContent.isWithTextMention(userId: UserId) = textSources.any {
|
||||
it.whenTextMentionTextSource {
|
||||
it.user.id == userId
|
||||
} ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses [isWithMention] with [user] [Username] (is presented) or [isWithTextMention] with [user] [UserId] to determine
|
||||
* user mentioning in [this] [CommonMessage]
|
||||
*/
|
||||
fun TextedContent.isWithMention(user: User): Boolean = user.username ?.let { username -> isWithMention(username) } == true || isWithTextMention(user.id)
|
||||
|
||||
/**
|
||||
* Uses [isWithMention] passing [username] as argument to take only messages with [username] mentions or text mentions
|
||||
*/
|
||||
fun Flow<TextedContent>.filterMentions(username: Username) = filter {
|
||||
it.isWithMention(username)
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses [isWithTextMention] passing [userId] as argument to take only messages with [userId] text mentions
|
||||
*/
|
||||
fun Flow<TextedContent>.filterTextMentions(userId: UserId) = filter {
|
||||
it.isWithTextMention(userId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses [isWithMention] passing [user] as argument to take only messages with [user] mentions or text mentions
|
||||
*/
|
||||
fun Flow<TextedContent>.filterMentions(user: User) = filter {
|
||||
it.isWithMention(user)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates cold [Flow] with the messages with [TextedContent] where [username] has been mentioned
|
||||
*
|
||||
* @see filterMentions
|
||||
* @see filterTextMentions
|
||||
*/
|
||||
suspend fun BehaviourContext.waitContentWithMentions (
|
||||
username: Username,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContent(initRequest, errorFactory).mapContent<TextedContent>().filterMentions(username)
|
||||
|
||||
/**
|
||||
* Creates cold [Flow] with the messages with [TextedContent] where [userId] has been mentioned with text
|
||||
*
|
||||
* @see filterTextMentions
|
||||
* @see filterMentions
|
||||
* @see dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource
|
||||
*/
|
||||
suspend fun BehaviourContext.waitContentWithTextMentions (
|
||||
userId: UserId,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitTextedContent(initRequest, errorFactory).filterTextMentions(userId)
|
||||
|
||||
/**
|
||||
* Creates cold [Flow] with the messages with [TextedContent] where [user] has been mentioned as text or mentioned
|
||||
* with text
|
||||
*
|
||||
* @see filterMentions
|
||||
* @see filterTextMentions
|
||||
*/
|
||||
suspend fun BehaviourContext.waitContentWithMentions (
|
||||
user: User,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitTextedContent(initRequest, errorFactory).filterMentions(user)
|
||||
@@ -0,0 +1,82 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.whenMentionTextSource
|
||||
import dev.inmo.tgbotapi.extensions.utils.whenTextMentionTextSource
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextedContent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
|
||||
fun CommonMessage<TextedContent>.isWithMention(username: Username) = content.isWithMention(username)
|
||||
|
||||
fun CommonMessage<TextedContent>.isWithTextMention(userId: UserId) = content.isWithTextMention(userId)
|
||||
|
||||
/**
|
||||
* Uses [isWithMention] with [user] [Username] (is presented) or [isWithTextMention] with [user] [UserId] to determine
|
||||
* user mentioning in [this] [CommonMessage]
|
||||
*/
|
||||
fun CommonMessage<TextedContent>.isWithMention(user: User): Boolean = content.isWithMention(user)
|
||||
|
||||
/**
|
||||
* Uses [isWithMention] passing [username] as argument to take only messages with [username] mentions or text mentions
|
||||
*/
|
||||
fun Flow<CommonMessage<TextedContent>>.filterMentionsMessages(username: Username) = filter {
|
||||
it.isWithMention(username)
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses [isWithTextMention] passing [userId] as argument to take only messages with [userId] text mentions
|
||||
*/
|
||||
fun Flow<CommonMessage<TextedContent>>.filterTextMentionsMessages(userId: UserId) = filter {
|
||||
it.isWithTextMention(userId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses [isWithMention] passing [user] as argument to take only messages with [user] mentions or text mentions
|
||||
*/
|
||||
fun Flow<CommonMessage<TextedContent>>.filterMentionsMessages(user: User) = filter {
|
||||
it.isWithMention(user)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates cold [Flow] with the messages with [TextedContent] where [username] has been mentioned
|
||||
*
|
||||
* @see filterMentions
|
||||
* @see filterTextMentions
|
||||
*/
|
||||
suspend fun BehaviourContext.waitContentMessageWithMentions (
|
||||
username: Username,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextedContent>().filterMentionsMessages(username)
|
||||
|
||||
/**
|
||||
* Creates cold [Flow] with the messages with [TextedContent] where [userId] has been mentioned with text
|
||||
*
|
||||
* @see filterTextMentions
|
||||
* @see filterMentions
|
||||
* @see dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource
|
||||
*/
|
||||
suspend fun BehaviourContext.waitContentMessageWithTextMentions (
|
||||
userId: UserId,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitTextedContentMessage(initRequest, errorFactory).filterTextMentionsMessages(userId)
|
||||
|
||||
/**
|
||||
* Creates cold [Flow] with the messages with [TextedContent] where [user] has been mentioned as text or mentioned
|
||||
* with text
|
||||
*
|
||||
* @see filterMentions
|
||||
* @see filterTextMentions
|
||||
*/
|
||||
suspend fun BehaviourContext.waitContentMessageWithMentions (
|
||||
user: User,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitTextedContentMessage(initRequest, errorFactory).filterMentionsMessages(user)
|
||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceUser
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||
@@ -15,7 +16,9 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
* Allow only events from the same chat as base [Message]
|
||||
*/
|
||||
val MessageFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, Message, Update> = { message, update ->
|
||||
update.sourceChat() ?.id == message.chat.id
|
||||
update.sourceChat() ?.let {
|
||||
it.id == message.chat.id
|
||||
} != false
|
||||
}
|
||||
/**
|
||||
* Allow only events from the same chat as base [List] of [Message]
|
||||
@@ -29,31 +32,41 @@ val MessagesFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, List<Mess
|
||||
* Allow only updates from the same user as base [CallbackQuery.user]
|
||||
*/
|
||||
val CallbackQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, CallbackQuery, Update> = { query, update ->
|
||||
update.sourceChat() ?.id == query.user.id
|
||||
update.sourceUser() ?.let {
|
||||
it.id == query.user.id
|
||||
} != false
|
||||
}
|
||||
/**
|
||||
* Allow only updates from the same user as base [ShippingQuery.user]
|
||||
*/
|
||||
val ShippingQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, ShippingQuery, Update> = { query, update ->
|
||||
update.sourceChat() ?.id == query.user.id
|
||||
update.sourceUser() ?.let {
|
||||
it.id == query.user.id
|
||||
} != false
|
||||
}
|
||||
/**
|
||||
* Allow only updates from the same user as base [ShippingQuery.user]
|
||||
*/
|
||||
val PreCheckoutQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, PreCheckoutQuery, Update> = { query, update ->
|
||||
update.sourceChat() ?.id == query.user.id
|
||||
update.sourceUser() ?.let {
|
||||
it.id == query.user.id
|
||||
} != false
|
||||
}
|
||||
/**
|
||||
* Allow only updates from the same user as base [InlineQuery.from]
|
||||
*/
|
||||
val InlineQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, InlineQuery, Update> = { query, update ->
|
||||
update.sourceChat() ?.id == query.from.id
|
||||
update.sourceUser() ?.let {
|
||||
it.id == query.user.id
|
||||
} != false
|
||||
}
|
||||
/**
|
||||
* Allow only events from the same chat as base [ChatMemberUpdated]
|
||||
*/
|
||||
val ChatMemberUpdatedFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, ChatMemberUpdated, Update> = { updated, update ->
|
||||
update.sourceChat() ?.id == updated.chat.id
|
||||
update.sourceChat() ?.let {
|
||||
it.id == updated.chat.id
|
||||
} != false
|
||||
}
|
||||
/**
|
||||
* Allow only events from the same chat as base [ChatMemberUpdated]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ChatJoinRequestFilterByChat
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatJoinRequestMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
@@ -25,7 +24,7 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onChatJoinRequest(
|
||||
initialFilter: SimpleFilter<ChatJoinRequest>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatJoinRequest, Update>? = ChatJoinRequestFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatJoinRequest, Update>? = null,
|
||||
markerFactory: MarkerFactory<in ChatJoinRequest, Any> = ByChatChatJoinRequestMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatJoinRequest>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
|
||||
@@ -22,7 +22,7 @@ internal suspend fun <BC : BehaviourContext> BC.commandUncounted(
|
||||
commandRegex: Regex,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = onText(
|
||||
@@ -49,7 +49,7 @@ suspend fun <BC : BehaviourContext> BC.command(
|
||||
commandRegex: Regex,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = runCatchingSafely {
|
||||
@@ -78,7 +78,7 @@ suspend fun <BC : BehaviourContext> BC.command(
|
||||
command: String,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -87,7 +87,7 @@ suspend fun <BC : BehaviourContext> BC.command(
|
||||
botCommand: BotCommand,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
) = command(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -96,7 +96,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||
commandRegex: Regex,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -105,7 +105,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||
command: String,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -114,7 +114,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||
botCommand: BotCommand,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = onCommand(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -122,7 +122,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
commandRegex: Regex,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
) = command(
|
||||
@@ -142,7 +142,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
command: String,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
) = commandWithArgs(
|
||||
@@ -156,7 +156,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
botCommand: BotCommand,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
) = commandWithArgs(
|
||||
@@ -170,7 +170,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||
commandRegex: Regex,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -178,7 +178,7 @@ suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||
command: String,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -186,7 +186,7 @@ suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||
botCommand: BotCommand,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
): Job = onCommandWithArgs(botCommand.command, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -20,7 +20,7 @@ import kotlinx.coroutines.Job
|
||||
suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = onText(
|
||||
@@ -48,7 +48,7 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
||||
suspend fun <BC : BehaviourContext> BC.onUnhandledCommand(
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = unhandledCommand(requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
@@ -56,7 +56,7 @@ suspend fun <BC : BehaviourContext> BC.onUnhandledCommand(
|
||||
@PreviewFeature
|
||||
suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
||||
) = onUnhandledCommand(
|
||||
@@ -74,7 +74,7 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
||||
@PreviewFeature
|
||||
suspend fun <BC : BehaviourContext> BC.onUnhandledCommandWithArgs(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
||||
): Job = unhandledCommandWithArgs(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -46,7 +46,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent>
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onContentMessage(
|
||||
initialFilter: CommonMessageFilter<MessageContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MessageContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MessageContent>>
|
||||
) = onContentMessageWithType(
|
||||
@@ -70,7 +70,7 @@ suspend fun <BC : BehaviourContext> BC.onContentMessage(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onContact(
|
||||
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -94,7 +94,7 @@ suspend fun <BC : BehaviourContext> BC.onContact(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onDice(
|
||||
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -118,7 +118,7 @@ suspend fun <BC : BehaviourContext> BC.onDice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onGame(
|
||||
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -142,7 +142,7 @@ suspend fun <BC : BehaviourContext> BC.onGame(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onLocation(
|
||||
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -166,7 +166,7 @@ suspend fun <BC : BehaviourContext> BC.onLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
||||
initialFilter: CommonMessageFilter<LiveLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LiveLocationMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LiveLocationMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in LiveLocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LiveLocationMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -190,7 +190,7 @@ suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
||||
initialFilter: CommonMessageFilter<StaticLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StaticLocationMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StaticLocationMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in StaticLocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StaticLocationMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -214,7 +214,7 @@ suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onPoll(
|
||||
initialFilter: CommonMessageFilter<PollContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PollMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PollMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in PollMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PollMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -238,7 +238,7 @@ suspend fun <BC : BehaviourContext> BC.onPoll(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onText(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -248,6 +248,54 @@ suspend fun <BC : BehaviourContext> BC.onText(
|
||||
scenarioReceiver
|
||||
)
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onStory(
|
||||
initialFilter: CommonMessageFilter<StoryContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StoryMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in StoryMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StoryMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
)
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onTextedContent(
|
||||
initialFilter: CommonMessageFilter<TextedContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextedMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
)
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
@@ -262,7 +310,7 @@ suspend fun <BC : BehaviourContext> BC.onText(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVenue(
|
||||
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -286,7 +334,7 @@ suspend fun <BC : BehaviourContext> BC.onVenue(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
||||
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -310,7 +358,7 @@ suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
||||
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -334,7 +382,7 @@ suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
||||
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -358,7 +406,7 @@ suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
||||
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
||||
) = onContentMessageWithType(
|
||||
@@ -382,7 +430,7 @@ suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onMedia(
|
||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -406,7 +454,7 @@ suspend fun <BC : BehaviourContext> BC.onMedia(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onAnimation(
|
||||
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -430,7 +478,7 @@ suspend fun <BC : BehaviourContext> BC.onAnimation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onAudio(
|
||||
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -454,7 +502,7 @@ suspend fun <BC : BehaviourContext> BC.onAudio(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onDocument(
|
||||
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -478,7 +526,7 @@ suspend fun <BC : BehaviourContext> BC.onDocument(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onPhoto(
|
||||
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -502,7 +550,7 @@ suspend fun <BC : BehaviourContext> BC.onPhoto(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onSticker(
|
||||
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -526,7 +574,7 @@ suspend fun <BC : BehaviourContext> BC.onSticker(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVideo(
|
||||
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -550,7 +598,7 @@ suspend fun <BC : BehaviourContext> BC.onVideo(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
||||
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -574,7 +622,7 @@ suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVoice(
|
||||
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -598,7 +646,7 @@ suspend fun <BC : BehaviourContext> BC.onVoice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onInvoice(
|
||||
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
||||
) = onContentMessageWithType(
|
||||
@@ -607,3 +655,51 @@ suspend fun <BC : BehaviourContext> BC.onInvoice(
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
)
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVisualContent(
|
||||
initialFilter: CommonMessageFilter<VisualMediaGroupPartContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VisualMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VisualMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VisualMediaGroupMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
)
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onMediaContent(
|
||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ import kotlinx.coroutines.flow.filter
|
||||
private val startRegex = Regex("start")
|
||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update> = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update>? = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||
): Job = on(
|
||||
@@ -38,7 +38,7 @@ suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||
scenarioReceiver,
|
||||
) {
|
||||
(it.messageUpdateOrNull()) ?.data ?.commonMessageOrNull() ?.withContentOrNull<TextContent>() ?.let { message ->
|
||||
message to message.content.textSources[1].source.removePrefix(" ").decodeURLQueryComponent()
|
||||
message to (message.content.textSources.getOrNull(1) ?.source ?.removePrefix(" ") ?.decodeURLQueryComponent() ?: return@let null)
|
||||
} ?.let(::listOfNotNull)
|
||||
}.also {
|
||||
triggersHolder.handleableCommandsHolder.registerHandleable(startRegex)
|
||||
@@ -46,3 +46,24 @@ suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||
this@onDeepLink.launchSafelyWithoutExceptions { triggersHolder.handleableCommandsHolder.unregisterHandleable(startRegex) }
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||
regex: Regex,
|
||||
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update>? = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||
): Job {
|
||||
val internalFilter = SimpleFilter<Pair<TextMessage, String>> {
|
||||
regex.matches(it.second)
|
||||
}
|
||||
return onDeepLink(initialFilter ?.let { internalFilter * it } ?: internalFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
}
|
||||
|
||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||
deepLink: String,
|
||||
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update>? = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||
): Job = onDeepLink(Regex("^$deepLink$"), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/@file:Suppress("unused", "UNCHECKED_CAST")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
@@ -35,7 +20,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent>
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<T>>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
when (it) {
|
||||
is BaseEditMessageUpdate -> (it.editMessageUpdateOrNull() ?.data ?.withContent<T>())
|
||||
is BaseEditMessageUpdate -> (it.data.withContent<T>())
|
||||
else -> null
|
||||
} ?.let(::listOfNotNull)
|
||||
}
|
||||
@@ -55,7 +40,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent>
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedContentMessage(
|
||||
initialFilter: CommonMessageFilter<MessageContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MessageContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MessageContent>>
|
||||
)= onEditedContent(
|
||||
@@ -79,7 +64,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedContentMessage(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedContact(
|
||||
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
||||
)= onEditedContent(
|
||||
@@ -103,7 +88,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedContact(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedDice(
|
||||
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
||||
)= onEditedContent(
|
||||
@@ -127,7 +112,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedDice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedGame(
|
||||
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
||||
)= onEditedContent(
|
||||
@@ -151,7 +136,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedGame(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedLocation(
|
||||
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
||||
)= onEditedContent(
|
||||
@@ -175,7 +160,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedText(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
)= onEditedContent(
|
||||
@@ -199,7 +184,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedText(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVenue(
|
||||
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
||||
)= onEditedContent(
|
||||
@@ -223,7 +208,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVenue(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
|
||||
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
||||
)= onEditedContent(
|
||||
@@ -247,7 +232,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
|
||||
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
||||
)= onEditedContent(
|
||||
@@ -271,7 +256,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedTextedMediaContent(
|
||||
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
||||
)= onEditedContent(
|
||||
@@ -295,7 +280,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedTextedMediaContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedMediaCollection(
|
||||
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
||||
)= onEditedContent(
|
||||
@@ -319,7 +304,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedMediaCollection(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedMedia(
|
||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||
)= onEditedContent(
|
||||
@@ -343,7 +328,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedMedia(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedAnimation(
|
||||
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
||||
)= onEditedContent(
|
||||
@@ -367,7 +352,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedAnimation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedAudio(
|
||||
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
||||
)= onEditedContent(
|
||||
@@ -391,7 +376,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedAudio(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedDocument(
|
||||
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
||||
)= onEditedContent(
|
||||
@@ -415,7 +400,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedDocument(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedPhoto(
|
||||
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
||||
)= onEditedContent(
|
||||
@@ -439,7 +424,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedPhoto(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedSticker(
|
||||
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
||||
)= onEditedContent(
|
||||
@@ -463,7 +448,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedSticker(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVideo(
|
||||
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
||||
)= onEditedContent(
|
||||
@@ -487,7 +472,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVideo(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVideoNote(
|
||||
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
||||
)= onEditedContent(
|
||||
@@ -511,7 +496,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVideoNote(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVoice(
|
||||
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
||||
)= onEditedContent(
|
||||
@@ -535,7 +520,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVoice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedInvoice(
|
||||
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update> = MessageFilterByChat,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
||||
)= onEditedContent(
|
||||
|
||||
@@ -13,12 +13,19 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
|
||||
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.abstracts.SupergroupEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
||||
@@ -339,10 +346,10 @@ suspend fun <BC : BehaviourContext> BC.onGroupChatCreated(
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onLeftChatMember(
|
||||
initialFilter: SimpleFilter<ChatEventMessage<LeftChatMember>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<LeftChatMember>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<LeftChatMember>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<LeftChatMember>>
|
||||
initialFilter: SimpleFilter<ChatEventMessage<LeftChatMemberEvent>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<LeftChatMemberEvent>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<LeftChatMemberEvent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<LeftChatMemberEvent>>
|
||||
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
/**
|
||||
@@ -575,3 +582,143 @@ suspend fun <BC : BehaviourContext> BC.onForumTopicReopened(
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ForumTopicReopened>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<ForumTopicReopened>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onForumTopicEdited(
|
||||
initialFilter: SimpleFilter<SupergroupEventMessage<ForumTopicEdited>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<ForumTopicEdited>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ForumTopicEdited>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<ForumTopicEdited>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onGeneralForumTopicHidden(
|
||||
initialFilter: SimpleFilter<SupergroupEventMessage<GeneralForumTopicHidden>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<GeneralForumTopicHidden>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<GeneralForumTopicHidden>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<GeneralForumTopicHidden>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onGeneralForumTopicUnhidden(
|
||||
initialFilter: SimpleFilter<SupergroupEventMessage<GeneralForumTopicUnhidden>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<GeneralForumTopicUnhidden>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<GeneralForumTopicUnhidden>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<GeneralForumTopicUnhidden>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowed(
|
||||
initialFilter: SimpleFilter<SupergroupEventMessage<WriteAccessAllowed>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<WriteAccessAllowed>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<WriteAccessAllowed>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onChatSharedRequest(
|
||||
initialFilter: SimpleFilter<PrivateEventMessage<ChatSharedRequest>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<ChatSharedRequest>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChatSharedRequest>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<ChatSharedRequest>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onUserShared(
|
||||
initialFilter: SimpleFilter<PrivateEventMessage<UserShared>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<UserShared>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<UserShared>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<UserShared>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onChatShared(
|
||||
initialFilter: SimpleFilter<PrivateEventMessage<ChatShared>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<ChatShared>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChatShared>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<ChatShared>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -20,7 +20,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : InlineQuery> BC.
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* @param subcontextUpdatesFilter **Default is [InlineQueryFilterByUser]]**. This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
@@ -40,7 +40,7 @@ suspend fun <BC : BehaviourContext> BC.onAnyInlineQuery(
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* @param subcontextUpdatesFilter **Default is [InlineQueryFilterByUser]]**. This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
@@ -60,7 +60,7 @@ suspend fun <BC : BehaviourContext> BC.onBaseInlineQuery(
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* @param subcontextUpdatesFilter **Default is [InlineQueryFilterByUser]]**. This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user