mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-18 04:50:20 +00:00
Compare commits
364 Commits
0.30.1
...
gradle-wra
| Author | SHA1 | Date | |
|---|---|---|---|
| eaee334ff6 | |||
| 5c694e8625 | |||
| 0306c40fb2 | |||
| fd915553e3 | |||
| ec1c0ba8bb | |||
| 12a64ec1d1 | |||
| 59d7a7c781 | |||
| cabfd7c76b | |||
| f12f52899c | |||
|
|
ed067db20f | ||
| b055268979 | |||
| 2584839d66 | |||
| 63946e860d | |||
| 90df436c63 | |||
| d3c8b49b10 | |||
| c1372b55bc | |||
| b6c7ece995 | |||
| 44e7c80f43 | |||
| 1e41e95333 | |||
| 03d4d715c0 | |||
| ab060d02ea | |||
| f447be02dc | |||
| eb923a6338 | |||
| 0914710cc7 | |||
| 1f7450844f | |||
| 167c214e35 | |||
| 42a8d649cd | |||
| eb3f180cc6 | |||
| 70f96ac8fa | |||
| d69b2e09d5 | |||
| 946b0222df | |||
| 7da315dbaf | |||
| 87071ca52c | |||
| b2770e3ecc | |||
| df63ccfe07 | |||
| 694bec22a2 | |||
| 6a3588bb8d | |||
| a26568aa29 | |||
| cd30660256 | |||
| 1846d20b0d | |||
| f13207064e | |||
| 61be689aca | |||
| 03f8d65bb6 | |||
| 2dc8beba8a | |||
| 5451adf4ac | |||
| 9982534001 | |||
| c0451d4c8f | |||
| a9d65944e6 | |||
| 39598dcb69 | |||
| 3069a6084c | |||
| e7bbce3fa7 | |||
| 0b361163f2 | |||
| 6aba2ff641 | |||
| 6b761ab37d | |||
| b9c8a89af9 | |||
| a42c5c63c4 | |||
| fc1a029acb | |||
| f90ae2f918 | |||
| 019b260888 | |||
| 0831f2fa75 | |||
| 32ae9d2b16 | |||
| b975a1b036 | |||
| f4b1e4a150 | |||
| 97031512d4 | |||
| 353df43109 | |||
| 4e55460834 | |||
| e2e235bd6c | |||
| 8ced95bc2f | |||
| 685e4af8f5 | |||
| 0b2f7a3899 | |||
| 112c86c9da | |||
| 1ddd138ff7 | |||
| 1a5d1cde78 | |||
| 5b620014cb | |||
| 80093cb5a9 | |||
| 9f8e8ee21b | |||
| 3de3bb6133 | |||
| 308fb9274b | |||
| d14ca7bbdc | |||
| dbdd9b5ad2 | |||
| 6dd27cb0bf | |||
| 210a52485b | |||
| 5c11b60ea6 | |||
| 60c3a0d7af | |||
| 8d777e1c0e | |||
| 4e019eb8bb | |||
| bd80562c2a | |||
| 9fc07f2ff3 | |||
| a4bae5133a | |||
| 7bb272f2fa | |||
| 72cf38d3bb | |||
| 0adee13cba | |||
| f9e3e57f24 | |||
| d7d4adc8e4 | |||
| e9b074a36c | |||
| 65cba0f014 | |||
| 36202133a1 | |||
| 66f7801b32 | |||
| e7265829d1 | |||
| 9ad5bfbc57 | |||
| aba62ba930 | |||
| 40d702a311 | |||
| 233d893b5a | |||
| 0faca5838c | |||
| 838f62aa84 | |||
| bc21a680bc | |||
| 8bb60bea34 | |||
| 8daadcff95 | |||
| 2a1e624641 | |||
| 696822db02 | |||
| ded501d963 | |||
| 86e506c33d | |||
| 9902b00e85 | |||
| 53524abcbb | |||
| 7639b15dc6 | |||
| 61b720c61f | |||
| baf4c74b69 | |||
| 367cfff2cb | |||
| 75e8d0f62d | |||
| c521a5f9a4 | |||
| c5513365c2 | |||
| d184ce7a0f | |||
| a3bff3f24d | |||
| a835b1dcbb | |||
| ffed2b80a5 | |||
| ff24b9f35b | |||
| 1287852334 | |||
| fc2f177e38 | |||
| 1efd4dce6e | |||
| 69b5a16b17 | |||
| 77b531ad06 | |||
| a98d5d9abd | |||
| 104653ac41 | |||
| 63337b8285 | |||
| 5cc0bbb31b | |||
| 563d784603 | |||
| 0d9f18f346 | |||
| 23ceaf8e97 | |||
| fe2dffd8b5 | |||
| eeb46817c3 | |||
| 5ab00da31d | |||
| 841ae73f7c | |||
| 41b4d29917 | |||
| f8b3c44146 | |||
| f0eb670c3f | |||
| fe5d94f31e | |||
| 7901d0a223 | |||
| 799f9123ba | |||
| f77f010e66 | |||
| 67ddf8d809 | |||
| 81afa46253 | |||
| a5bba76f07 | |||
| d882cf9c97 | |||
| 2e27b8b64d | |||
| 4df800eaa9 | |||
| 8d27349868 | |||
| 2a89c41a58 | |||
| 098b5cc393 | |||
| 10f4817283 | |||
| 4449893608 | |||
| 3a53f41f66 | |||
| 7cd366d893 | |||
| 1309a4111c | |||
| 0ca815760b | |||
| eca0680f2f | |||
| d472d371ed | |||
| 4748b6813a | |||
| a2ea15d4b0 | |||
| 27dc302f5d | |||
| baf8ed3a77 | |||
| 18913af3c3 | |||
| 51871ea94c | |||
| 6a625d7b9f | |||
| 0b93b472a3 | |||
| ff16f9a315 | |||
| 86bfe043a5 | |||
| fa18e7299d | |||
| c986025075 | |||
| e8a7ea9ce4 | |||
| 30f35e5488 | |||
| b626974ea7 | |||
| 128b782a27 | |||
| dc83b8d77a | |||
| 2aac6c0bde | |||
| b637d0d2a6 | |||
| d12cba2343 | |||
| 450c7e6474 | |||
| a35fb40a66 | |||
| 8731aa2c26 | |||
| 32e305537d | |||
| ec0a10e36e | |||
| 131ec4d6d5 | |||
| ecc608f51a | |||
| 040654f131 | |||
| 9e73d0c461 | |||
| d67c80bc99 | |||
| b0eef4f82d | |||
| fbe91a6321 | |||
| 15066c9d63 | |||
| e0bf67d8f9 | |||
| 1dc3ce2fb5 | |||
| 0c71133969 | |||
| 1359dd549f | |||
| c425e2ecc3 | |||
| 4d63e3a17d | |||
| d34deade0d | |||
| 2f52ad45a4 | |||
| 1d99e632a4 | |||
| cdcfaf5a29 | |||
| f3590762f3 | |||
| e0ff14b7fe | |||
| 9983e111ec | |||
| 08b8710772 | |||
| fc71e028c4 | |||
| 30a4a7bd8b | |||
| b973278b0a | |||
| ae2f4579e2 | |||
| a4bf6911c7 | |||
| 73b3daa68b | |||
| 09748615ae | |||
| 2dc8521aed | |||
| 81de59f37c | |||
| fb61a94c5e | |||
| 26fd5e51bf | |||
| c1ab9da4c4 | |||
| 6b414d64b0 | |||
| 5a3edc2b44 | |||
| 6dcdc2ab7f | |||
| a2ae4f71de | |||
| 5d87b86afe | |||
| ef22735894 | |||
| c0ea479fe3 | |||
| 0846e816e9 | |||
| d837c9d605 | |||
| d1993842c3 | |||
| 4e8a9dcff0 | |||
| 10eb15e172 | |||
| 0320da7614 | |||
| 7aa3ff180e | |||
| a882a212c2 | |||
| 1b15748f65 | |||
| 044fe5eadf | |||
| 9453ec37e7 | |||
| 3d0cbc2d2b | |||
| 198b551ebf | |||
| 1452e32293 | |||
| 946b7abcae | |||
| 879943622a | |||
| c0b4b523cf | |||
| 49e6e9cfe3 | |||
| ffadb6355b | |||
| 9cc402b42d | |||
| b9341f89ac | |||
| ac07f44c81 | |||
| 2e53247726 | |||
| e2dddf96a1 | |||
| ce0fceb240 | |||
| 633239961a | |||
| 8b79b15777 | |||
| a28cf5ddff | |||
| 8c2cffc8e3 | |||
| b933361258 | |||
| 383e722d07 | |||
| 3125c2fc1b | |||
| 965b8c3c50 | |||
| 94745ef373 | |||
| aee5ab564b | |||
| c70f0b65dd | |||
| 30e6f68228 | |||
| 00873a255c | |||
| 6bd423dc11 | |||
| c5ada8cea0 | |||
| 0cb3df4d1a | |||
| b22118b400 | |||
| 2006e45b57 | |||
| c091098feb | |||
| 6cf8d47cbf | |||
| 3dc4e9dda4 | |||
| 6407ad1a93 | |||
| f974e5787f | |||
| 28a9bbd310 | |||
| 599d5a51e3 | |||
| 25f8d15a4b | |||
| 66c2cb2d30 | |||
| 74fb448378 | |||
| 3417ec060f | |||
| 4f54a00003 | |||
| 4fb187da30 | |||
| 7637b6f69a | |||
| 9df9af193c | |||
| ba4b4c4b64 | |||
| fa0861b8bc | |||
| 20494e1d4a | |||
| a404008dee | |||
| 881205dd80 | |||
| 2096c44811 | |||
| 1a3da33589 | |||
| be28c9bd5d | |||
| a193ef5fd5 | |||
| 7c43d3aaa5 | |||
| e034afc75c | |||
| 08e3326d1a | |||
| 6dd1825b98 | |||
| bd4eb29fc1 | |||
| 2cc66ef13c | |||
| 9a8175d1c8 | |||
| 25285b2e8a | |||
| bb09f05d7b | |||
| da5e46e59f | |||
| a3f315a73a | |||
| 43583a885a | |||
| ec02257ecd | |||
| 29ee4a9396 | |||
| 2717cb4fc6 | |||
| 1ce2526401 | |||
| 74c480b07e | |||
| 657e9aa770 | |||
| 0d19952ba7 | |||
| f8cccc3e17 | |||
| bc1b7c3f25 | |||
| ec74111a9d | |||
| 2dadeb7eb7 | |||
| 24bd65501b | |||
| 574ca803fa | |||
| 947e3bf34e | |||
| 488158d8fb | |||
| 41bf3c7f0b | |||
| c2032d21cd | |||
| 6650dd9cfe | |||
| af1d6d6f1a | |||
| a5861d659d | |||
| b36f80a6d3 | |||
| 7c4f034a6c | |||
| 3b08bc6dd2 | |||
| ed87c0ad95 | |||
| c8c0fc2ce8 | |||
| 1f40ce1a81 | |||
| b0219389fc | |||
| f6ec82b449 | |||
| 71dac70635 | |||
| 98f68a9e1e | |||
| e7199e7451 | |||
| 33b50c6c68 | |||
| e4ce6f8fc7 | |||
| 8764f18ca8 | |||
| b2fa7fee9d | |||
| 0121e3a104 | |||
| f6e5664632 | |||
| c5b7c4e1f5 | |||
| 53800d49bf | |||
| d83e3eb10a | |||
| 66b4d06064 | |||
| 4fab01b2a2 | |||
| b81086c4bb | |||
| d776071cac | |||
| 5f33d05deb | |||
| 912cc7217c | |||
| 96e00f6e31 | |||
| f8ea5f9515 | |||
| 9f11c4f1c4 | |||
| 9c91980d5d | |||
| 7376eb5b10 | |||
| 6654f27f9d | |||
| 83edda2dfe |
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "gradle" # See documentation for possible values
|
||||||
|
directory: "/tgbotapi.core" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
21
.github/workflows/kdocs.yml
vendored
Normal file
21
.github/workflows/kdocs.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: Publish KDocs
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
jobs:
|
||||||
|
publishing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
- name: Build
|
||||||
|
run: ./gradlew dokkaHtml
|
||||||
|
- name: Publish KDocs
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./docs/build/dokka/html
|
||||||
|
publish_branch: kdocs
|
||||||
23
.github/workflows/packages_publishing.yml
vendored
Normal file
23
.github/workflows/packages_publishing.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Publish package to GitHub Packages
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
publishing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
- 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: Build
|
||||||
|
run: ./gradlew build
|
||||||
|
- name: Publish
|
||||||
|
run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication -x signMetadataPublication
|
||||||
|
env:
|
||||||
|
GITHUBPACKAGES_USER: ${{ github.actor }}
|
||||||
|
GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||||
433
CHANGELOG.md
433
CHANGELOG.md
@@ -1,5 +1,438 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 0.34.1
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `ktor`: `1.5.3` -> `1.5.4`
|
||||||
|
* `MicroUtils`: `0.4.35` -> `0.4.36`
|
||||||
|
* `Core`
|
||||||
|
* Fix in creating of text sources list
|
||||||
|
|
||||||
|
## 0.34.0
|
||||||
|
|
||||||
|
_**It is recommended to use [0.34.1](https://github.com/InsanusMokrassar/TelegramBotAPI/releases/tag/0.34.1) version due to the bug in 0.34.0 related to rewriting of `TextSource`s creating mechanism.**_
|
||||||
|
|
||||||
|
**UPDATE UP TO Telegram Bot API 5.2**
|
||||||
|
|
||||||
|
_**ALL OLD DEPRECATIONS WERE REMOVED**_
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Type `ChatType` has been added
|
||||||
|
* New `ExtendedChat` for unknown messages `UnknownExtendedChat` has been added
|
||||||
|
* `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor
|
||||||
|
* New interface `CommonSendInvoiceData` has been added
|
||||||
|
* Fields `CommonSendInvoiceData#maxTipAmount` and `CommonSendInvoiceData#suggestedTipAmounts` have been added
|
||||||
|
* New type `InputInvoiceMessageContent` has been added
|
||||||
|
* New interface `TextedWithTextSources` on top of `Texted` interface
|
||||||
|
* Interface `TextedInput` now extends `TextedWithTextSources` with overriding of `textSources` field as not
|
||||||
|
nullable
|
||||||
|
* `textSources` become main field in `TextedInput`
|
||||||
|
* **MIGRATION** Remove all `import dev.inmo.tgbotapi.CommonAbstracts.textSources` in your project
|
||||||
|
* `textEntities` become are calculable property in `TextedInput`
|
||||||
|
* Interface `Captioned` and `CaptionedInput` now is deprecated
|
||||||
|
* Most of captions usages were replaced with texts
|
||||||
|
* Interface `Explained` and `ExplainedInput` now is deprecated
|
||||||
|
* Most of captions usages were replaced with texts
|
||||||
|
* Interface `VoiceChatEvent` now is `CommonEvent`
|
||||||
|
* Mechanism of `RawMessageEntity` converting were fully rewritten
|
||||||
|
|
||||||
|
## 0.33.4
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `uuid`: `0.2.3` -> `0.2.4`
|
||||||
|
* `MicroUtils`: `0.4.33` -> `0.4.35`
|
||||||
|
* `Core`:
|
||||||
|
* All `TextSource` implementators have become `Serializable`
|
||||||
|
* New serializer `TextSourceSerializer`
|
||||||
|
* Interface`FromUserMessage` now extends `Message`
|
||||||
|
* New interface `FromUser`
|
||||||
|
* Interface `FromUserMessage` now extends `FromUser`
|
||||||
|
* `Extensions Utils`
|
||||||
|
* Fixes in `parseCommandsWithParams`
|
||||||
|
|
||||||
|
## 0.33.3
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.32` -> `0.4.33`
|
||||||
|
* `Ktor`: `1.5.2` -> `1.5.3`
|
||||||
|
* `API`:
|
||||||
|
* Bot actions DSL (fix for [#358](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/358))
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Rewrite logic of `doInSubContextWithUpdatesFilter` and `doInSubContextWithFlowsUpdatesFilterSetup` extensions
|
||||||
|
* All triggers now work with `stopOnCompletion` set up to `false`
|
||||||
|
|
||||||
|
## 0.33.2
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.30` -> `0.4.32`
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* New typealias `MediaGroupFilter` has been added for `MediaGroup` expectators
|
||||||
|
* Several typealiases became `suspend`:
|
||||||
|
* `CallbackQueryMapper`
|
||||||
|
* `ChatMemberUpdatedMapper`
|
||||||
|
* `InlineQueryMapper`
|
||||||
|
* Commands got an additional parameter - `additionalFilter`. It will be called when all command filters were passed
|
||||||
|
|
||||||
|
## 0.33.1
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.4.31` -> `1.4.32`
|
||||||
|
* `MicroUtils`: `0.4.29` -> `0.4.30`
|
||||||
|
* `Klocks`: `2.0.6` -> `2.0.7`
|
||||||
|
* `Utils Extensions`:
|
||||||
|
* Add extensions `parseCommandsWithParams`
|
||||||
|
|
||||||
|
## 0.33.0
|
||||||
|
|
||||||
|
**UPDATE UP TO Telegram Bot API 5.1**
|
||||||
|
_**ALL DEPRECATIONS WERE REMOVED**_
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.28` -> `0.4.29`
|
||||||
|
* `Core`:
|
||||||
|
* `AdministratorChatMemberSerializer` and `ChatMemberSerializer` has changed their visibility: they are public for now
|
||||||
|
* Add `ChatInviteLinkRequest` with subrequests like `KnownChatInviteLinkRequest`
|
||||||
|
* Add `CreateChatInviteLink`/`EditChatInviteLink`/`RevokeChatInviteLink` requests
|
||||||
|
* Update `KickChatMember` to include `revokeMessages` flag
|
||||||
|
* Update `PromoteChatMember` to include `canManageVoiceChats` and `canManageChat` flags
|
||||||
|
* Add `ChatInviteLink` object
|
||||||
|
* Add `PrimaryInviteLink` for `ChatInviteLink` with `isPrimary == true`
|
||||||
|
* Add `CommonInviteLink` for `ChatInviteLink` with `isPrimary == false`
|
||||||
|
* `AdministratorChatMemberSerializer` has been set as public for several versions
|
||||||
|
* `ChatMemberSerializer` has been set as public for several versions
|
||||||
|
* Add `ChatMemberUpdated`
|
||||||
|
* Add `MessageAutoDeleteTimerChanged`
|
||||||
|
* Add `VoiceChatEvent`
|
||||||
|
* Add `VoiceChatEnded`
|
||||||
|
* Add `VoiceChatParticipantsInvited`
|
||||||
|
* Add `VoiceChatStarted`
|
||||||
|
* Add `ChatMemberUpdatedUpdate`
|
||||||
|
* Add `CommonChatMemberUpdatedUpdate`
|
||||||
|
* Add `MyChatMemberUpdatedUpdate`
|
||||||
|
* `API`:
|
||||||
|
* All API extensions has been updated
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Now content triggers and expectators will wait for channel posts too
|
||||||
|
* New waiters and triggers for `ChatMemberUpdated` and its variations
|
||||||
|
|
||||||
|
## 0.32.9
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.4.30` -> `1.4.31`
|
||||||
|
* `Ktor`: `1.5.1` -> `1.5.2`
|
||||||
|
* `MicroUtils`: `0.4.26` -> `0.4.28`
|
||||||
|
* `Coroutines`: `1.4.2` -> `1.4.3`
|
||||||
|
|
||||||
|
## 0.32.8
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `Serialization`: `1.1.0-RC` -> `1.1.0`
|
||||||
|
* `MicroUtils`: `0.4.25` -> `0.4.26`
|
||||||
|
|
||||||
|
## 0.32.7
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* New variable `LeftRestrictionsChatPermissions` and `RestrictionsChatPermissions`
|
||||||
|
* `Extensions Utils`:
|
||||||
|
* `DiceAnimationType` class casts
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Now `doInSubContextWithUpdatesFilter` and `doInSubContext` will automatically subscribe on updates of parent
|
||||||
|
`BehaviourContext`
|
||||||
|
* `doInSubContextWithFlowsUpdatesFilterSetup`, `doInSubContextWithUpdatesFilter` and `doInSubContext` got new
|
||||||
|
parameter `stopOnCompletion` to be able to disable stopping of behaviour context on finishing
|
||||||
|
|
||||||
|
## 0.32.6
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.24` -> `0.4.25`
|
||||||
|
* `Extensions API`:
|
||||||
|
* New extension `TelegramBot#replyWithDice`
|
||||||
|
* `Extensions Utils`:
|
||||||
|
* `SlotMachineReelImages` has been renamed to `SlotMachineReelImage`
|
||||||
|
* `SlotMachineReelImage` got two built-in parameters: `text` and `number`
|
||||||
|
* New extension `String#asSlotMachineReelImage`
|
||||||
|
|
||||||
|
## 0.32.5
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Add `mention` variants for user ids and receiver variants ([#294](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/294))
|
||||||
|
* Now `AbstractRequestCallFactory` will set up one-second delay for zero timeouts in `GetUpdate` requests
|
||||||
|
* Several extensions for `TelegramBotAPI` like `retrieveAccumulatedUpdates` have been added as a solution for
|
||||||
|
[#293](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/293)
|
||||||
|
* Links for `tg://user?id=<user_id>` have been updated ([#292](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/292))
|
||||||
|
* All usages of captions or texts in resends and same things have been replaced with `textSources`
|
||||||
|
* Global `defaultParseMode` has been added ([#291](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/291))
|
||||||
|
|
||||||
|
## 0.32.4
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.4.21` -> `1.4.30`
|
||||||
|
* `Klock`: `2.0.4` -> `2.0.6`
|
||||||
|
* `MicroUtils`: `0.4.23` -> `0.4.24`
|
||||||
|
* `Core`:
|
||||||
|
* Renames:
|
||||||
|
* `ChannelMessage` -> `ChannelContentMessage`
|
||||||
|
* `PublicMessage` -> `PublicContentMessage`
|
||||||
|
* `GroupMessage` -> `GroupContentMessage`
|
||||||
|
* `FromChannelGroupMessage` -> `FromChannelGroupContentMessage`
|
||||||
|
* `AnonymousGroupMessage` -> `AnonymousGroupContentMessage`
|
||||||
|
* `CommonGroupMessage` -> `CommonGroupContentMessage`
|
||||||
|
* `PrivateMessage` -> `PrivateContentMessage`
|
||||||
|
* `Extensions Utils`:
|
||||||
|
* Renames of extensions in `ClassCasts` according to changes in `Core`
|
||||||
|
|
||||||
|
## 0.32.3
|
||||||
|
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Add expectators and waiters for inline queries
|
||||||
|
|
||||||
|
## 0.32.2
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Fix of [#275](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/275)
|
||||||
|
|
||||||
|
## 0.32.1
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Fix of [#272](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/272)
|
||||||
|
* `Utils`:
|
||||||
|
* Fix of [#273](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/273)
|
||||||
|
|
||||||
|
## 0.32.0
|
||||||
|
|
||||||
|
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.16` -> `0.4.23`
|
||||||
|
* `Klock`: `0.2.3` -> `0.2.4`
|
||||||
|
* `Ktor`: `1.5.0` -> `1.5.1`
|
||||||
|
* `Core`:
|
||||||
|
* **BREAKING CHANGE** Now `MediaGroupMessage` have a generic type related to `MediaGroupContent`
|
||||||
|
* Methods and types related to `MediaGroupMessage` have been modified according to their meanings
|
||||||
|
* **Important Change** `FlowsUpdatesFilter` now is an interface. Old class has been renamed to
|
||||||
|
`DefaultFlowsUpdatesFilter` and factory method `FlowsUpdatesFilter` has been added
|
||||||
|
* **PASSPORT** Full support of `Telegram Passport API`
|
||||||
|
* `PassportData`
|
||||||
|
* All variants of `EncryptedPassportElement`
|
||||||
|
* All variants of `SecureValue`
|
||||||
|
* All variants of `PassportElementError`
|
||||||
|
* New request `SetPassportDataErrors`
|
||||||
|
* `Credentials`:
|
||||||
|
* `EncryptedCredentials`
|
||||||
|
* `DeryptedCredentials`
|
||||||
|
* `EndDataCredentials`
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Trigger and expectation extensions for `MessageContent` (`onContentMessage` and `waitContentMessage`)
|
||||||
|
* `onMediaGroup` has been replaced
|
||||||
|
* `waitMediaGroup` has been added
|
||||||
|
* `onVisualMediaGroup` now is just an alternative to `onVisualGallery`
|
||||||
|
* `command` and `onCommand` expectations has been added for commands `String` variant
|
||||||
|
* New extensions `BehaviourContext#oneOf`, `BehaviourContext#parallel` and `Deferred<T>#withAction`
|
||||||
|
* Several renames:
|
||||||
|
* `waitAudioMediaGroup` -> `waitAudioMediaGroupContent`
|
||||||
|
* `waitDocumentMediaGroup` -> `waitDocumentMediaGroupContent`
|
||||||
|
* `waitMediaGroup` -> `waitAnyMediaGroupContent`
|
||||||
|
* `waitVisualMediaGroup` -> `waitVisualMediaGroupContent`
|
||||||
|
* New extensions `BehaviourContext#waitPassportMessagesWith` and `BehaviourContext#waitAnyPassportMessages`
|
||||||
|
* New extensions `BehaviourContext#onPassportMessage` and `BehaviourContext#onPassportMessageWith`
|
||||||
|
* `Utils`:
|
||||||
|
* New `ClassCasts` for
|
||||||
|
* `Message`
|
||||||
|
* **PASSPORT** `EncryptedPassportElement`
|
||||||
|
* **PASSPORT** `PassportElementError`
|
||||||
|
* **PASSPORT** `SecureValue`
|
||||||
|
* Several tools for decryption have been added:
|
||||||
|
* `AESDecryptor` is available for `JVM` platform
|
||||||
|
* Extensions `EncryptedCredentials#decryptWithPKCS8PrivateKey` are available for `JVM`
|
||||||
|
platform
|
||||||
|
* Extensions `EndDataCredentials#decryptData` and `FileCredentials#decryptFile` have been added
|
||||||
|
* Several extensions `createDecryptor`
|
||||||
|
* Several extensions `doInDecryptionContextWithPKCS8Key`
|
||||||
|
* New extension `Flow#passportMessages`
|
||||||
|
* In most of webhook setting up functions/methods now available parameter `mediaGroupsDebounceTimeMillis`
|
||||||
|
* `API`:
|
||||||
|
* **PASSPORT** New extensions `TelegramBot#setPassportDataErrors`
|
||||||
|
|
||||||
|
## 0.31.0
|
||||||
|
|
||||||
|
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* **ALL DEPRECATIONS CREATED SINCE 0.30.0 WERE REMOVED**
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Extension `TelegramBot#buildBehaviour` have changed its return value: now it is `Job` instead of
|
||||||
|
`FlowsUpdatesFilter`
|
||||||
|
* `Utils`
|
||||||
|
* New extensions `TelegramBot#longPolling` were added as new recommended way to start getting updates via long
|
||||||
|
polling
|
||||||
|
* Old extensions `RequestsExecutor#startGettingFlowsUpdatesByLongPolling` has been deprecated
|
||||||
|
|
||||||
|
## 0.30.13
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.15` -> `0.4.16`
|
||||||
|
* `Core`:
|
||||||
|
* New variable `FlowsUpdatesFilter#allUpdatesWithoutMediaGroupsGroupingFlow` which will contains updates without
|
||||||
|
`SentMediaGroupUpdate`
|
||||||
|
* `Utils`:
|
||||||
|
* Extensions for `ResendableContent` has been added
|
||||||
|
* Extensions for `TextSource` has been added
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Project has been created :)
|
||||||
|
|
||||||
|
## 0.30.12
|
||||||
|
|
||||||
|
* `Utils`:
|
||||||
|
* Class casts has been added. Now you can write something like `message.asGroupMessage() ?.let { ... }` instead of
|
||||||
|
`(message as? GroupMessage<*>) ?.let { ... }`
|
||||||
|
|
||||||
|
## 0.30.11
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.11` -> `0.4.15`
|
||||||
|
* `Klock`: `2.0.1` -> `2.0.3`
|
||||||
|
* `Ktor`: `1.4.3` -> `1.5.0`
|
||||||
|
* `Core`:
|
||||||
|
* All bot actions got functions for short calling, like `recordVideo` for `RecordVideoNote`
|
||||||
|
* All bot actions got class-cast shortcuts
|
||||||
|
|
||||||
|
## 0.30.10
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.4.20` -> `1.4.21`
|
||||||
|
* `Klock`: `2.0.0` -> `2.0.1`
|
||||||
|
* `Ktor`: `1.4.2` -> `1.4.3`
|
||||||
|
* `MicroUtils`: `0.4.6` -> `0.4.11`
|
||||||
|
* `API Extensions`:
|
||||||
|
* New function `buildBot`
|
||||||
|
|
||||||
|
## 0.30.9
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `UUID`: `0.2.2` -> `0.2.3`
|
||||||
|
* `Coroutines`: `1.4.1` -> `1.4.2`
|
||||||
|
* `MicroUtils`: `0.4.3` -> `0.4.6`
|
||||||
|
* `Core`:
|
||||||
|
* Add `BowlingDiceAnimationType`
|
||||||
|
|
||||||
|
## 0.30.8
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.4.10` -> `1.4.20`
|
||||||
|
* `Klock`: `1.12.1` -> `2.0.0`
|
||||||
|
* `MicroUtils`: `0.4.1` -> `0.4.3`
|
||||||
|
|
||||||
|
## 0.30.7
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.4.0` -> `0.4.1`
|
||||||
|
* `Core`:
|
||||||
|
* `TelegramAPIUrlsKeeper` will fix ending of host url since this version
|
||||||
|
* New mechanisms in`PowLimiter` and `CommonLimiter` has been added
|
||||||
|
* New builder `KtorRequestsExecutorBuilder`
|
||||||
|
* New function `telegramBot`
|
||||||
|
* `Utils`:
|
||||||
|
* Simple function `telegramBot(TelegramAPIUrlsKeeper)` has been deprecated with replacement by almost the same
|
||||||
|
function in `Core`
|
||||||
|
|
||||||
|
## 0.30.6
|
||||||
|
|
||||||
|
* `Core`
|
||||||
|
* `TextSource` properties has been renamed:
|
||||||
|
* `asMarkdownSource` -> `markdown`
|
||||||
|
* `asMarkdownV2Source` -> `markdownV2`
|
||||||
|
* `asHtmlSource` -> `html`
|
||||||
|
* `PrivateChat` override `id` property with type `UserId`
|
||||||
|
* Several new extensions and functions in links creation:
|
||||||
|
* New function `makeUsernameLink` with parameter `String`
|
||||||
|
* New extension `Username#link` and function `makeLink(Username)`
|
||||||
|
* Function `makeLinkToMessage` now able to get any type of chat
|
||||||
|
* New extension `Message#link`
|
||||||
|
* Old functions `makeLinkToAddStickerSet...` has been deprecated:
|
||||||
|
* `makeLinkToAddStickerSet`
|
||||||
|
* `makeLinkToAddStickerSetInMarkdownV2`
|
||||||
|
* `makeLinkToAddStickerSetInMarkdown`
|
||||||
|
* `makeLinkToAddStickerSetInHtml`
|
||||||
|
|
||||||
|
## 0.30.5
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.3.3` -> `0.4.0`
|
||||||
|
* `Core`:
|
||||||
|
* Mechanism of `ChatMember` serialization has been changed
|
||||||
|
* Since this version any `ChatMember` can be serialized (even outside in case it marked by `@Serializable`)
|
||||||
|
* Since this version any `ChatMember` (included in this project) can be deserialized in common way
|
||||||
|
* `User` property `id` has changed its type: now it is `UserId` (under the hood it is the same as `ChatId`)
|
||||||
|
|
||||||
|
## 0.30.4
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.3.1` -> `0.3.3`
|
||||||
|
* `Core`:
|
||||||
|
* `MultilevelTextSource#textSources` has been safely renamed to `subsources`
|
||||||
|
* `TextContent#fullEntitiesList` has been deprecated
|
||||||
|
* Now `TextContent` implements `TextedInput`
|
||||||
|
* `TextContent#entities` has been deprecated
|
||||||
|
* `GroupEventMessage` now overrides `chatEvent` with type `GroupEvent`
|
||||||
|
* `SupergroupEventMessage` now overrides `chatEvent` with type `SupergroupEvent`
|
||||||
|
* Any `ChatEventMessage` now have generic type of its `chatEvent` (just like messages)
|
||||||
|
* `Utils`:
|
||||||
|
* Old extensions related to chat events are deprecated:
|
||||||
|
* `Flow<ChatEventMessage<*>>#divideBySource`
|
||||||
|
* `Flow<ChatEventMessage<*>>#onlyChannelEvents`
|
||||||
|
* `Flow<ChatEventMessage<*>>#onlyGroupEvents`
|
||||||
|
* `Flow<ChatEventMessage<*>>#onlySupergroupEvents`
|
||||||
|
* A lot of extensions for `Flow<ChatEventMessage>` has been added:
|
||||||
|
* `FlowsUpdatesFilter#events`
|
||||||
|
* `FlowsUpdatesFilter#channelEvents`
|
||||||
|
* `FlowsUpdatesFilter#groupEvents`
|
||||||
|
* `FlowsUpdatesFilter#supergroupEvents`
|
||||||
|
* And a lot of other filters with specific types
|
||||||
|
|
||||||
|
## 0.30.3
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.3.0` -> `0.3.1`
|
||||||
|
* `Core`:
|
||||||
|
* New type of requests exceptions `TooMuchRequestsException`. In fact it will be rare case when you will get this
|
||||||
|
exception
|
||||||
|
* `EmptyLimiter` has been renamed to `ExceptionsOnlyLimiter` and currently will stop requests after
|
||||||
|
`TooMuchRequestsException` happen until retry time is actual
|
||||||
|
* Now `ExceptionsOnlyLimiter` (previously `EmptyLimiter`) is a class
|
||||||
|
* `AbstractRequestCallFactory` currently will not look at the response and wait if it have `RetryAfter` error. New
|
||||||
|
behaviour aimed on delegating of this work to `RequestsLimiter`
|
||||||
|
|
||||||
|
## 0.30.2
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `Ktor`: `1.4.1` -> `1.4.2`
|
||||||
|
* `Core`:
|
||||||
|
* New sealed class `SetWebhookRequest` which can be used in `SetWebhook` requests
|
||||||
|
* `Utils`:
|
||||||
|
* Extensions `setWebhookInfoAndStartListenWebhooks` has been united in one extension with `SetWebhookRequest`
|
||||||
|
incoming parameter
|
||||||
|
|
||||||
## 0.30.1
|
## 0.30.1
|
||||||
|
|
||||||
* `Common`:
|
* `Common`:
|
||||||
|
|||||||
211
README.md
211
README.md
@@ -1,137 +1,118 @@
|
|||||||
|
[Participate in our common survey ☺](https://forms.gle/q6Xf8K3fD1pPsYUw9)
|
||||||
|
|
||||||
# TelegramBotAPI
|
# TelegramBotAPI
|
||||||
|
|
||||||
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)|
|
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||||
|
|
||||||
|
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)|
|
||||||
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| Useful links | [](https://t.me/InMoTelegramBotAPI) [](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| Useful links | [](https://t.me/InMoTelegramBotAPI) [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
| TelegramBotAPI Core status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) |
|
| TelegramBotAPI Core status | [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) |
|
||||||
| TelegramBotAPI Extensions status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) |
|
| TelegramBotAPI API Extensions status | [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) |
|
||||||
| TelegramBotAPI Util Extensions status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.utils/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) |
|
| TelegramBotAPI Util Extensions status | [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) |
|
||||||
| TelegramBotAPI All status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) |
|
| TelegramBotAPI Behaviour Builder Extensions status | [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder) |
|
||||||
|
| TelegramBotAPI All status | [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) |
|
||||||
|
|
||||||
**At the time of publication of version `0.28.0` there are errors in serialization plugins like
|
## Examples
|
||||||
[kotlinx.serialization#1004](https://github.com/Kotlin/kotlinx.serialization/issues/1004). It is possible, that both JVM
|
|
||||||
and JS version may work improperly in some cases with `kotlinx.serialization` version `1.0.0-RC`**
|
|
||||||
|
|
||||||
|
There are several things you need to do to launch examples below:
|
||||||
|
|
||||||
It is a complex of libraries for working with `TelegramBotAPI` in type-safe and strict way as much as it possible. In
|
* Add `mavenCentral()` to your project repositories
|
||||||
the list of this complex currently next projects:
|
* [Maven variant](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#pomxml)
|
||||||
|
* Add dependency `implementation "dev.inmo:tgbotapi:$tgbotapi_version"`
|
||||||
|
* Replace `tgbotapi_version` with exact version (see last one in the table above) or put variable with this name in project
|
||||||
|
* Alternative variant for maven [here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#telegrambotapi)
|
||||||
|
|
||||||
* [TelegramBotAPI Core](tgbotapi.core/README.md) - core of library. In fact it is independent library and can be used alone
|
More including instructions [available here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project).
|
||||||
without any additional library
|
Other configuration examples:
|
||||||
* [TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md) - contains extensions (mostly for
|
|
||||||
`RequestsExecutor`), which allows to use the core library in more pleasant way
|
|
||||||
* [TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) - contains extensions for more comfortable
|
|
||||||
work with commands, updates and other different things
|
|
||||||
* [TelegramBotAPI](tgbotapi/README.md) - concentration of all previously mentioned libraries
|
|
||||||
|
|
||||||
Most part of some specific solves or unuseful
|
* [For multiplatform](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/tree/master/ResenderBot)
|
||||||
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
* [For JVM](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/blob/master/GetMeBot/build.gradle)
|
||||||
|
|
||||||
## JavaScript notes
|
### Most common example
|
||||||
|
|
||||||
### Versions before `0.28.0`
|
```kotlin
|
||||||
|
suspend fun main() {
|
||||||
|
val bot = telegramBot(TOKEN)
|
||||||
|
|
||||||
In case if you are want to use this library inside of browser, you will need additional settings (thanks for help to [Alexander Nozik](https://research.jetbrains.org/researchers/altavir)):
|
bot.buildBehaviour {
|
||||||
|
println(getMe())
|
||||||
<details>
|
|
||||||
<summary>Gradle build script help (for versions before 0.28.0)</summary>
|
onCommand("start") {
|
||||||
|
reply(it, "Hi:)")
|
||||||
```groovy
|
|
||||||
dependencies {
|
|
||||||
/* ... */
|
|
||||||
|
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI:$tgbot_api_version"
|
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$tgbot_api_version" // optional
|
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-utils:$tgbot_api_version" // optional
|
|
||||||
|
|
||||||
/* Block of dependencies for correct building in browser */
|
|
||||||
implementation(npm("fs"))
|
|
||||||
implementation(npm("bufferutil"))
|
|
||||||
implementation(npm("utf-8-validate"))
|
|
||||||
implementation(npm("abort-controller"))
|
|
||||||
implementation(npm("text-encoding"))
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ... */
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
target {
|
|
||||||
browser {
|
|
||||||
/* Block for fix of exception in absence of some functionality, https://github.com/ktorio/ktor/issues/1339 */
|
|
||||||
dceTask {
|
|
||||||
dceOptions {
|
|
||||||
keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}.join()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
In this example you will see information about this bot at the moment of starting and answer with `Hi:)` every time it
|
||||||
|
gets message `/start`
|
||||||
|
|
||||||
## Ok, where should I start?
|
### Handling only last messages
|
||||||
|
|
||||||

|
```kotlin
|
||||||
|
suspend fun main() {
|
||||||
|
val bot = telegramBot(TOKEN)
|
||||||
|
|
||||||
In most cases, the most simple way will be to implement [TelegramBotAPI](tgbotapi/README.md) - it contains
|
val flowsUpdatesFilter = FlowsUpdatesFilter()
|
||||||
all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just
|
bot.buildBehaviour(flowUpdatesFilter = flowsUpdatesFilter) {
|
||||||
[TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md),
|
println(getMe())
|
||||||
[TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) or even
|
|
||||||
[TelegramBotAPI Core](tgbotapi.core/README.md).
|
onCommand("start") {
|
||||||
|
reply(it, "Hi:)")
|
||||||
|
}
|
||||||
|
|
||||||
If you want to dive deeper in the core of library or develop something for it - welcome to learn more from
|
retrieveAccumulatedUpdates(this).join()
|
||||||
[TelegramBotAPI Core](tgbotapi.core/README.md) and our [Telegram Chat](https://teleg.one/InMoTelegramBotAPIChat).
|
}
|
||||||
|
|
||||||
Anyway, all libraries are very typical inside of them. Examples:
|
|
||||||
|
|
||||||
* In `TelegramBotAPI` common request look like `requestsExecutor.execute(SomeRequest())`
|
|
||||||
* `tgbotapi.extensions.api` typical syntax look like `requestsExecutor.someRequest()` (in most cases it would be
|
|
||||||
better to use `bot` name instead of `requestsExecutor`)
|
|
||||||
* `tgbotapi.extensions.utils` will look like `filter.filterBaseMessageUpdates(chatId).filterExactCommands(Regex("^.*$"))...`
|
|
||||||
|
|
||||||
## Build instruction
|
|
||||||
|
|
||||||
If you want to build this project or to contribute, there are several recommendations:
|
|
||||||
|
|
||||||
### Build
|
|
||||||
|
|
||||||
In case if you want to just build project, run next command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./gradlew clean build
|
|
||||||
```
|
|
||||||
|
|
||||||
On windows:
|
|
||||||
|
|
||||||
```
|
|
||||||
gradlew.bat clean build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Publishing for work with your version locally
|
|
||||||
|
|
||||||
In case, if you want to work in your other projects using your modification (or some state) of this library,
|
|
||||||
you can use next code:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./gradlew clean build publishToMavenLocal
|
|
||||||
```
|
|
||||||
|
|
||||||
On windows:
|
|
||||||
|
|
||||||
```
|
|
||||||
gradlew.bat clean build publishToMavenLocal
|
|
||||||
```
|
|
||||||
|
|
||||||
But you must remember, that in this case your local maven repo must be the first one from
|
|
||||||
your project retrieving libraries:
|
|
||||||
|
|
||||||
```groovy
|
|
||||||
repositories {
|
|
||||||
mavenLocal() // that must be the first one
|
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Besides, for your own version you can change variable `library_version` in the file [gradle.properties](./gradle.properties).
|
The main difference with the previous example is that bot will get only last updates (accumulated before bot launch
|
||||||
|
and maybe some updates it got after launch)
|
||||||
|
|
||||||
|
### Build a little bit more complex behaviour
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
suspend fun main() {
|
||||||
|
val bot = telegramBot(TOKEN)
|
||||||
|
|
||||||
|
bot.buildBehaviour {
|
||||||
|
println(getMe())
|
||||||
|
|
||||||
|
val nameReplyMarkup = ReplyKeyboardMarkup(
|
||||||
|
matrix {
|
||||||
|
row {
|
||||||
|
+SimpleKeyboardButton("nope")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
onCommand("start") {
|
||||||
|
val photo = waitPhoto(
|
||||||
|
SendTextMessage(it.chat.id, "Send me your photo please")
|
||||||
|
).first()
|
||||||
|
|
||||||
|
val name = waitText(
|
||||||
|
SendTextMessage(
|
||||||
|
it.chat.id,
|
||||||
|
"Send me your name or choose \"nope\"",
|
||||||
|
replyMarkup = nameReplyMarkup
|
||||||
|
)
|
||||||
|
).first().text.takeIf { it != "nope" }
|
||||||
|
|
||||||
|
sendPhoto(
|
||||||
|
it.chat,
|
||||||
|
photo.mediaCollection,
|
||||||
|
entities = buildEntities {
|
||||||
|
if (name != null) regular(name) // may be collapsed up to name ?.let(::regular)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}.join()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### More examples
|
||||||
|
|
||||||
|
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
|
||||||
|
always welcome in our [wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/About-this-project) and
|
||||||
|
[chat](https://t.me/InMoTelegramBotAPIChat).
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<minder version="1.11.1">
|
<minder version="1.11.3">
|
||||||
<theme name="default" label="Default" index="-1"/>
|
<theme name="default" label="Default" index="-1"/>
|
||||||
<styles>
|
<styles>
|
||||||
<style level="0" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
<style level="0" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
@@ -14,45 +14,54 @@
|
|||||||
<style level="9" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
<style level="9" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
<style level="10" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
<style level="10" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
</styles>
|
</styles>
|
||||||
<drawarea x="-320.56697591145837" y="-10.028254191080691" scale="0.75"/>
|
<drawarea x="-950.47548925255796" y="-49.650554065281653" scale="0.5"/>
|
||||||
<images/>
|
<images/>
|
||||||
<nodes>
|
<nodes>
|
||||||
<node id="0" posx="748.88964843749955" posy="119.42341613769531" width="472" height="168" side="top" fold="false" treesize="603" layout="Downwards" group="false">
|
<node id="0" posx="1378.798161778599" posy="159.04571601189673" width="472" height="168" side="top" fold="false" treesize="743" layout="Downwards" group="false">
|
||||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="439" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="439" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
<nodename posx="764.88964843749955" posy="135.42341613769531" maxwidth="488.96484375">
|
<nodename posx="1394.798161778599" posy="175.04571601189673" maxwidth="488.96484375">
|
||||||
<text data="tgbotapi.core Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api"/>
|
<text data="tgbotapi.core Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api"/>
|
||||||
</nodename>
|
</nodename>
|
||||||
<nodenote></nodenote>
|
<nodenote></nodenote>
|
||||||
<nodes>
|
<nodes>
|
||||||
<node id="1" posx="781.88964843749955" posy="387.42341613769531" width="406" height="145" side="bottom" fold="false" treesize="603" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
<node id="1" posx="1411.798161778599" posy="427.04571601189673" width="406" height="145" side="bottom" fold="false" treesize="743" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="none" nodewidth="394" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="none" nodewidth="394" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
<nodename posx="797.88964843749955" posy="403.42341613769531" maxwidth="419.451171875">
|
<nodename posx="1427.798161778599" posy="443.04571601189673" maxwidth="419.451171875">
|
||||||
<text data="TelegramBotAPI extensions Family of projects which are fully based on TelegramBotAPI and extend its functionality"/>
|
<text data="TelegramBotAPI extensions Family of projects which are fully based on TelegramBotAPI and extend its functionality"/>
|
||||||
</nodename>
|
</nodename>
|
||||||
<nodenote></nodenote>
|
<nodenote></nodenote>
|
||||||
<nodes>
|
<nodes>
|
||||||
<node id="2" posx="683.38964843749955" posy="632.42341613769531" width="296" height="191" side="bottom" fold="false" treesize="296" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
<node id="2" posx="1247.298161778599" posy="672.04571601189673" width="296" height="191" side="bottom" fold="false" treesize="296" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="203" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="203" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
<nodename posx="699.38964843749955" posy="648.42341613769531" maxwidth="295.90315755208337">
|
<nodename posx="1263.298161778599" posy="688.04571601189673" maxwidth="295.90315755208337">
|
||||||
<text data="tgbotapi.extensions.api Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier"/>
|
<text data="tgbotapi.extensions.api Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier"/>
|
||||||
</nodename>
|
</nodename>
|
||||||
<nodenote></nodenote>
|
<nodenote></nodenote>
|
||||||
</node>
|
</node>
|
||||||
<node id="3" posx="979.38964843749955" posy="632.42341613769531" width="307" height="168" side="bottom" fold="false" treesize="307" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
<node id="3" posx="1609.298161778599" posy="672.04571601189673" width="307" height="168" side="bottom" fold="false" treesize="439" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="286" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="286" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
<nodename posx="995.38964843749955" posy="648.42341613769531" maxwidth="299.252197265625">
|
<nodename posx="1625.298161778599" posy="688.04571601189673" maxwidth="299.252197265625">
|
||||||
<text data="tgbotapi.extensions.utils Extensions project with utils things which will make easier different operations"/>
|
<text data="tgbotapi.extensions.utils Extensions project with utils things which will make easier different operations"/>
|
||||||
</nodename>
|
</nodename>
|
||||||
<nodenote></nodenote>
|
<nodenote></nodenote>
|
||||||
|
<nodes>
|
||||||
|
<node id="4" posx="1543.298161778599" posy="940.04571601189673" width="439" height="122" side="bottom" fold="false" treesize="439" color="#68b723" colorroot="false" layout="Downwards" group="false">
|
||||||
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="387" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
|
<nodename posx="1559.298161778599" posy="956.04571601189673" maxwidth="408.97932942708348">
|
||||||
|
<text data="tgbotapi.extensions.behaviour_builder Extension project for building bot behaviour via special dsl"/>
|
||||||
|
</nodename>
|
||||||
|
<nodenote></nodenote>
|
||||||
|
</node>
|
||||||
|
</nodes>
|
||||||
</node>
|
</node>
|
||||||
</nodes>
|
</nodes>
|
||||||
</node>
|
</node>
|
||||||
</nodes>
|
</nodes>
|
||||||
</node>
|
</node>
|
||||||
<node id="4" posx="815.52319335937455" posy="948.04447937011719" width="329" height="213" side="top" fold="false" treesize="329" layout="Downwards" group="false">
|
<node id="5" posx="1391.8445078072455" posy="1155.6062730594231" width="461" height="236" side="bottom" fold="false" treesize="461" layout="Downwards" group="false">
|
||||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="388" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="430" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
<nodename posx="831.52319335937455" posy="964.04447937011719" maxwidth="394.3671875">
|
<nodename posx="1407.8445078072455" posy="1171.6062730594231" maxwidth="453.885498046875">
|
||||||
<text data="tgbotapi Here included all available TelegramBotAPI libraries: * tgbotapi.core * tgbotapi.extensions.api * tgbotapi.extensions.utils">
|
<text data="tgbotapi Here included all available TelegramBotAPI libraries: * tgbotapi.core * tgbotapi.extensions.api * tgbotapi.extensions.utils * tgbotapi.extensions.behaviour_builder">
|
||||||
<color>
|
<color>
|
||||||
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
@@ -70,6 +79,94 @@
|
|||||||
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
@@ -102,6 +199,90 @@
|
|||||||
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||||
</color>
|
</color>
|
||||||
</text>
|
</text>
|
||||||
</nodename>
|
</nodename>
|
||||||
@@ -110,12 +291,17 @@
|
|||||||
</nodes>
|
</nodes>
|
||||||
<groups/>
|
<groups/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection from_id="2" to_id="4" drag_x="905.70642089843705" drag_y="891.23394775390625" color="#777777">
|
<connection from_id="2" to_id="5" drag_x="1475.8213347929195" drag_y="1014.8259945356604" color="#777777">
|
||||||
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
<title></title>
|
<title></title>
|
||||||
<note></note>
|
<note></note>
|
||||||
</connection>
|
</connection>
|
||||||
<connection from_id="3" to_id="4" drag_x="1056.456420898437" drag_y="885.48394775390625" color="#777777">
|
<connection from_id="4" to_id="5" drag_x="1691.5447998046875" drag_y="1107.00439453125" color="#777777">
|
||||||
|
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<title></title>
|
||||||
|
<note></note>
|
||||||
|
</connection>
|
||||||
|
<connection from_id="3" to_id="5" drag_x="1483.48876953125" drag_y="896.18115234375">
|
||||||
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
<title></title>
|
<title></title>
|
||||||
<note></note>
|
<note></note>
|
||||||
|
|||||||
20
badges/template.svg
Normal file
20
badges/template.svg
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="104" height="20">
|
||||||
|
<linearGradient id="b" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="a">
|
||||||
|
<rect width="104" height="20" rx="3" fill="#fff"/>
|
||||||
|
</clipPath>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path fill="#555" d="M0 0h65v20H0z"/>
|
||||||
|
<path fill="#007ec6" d="M35 0h69v20H35z"/>
|
||||||
|
<path fill="url(#b)" d="M0 0h104v20H0z"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
||||||
|
<text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">Bot</text>
|
||||||
|
<text x="175" y="140" transform="scale(.1)">Bot</text>
|
||||||
|
<text x="690" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">Template</text>
|
||||||
|
<text x="690" y="140" transform="scale(.1)">Template</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1016 B |
12
build.gradle
12
build.gradle
@@ -9,7 +9,6 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
|
||||||
classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
|
classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +18,17 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
||||||
|
allprojects {
|
||||||
|
if (it != rootProject.findProject("docs")) {
|
||||||
|
tasks.whenTaskAdded { task ->
|
||||||
|
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
||||||
|
task.enabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getCurrentVersionChangelog() {
|
private String getCurrentVersionChangelog() {
|
||||||
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('stdlib')
|
implementation kotlin('stdlib')
|
||||||
|
|
||||||
project.parent.subprojects.forEach {
|
rootProject.subprojects.forEach {
|
||||||
if (it != project) {
|
if (it != project) {
|
||||||
api it
|
api it
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ private List<SourceDirectorySet> findSourcesWithName(String... approximateNames)
|
|||||||
}.collect { it.kotlin }
|
}.collect { it.kotlin }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.dokkaHtml {
|
Object callback = {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case project.hasProperty("DOKKA_PATH"):
|
case project.hasProperty("DOKKA_PATH"):
|
||||||
outputDirectory = project.property("DOKKA_PATH").toString()
|
outputDirectory = project.property("DOKKA_PATH").toString()
|
||||||
@@ -82,11 +82,14 @@ tasks.dokkaHtml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
named("jsMain") {
|
named("jsMain") {
|
||||||
sourceRoots.setFrom(findSourcesWithName("jsMain", "commonMain"))
|
sourceRoots.setFrom(findSourcesWithName("jsMain"))
|
||||||
}
|
}
|
||||||
|
|
||||||
named("jvmMain") {
|
named("jvmMain") {
|
||||||
sourceRoots.setFrom(findSourcesWithName("jvmMain", "commonMain"))
|
sourceRoots.setFrom(findSourcesWithName("jvmMain"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.dokkaGfm(callback)
|
||||||
|
tasks.dokkaHtml(callback)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
dokka_version=1.4.0
|
dokka_version=1.4.32
|
||||||
|
|
||||||
org.gradle.jvmargs=-Xmx1024m
|
org.gradle.jvmargs=-Xmx1024m
|
||||||
|
|||||||
@@ -5,19 +5,18 @@ kotlin.js.generate.externals=true
|
|||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
kotlin_version=1.4.10
|
kotlin_version=1.4.32
|
||||||
kotlin_coroutines_version=1.4.1
|
kotlin_coroutines_version=1.4.3
|
||||||
kotlin_serialisation_runtime_version=1.0.1
|
kotlin_serialisation_runtime_version=1.1.0
|
||||||
klock_version=1.12.1
|
klock_version=2.0.7
|
||||||
uuid_version=0.2.2
|
uuid_version=0.2.4
|
||||||
ktor_version=1.4.1
|
ktor_version=1.5.4
|
||||||
|
|
||||||
micro_utils_version=0.3.0
|
micro_utils_version=0.4.36
|
||||||
|
|
||||||
javax_activation_version=1.1.1
|
javax_activation_version=1.1.1
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=0.30.1
|
library_version=0.34.1
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.5
|
|
||||||
github_release_plugin_version=2.2.12
|
github_release_plugin_version=2.2.12
|
||||||
|
|||||||
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
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 89 KiB |
@@ -1,4 +1,11 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
|
resolutionStrategy {
|
||||||
|
eachPlugin {
|
||||||
|
if (requested.id.id == "org.jetbrains.dokka") {
|
||||||
|
useModule("org.jetbrains.dokka:dokka-gradle-plugin:${requested.version}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
jcenter()
|
jcenter()
|
||||||
@@ -8,5 +15,6 @@ pluginManagement {
|
|||||||
include ":tgbotapi.core"
|
include ":tgbotapi.core"
|
||||||
include ":tgbotapi.extensions.api"
|
include ":tgbotapi.extensions.api"
|
||||||
include ":tgbotapi.extensions.utils"
|
include ":tgbotapi.extensions.utils"
|
||||||
|
include ":tgbotapi.extensions.behaviour_builder"
|
||||||
include ":tgbotapi"
|
include ":tgbotapi"
|
||||||
include ":docs"
|
include ":docs"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# TelegramBotAPI Core
|
# TelegramBotAPI Core
|
||||||
|
|
||||||
[ ](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion)
|
|
||||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core)
|
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core)
|
||||||
|
|
||||||
## What is it?
|
## What is it?
|
||||||
@@ -10,10 +9,7 @@ moments are describing by official [Telegram Bot API](https://core.telegram.org/
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
This version compatible with [4th of November 2020 update of TelegramBotAPI (version 5.0)](https://core.telegram.org/bots/api#november-4-2020).
|
This version compatible with [26th of April 2021 update of TelegramBotAPI (version 5.2)](https://core.telegram.org/bots/api-changelog#april-26-2021).
|
||||||
There is only one exception of implemented functionality - Telegram Passport API, which was presented in
|
|
||||||
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api-changelog#august-27-2018) update. It will be implemented
|
|
||||||
as soon as possible.
|
|
||||||
|
|
||||||
## How to implement library?
|
## How to implement library?
|
||||||
|
|
||||||
@@ -149,3 +145,18 @@ Here was used `okhttp` realisation of client, but there are several others engin
|
|||||||
available on ktor.io site for [client](https://ktor.io/clients/http-client/engines.html) and [server](https://ktor.io/quickstart/artifacts.html)
|
available on ktor.io site for [client](https://ktor.io/clients/http-client/engines.html) and [server](https://ktor.io/quickstart/artifacts.html)
|
||||||
engines.
|
engines.
|
||||||
|
|
||||||
|
### Passport
|
||||||
|
|
||||||
|
In case you wish to work with `Telegram Passport`, currently there are several useful things, but most part of working
|
||||||
|
with decryption and handling is available only on JVM. Next snippet contains example of data decryption on JVM platform:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
passportMessage.passportData.doInDecryptionContextWithPKCS8Key(privateKey) {
|
||||||
|
val passportDataSecureValue = passport ?.data ?: return@doInDecryptionContextWithPKCS8Key
|
||||||
|
val passportData = (passportMessage.passportData.data.firstOrNull { it is CommonPassport } ?: return@doInDecryptionContextWithPKCS8Key) as CommonPassport
|
||||||
|
val decrypted = passportDataSecureValue.decrypt(
|
||||||
|
passportData.data
|
||||||
|
) ?.decodeToString() ?: return@doInDecryptionContextWithPKCS8Key
|
||||||
|
println(decrypted)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,9 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm()
|
jvm {
|
||||||
|
compilations.main.kotlinOptions.useIR = true
|
||||||
|
}
|
||||||
js(BOTH) {
|
js(BOTH) {
|
||||||
browser()
|
browser()
|
||||||
nodejs()
|
nodejs()
|
||||||
@@ -47,7 +48,11 @@ kotlin {
|
|||||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||||
api "com.benasher44:uuid:$uuid_version"
|
api "com.benasher44:uuid:$uuid_version"
|
||||||
|
|
||||||
|
api "dev.inmo:micro_utils.crypto:$micro_utils_version"
|
||||||
api "dev.inmo:micro_utils.coroutines:$micro_utils_version"
|
api "dev.inmo:micro_utils.coroutines:$micro_utils_version"
|
||||||
|
api "dev.inmo:micro_utils.serialization.base64:$micro_utils_version"
|
||||||
|
api "dev.inmo:micro_utils.serialization.encapsulator:$micro_utils_version"
|
||||||
|
api "dev.inmo:micro_utils.serialization.typed_serializer:$micro_utils_version"
|
||||||
|
|
||||||
api "io.ktor:ktor-client-core:$ktor_version"
|
api "io.ktor:ktor-client-core:$ktor_version"
|
||||||
}
|
}
|
||||||
@@ -56,6 +61,7 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('test-common')
|
implementation kotlin('test-common')
|
||||||
implementation kotlin('test-annotations-common')
|
implementation kotlin('test-annotations-common')
|
||||||
|
implementation project(":tgbotapi.extensions.utils")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +80,6 @@ kotlin {
|
|||||||
implementation kotlin('test-junit')
|
implementation kotlin('test-junit')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jsTest {
|
jsTest {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('test-junit')
|
implementation kotlin('test-junit')
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
apply plugin: 'maven-publish'
|
|
||||||
|
|
||||||
task javadocsJar(type: Jar) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
project.publishing.publications.all {
|
|
||||||
// rename artifacts
|
|
||||||
groupId "${project.group}"
|
|
||||||
if (it.name.contains('kotlinMultiplatform')) {
|
|
||||||
artifactId = "${project.name}"
|
|
||||||
} else {
|
|
||||||
artifactId = "${project.name}-$name"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications.all {
|
|
||||||
artifact javadocsJar
|
|
||||||
|
|
||||||
pom {
|
|
||||||
description = "Library for Object-Oriented and type-safe work with Telegram Bot API"
|
|
||||||
name = "Telegram Bot API Core"
|
|
||||||
url = "https://insanusmokrassar.github.io/TelegramBotAPI"
|
|
||||||
|
|
||||||
scm {
|
|
||||||
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
|
||||||
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +1 @@
|
|||||||
{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}}
|
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}}
|
||||||
@@ -1,59 +1,69 @@
|
|||||||
apply plugin: 'com.jfrog.bintray'
|
apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'signing'
|
||||||
|
|
||||||
apply from: "maven.publish.gradle"
|
task javadocsJar(type: Jar) {
|
||||||
|
classifier = 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
bintray {
|
publishing {
|
||||||
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
|
publications.all {
|
||||||
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
artifact javadocsJar
|
||||||
filesSpec {
|
|
||||||
from "${buildDir}/publications/"
|
pom {
|
||||||
eachFile {
|
description = "Library for Object-Oriented and type-safe work with Telegram Bot API"
|
||||||
String directorySubname = it.getFile().parentFile.name
|
name = "Telegram Bot API Core"
|
||||||
if (it.getName() == "module.json") {
|
url = "https://insanusmokrassar.github.io/TelegramBotAPI"
|
||||||
if (directorySubname == "kotlinMultiplatform") {
|
|
||||||
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
|
scm {
|
||||||
} else {
|
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
|
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
|
developers {
|
||||||
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
|
|
||||||
} else {
|
developer {
|
||||||
it.exclude()
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
into "${project.group}".replace(".", "/")
|
repositories {
|
||||||
}
|
if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) {
|
||||||
|
maven {
|
||||||
publish = true
|
name = "GithubPackages"
|
||||||
override = true
|
url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI")
|
||||||
|
credentials {
|
||||||
pkg {
|
username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER')
|
||||||
repo = "TelegramBotAPI"
|
password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD')
|
||||||
name = "${project.name}"
|
}
|
||||||
vcsUrl = "https://github.com/InsanusMokrassar/TelegramBotAPI"
|
}
|
||||||
licenses = ["Apache-2.0"]
|
}
|
||||||
version {
|
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||||
name = "${project.version}"
|
maven {
|
||||||
released = new Date()
|
name = "sonatype"
|
||||||
vcsTag = "${project.version}"
|
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
gpg {
|
credentials {
|
||||||
sign = true
|
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||||
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bintrayUpload.doFirst {
|
signing {
|
||||||
publications = publishing.publications.collect {
|
useGpgCmd()
|
||||||
if (it.name.contains('kotlinMultiplatform')) {
|
sign publishing.publications
|
||||||
null
|
|
||||||
} else {
|
|
||||||
it.name
|
|
||||||
}
|
|
||||||
} - null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bintrayUpload.dependsOn publishToMavenLocal
|
|
||||||
@@ -1,34 +1,20 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
const val CaptionDeprecation = "Captioned interface and others will be removed soon and not recommended to use"
|
||||||
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
|
||||||
|
|
||||||
interface Captioned {
|
@Deprecated(CaptionDeprecation)
|
||||||
|
interface Captioned : Texted {
|
||||||
|
@Deprecated(CaptionDeprecation)
|
||||||
val caption: String?
|
val caption: String?
|
||||||
|
get() = text
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CaptionedOutput : Captioned {
|
@Deprecated(CaptionDeprecation)
|
||||||
val parseMode: ParseMode?
|
interface CaptionedInput : Captioned, TextedInput {
|
||||||
}
|
|
||||||
|
|
||||||
interface CaptionedInput : Captioned {
|
|
||||||
/**
|
/**
|
||||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
* Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||||
* @see [CaptionedInput.fullEntitiesList]
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(CaptionDeprecation)
|
||||||
val captionEntities: List<TextPart>
|
val captionEntities: List<TextPart>
|
||||||
|
get() = textEntities
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CaptionedInput.captionEntities
|
|
||||||
* @see justTextSources
|
|
||||||
*/
|
|
||||||
val CaptionedInput.textSources
|
|
||||||
get() = captionEntities.justTextSources()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert its [CaptionedInput.captionEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
|
||||||
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
|
||||||
*/
|
|
||||||
@Deprecated("Currently list of entities already full. This method is redundant")
|
|
||||||
fun CaptionedInput.fullEntitiesList(): TextSourcesList = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList()
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
|
||||||
|
import dev.inmo.tgbotapi.types.payments.abstracts.Priced
|
||||||
|
|
||||||
|
interface CommonSendInvoiceData : Titled, Currencied, Priced {
|
||||||
|
val description: String
|
||||||
|
val payload: String
|
||||||
|
val providerToken: String
|
||||||
|
val maxTipAmount: Int?
|
||||||
|
val suggestedTipAmounts: List<Int>?
|
||||||
|
val providerData: String?
|
||||||
|
val requireName: Boolean
|
||||||
|
val requirePhoneNumber: Boolean
|
||||||
|
val requireEmail: Boolean
|
||||||
|
val requireShippingAddress: Boolean
|
||||||
|
val shouldSendPhoneNumberToProvider: Boolean
|
||||||
|
val shouldSendEmailToProvider: Boolean
|
||||||
|
val priceDependOnShipAddress: Boolean
|
||||||
|
|
||||||
|
val photoUrl: String?
|
||||||
|
val photoSize: Long?
|
||||||
|
val photoWidth: Int?
|
||||||
|
val photoHeight: Int?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun setPhoto(
|
||||||
|
photoUrl: String,
|
||||||
|
photoSize: Long? = null,
|
||||||
|
photoWidth: Int? = null,
|
||||||
|
photoHeight: Int? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
fun unsetPhoto()
|
||||||
|
}
|
||||||
@@ -1,40 +1,26 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
@Deprecated("Will be removed soon")
|
||||||
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
interface Explained : Texted {
|
||||||
|
|
||||||
interface Explained {
|
|
||||||
val explanation: String?
|
val explanation: String?
|
||||||
|
get() = text
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParsableExplainedOutput : Explained {
|
@Deprecated("Will be removed soon")
|
||||||
val parseMode: ParseMode?
|
interface ParsableExplainedOutput : Explained, TextedOutput
|
||||||
}
|
|
||||||
|
|
||||||
interface EntitiesExplainedOutput : Explained {
|
@Deprecated("Will be removed soon")
|
||||||
val entities: List<TextSource>?
|
interface EntitiesExplainedOutput : Explained, EntitiesOutput
|
||||||
}
|
|
||||||
|
|
||||||
|
@Deprecated("Will be removed soon")
|
||||||
interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput
|
interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput
|
||||||
|
|
||||||
|
@Deprecated("Will be removed soon")
|
||||||
interface ExplainedInput : Explained {
|
interface ExplainedInput : Explained {
|
||||||
|
val textSources: TextSourcesList
|
||||||
/**
|
/**
|
||||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
* Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||||
* @see [ExplainedInput.fullEntitiesList]
|
|
||||||
*/
|
*/
|
||||||
val explanationEntities: List<TextPart>
|
val explanationEntities: List<TextPart>
|
||||||
|
get() = textSources.toTextParts()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ExplainedInput.explanationEntities
|
|
||||||
* @see justTextSources
|
|
||||||
*/
|
|
||||||
val ExplainedInput.textSources
|
|
||||||
get() = explanationEntities.justTextSources()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert its [ExplainedInput.explanationEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
|
||||||
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
|
||||||
*/
|
|
||||||
@Deprecated("Currently list of entities already full. This method is redundant")
|
|
||||||
fun ExplainedInput.fullEntitiesList(): TextSourcesList = explanation ?.fullListOfSubSource(explanationEntities) ?.map { it.source } ?: emptyList()
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.User
|
||||||
|
|
||||||
|
interface FromUser {
|
||||||
|
val user: User
|
||||||
|
}
|
||||||
@@ -1,26 +1,28 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourceSerializer
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.regular
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.regular
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.toTextParts
|
|
||||||
import dev.inmo.tgbotapi.types.captionLength
|
import dev.inmo.tgbotapi.types.captionLength
|
||||||
import dev.inmo.tgbotapi.types.textLength
|
import dev.inmo.tgbotapi.types.textLength
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods"
|
const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods"
|
||||||
|
|
||||||
typealias TextSourcesList = List<TextSource>
|
typealias TextSourcesList = List<TextSource>
|
||||||
@Deprecated("All lists of TextSource in public API now are full. So, this typealias is redundant")
|
|
||||||
typealias FullTextSourcesList = List<TextSource>
|
|
||||||
@Deprecated("All lists of TextPart in public API now are full. So, this typealias is redundant")
|
|
||||||
typealias FullTextPartsList = List<TextPart>
|
|
||||||
|
|
||||||
|
@Serializable(TextSourceSerializer::class)
|
||||||
interface TextSource {
|
interface TextSource {
|
||||||
val asMarkdownSource: String
|
val markdown: String
|
||||||
val asMarkdownV2Source: String
|
val markdownV2: String
|
||||||
val asHtmlSource: String
|
val html: String
|
||||||
val source: String
|
val source: String
|
||||||
|
|
||||||
val asText: String
|
val asText: String
|
||||||
get() = source
|
get() = source
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun serializer() = TextSourceSerializer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
@@ -32,21 +34,36 @@ inline operator fun TextSource.plus(text: String) = listOf(this, regular(text))
|
|||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline operator fun List<TextSource>.plus(text: String) = this + regular(text)
|
inline operator fun List<TextSource>.plus(text: String) = this + regular(text)
|
||||||
|
|
||||||
|
@Serializable(TextSourceSerializer::class)
|
||||||
interface MultilevelTextSource : TextSource {
|
interface MultilevelTextSource : TextSource {
|
||||||
@Deprecated("Will be removed in near major release")
|
val subsources: List<TextSource>
|
||||||
val textParts: List<TextPart>
|
|
||||||
get() = textParts(0)
|
companion object {
|
||||||
val textSources: List<TextSource>
|
fun serializer() = TextSourceSerializer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("This class will be removed soon. Use TextSources instead")
|
||||||
data class TextPart(
|
data class TextPart(
|
||||||
val range: IntRange,
|
val range: IntRange,
|
||||||
val source: TextSource
|
val source: TextSource
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("This method is no longer required to work with TextSources")
|
||||||
fun List<TextPart>.justTextSources() = map { it.source }
|
fun List<TextPart>.justTextSources() = map { it.source }
|
||||||
|
internal fun List<TextSource>.toTextParts(preOffset: Int = 0): List<TextPart> {
|
||||||
|
var i = preOffset
|
||||||
|
return map {
|
||||||
|
TextPart(
|
||||||
|
i until (i + it.source.length),
|
||||||
|
it
|
||||||
|
).also {
|
||||||
|
i = it.range.last + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun List<TextSource>.makeString() = joinToString("") { it.source }
|
fun List<TextSource>.makeString() = joinToString("") { it.source }
|
||||||
internal fun MultilevelTextSource.textParts(offset: Int): List<TextPart> = textSources.toTextParts(offset)
|
|
||||||
fun List<TextSource>.separateForMessage(limit: IntRange, numberOfParts: Int? = null): List<List<TextSource>> {
|
fun List<TextSource>.separateForMessage(limit: IntRange, numberOfParts: Int? = null): List<List<TextSource>> {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
|
|||||||
@@ -1,40 +1,35 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
|
||||||
|
|
||||||
interface Texted {
|
interface Texted {
|
||||||
val text: String?
|
val text: String?
|
||||||
}
|
}
|
||||||
|
interface TextedWithTextSources : Texted {
|
||||||
|
/**
|
||||||
|
* Full list of [TextSource] built from source[TextedInput.textEntities]
|
||||||
|
*/
|
||||||
|
val textSources: List<TextSource>?
|
||||||
|
}
|
||||||
|
|
||||||
interface ParsableOutput : Texted {
|
interface ParsableOutput : Texted {
|
||||||
val parseMode: ParseMode?
|
val parseMode: ParseMode?
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EntitiesOutput : Texted {
|
interface EntitiesOutput : TextedWithTextSources {
|
||||||
val entities: List<TextSource>?
|
val entities: List<TextSource>?
|
||||||
|
get() = textSources
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TextedOutput : ParsableOutput, EntitiesOutput
|
interface TextedOutput : ParsableOutput, EntitiesOutput
|
||||||
|
|
||||||
interface TextedInput : Texted {
|
interface TextedInput : TextedWithTextSources {
|
||||||
|
override val textSources: List<TextSource>
|
||||||
/**
|
/**
|
||||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
* Here must be full list of entities. This list must contains [TextPart]s with
|
||||||
* @see [CaptionedInput.fullEntitiesList]
|
* [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of
|
||||||
|
* regular text
|
||||||
*/
|
*/
|
||||||
val textEntities: List<TextPart>
|
val textEntities: List<TextPart>
|
||||||
|
get() = textSources.toTextParts()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TextedInput.textEntities
|
|
||||||
* @see justTextSources
|
|
||||||
*/
|
|
||||||
val TextedInput.textSources
|
|
||||||
get() = textEntities.justTextSources()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert its [TextedInput.textEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
|
||||||
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
|
||||||
*/
|
|
||||||
@Deprecated("Currently list of entities already full. This method is redundant")
|
|
||||||
fun TextedInput.fullEntitiesList(): TextSourcesList = text ?.fullListOfSubSource(textEntities) ?.map { it.source } ?: emptyList()
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package dev.inmo.tgbotapi.bot.Ktor
|
|||||||
import dev.inmo.micro_utils.coroutines.safely
|
import dev.inmo.micro_utils.coroutines.safely
|
||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.Ktor.base.*
|
import dev.inmo.tgbotapi.bot.Ktor.base.*
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.EmptyLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.Response
|
import dev.inmo.tgbotapi.types.Response
|
||||||
@@ -14,12 +15,39 @@ import io.ktor.client.features.*
|
|||||||
import io.ktor.client.statement.readText
|
import io.ktor.client.statement.readText
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
class KtorRequestsExecutorBuilder(
|
||||||
|
var telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
||||||
|
) {
|
||||||
|
var client: HttpClient = HttpClient()
|
||||||
|
var callsFactories: List<KtorCallFactory> = emptyList()
|
||||||
|
var excludeDefaultFactories: Boolean = false
|
||||||
|
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter()
|
||||||
|
var jsonFormatter: Json = nonstrictJsonFormat
|
||||||
|
|
||||||
|
fun build() = KtorRequestsExecutor(telegramAPIUrlsKeeper, client, callsFactories, excludeDefaultFactories, requestsLimiter, jsonFormatter)
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun telegramBot(
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
crossinline builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
||||||
|
): TelegramBot = KtorRequestsExecutorBuilder(telegramAPIUrlsKeeper).apply(builder).build()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for [telegramBot]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun telegramBot(
|
||||||
|
token: String,
|
||||||
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
|
crossinline builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
||||||
|
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl), builder)
|
||||||
|
|
||||||
class KtorRequestsExecutor(
|
class KtorRequestsExecutor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient(),
|
client: HttpClient = HttpClient(),
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean = false,
|
||||||
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter(),
|
||||||
private val jsonFormatter: Json = nonstrictJsonFormat
|
private val jsonFormatter: Json = nonstrictJsonFormat
|
||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||||
@@ -40,7 +68,7 @@ class KtorRequestsExecutor(
|
|||||||
return safely(
|
return safely(
|
||||||
{ e ->
|
{ e ->
|
||||||
throw if (e is ClientRequestException) {
|
throw if (e is ClientRequestException) {
|
||||||
val content = e.response ?.readText() ?: throw e
|
val content = e.response.readText()
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||||
newRequestException(
|
newRequestException(
|
||||||
responseObject,
|
responseObject,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.safely
|
||||||
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.Response
|
import dev.inmo.tgbotapi.types.Response
|
||||||
import dev.inmo.tgbotapi.types.RetryAfterError
|
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.receive
|
import io.ktor.client.call.receive
|
||||||
@@ -13,10 +13,11 @@ import io.ktor.client.features.timeout
|
|||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
|
var defaultUpdateTimeoutForZeroDelay = 1000L
|
||||||
|
|
||||||
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
||||||
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
||||||
override suspend fun <T : Any> makeCall(
|
override suspend fun <T : Any> makeCall(
|
||||||
@@ -42,6 +43,11 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
requestTimeoutMillis = customTimeoutMillis
|
requestTimeoutMillis = customTimeoutMillis
|
||||||
socketTimeoutMillis = customTimeoutMillis
|
socketTimeoutMillis = customTimeoutMillis
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
timeout {
|
||||||
|
requestTimeoutMillis = defaultUpdateTimeoutForZeroDelay
|
||||||
|
socketTimeoutMillis = defaultUpdateTimeoutForZeroDelay
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,23 +57,17 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
val content = response.receive<String>()
|
val content = response.receive<String>()
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||||
|
|
||||||
return (responseObject.result?.let {
|
return safely {
|
||||||
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
(responseObject.result?.let {
|
||||||
} ?: responseObject.parameters?.let {
|
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
||||||
val error = it.error
|
} ?: response.let {
|
||||||
if (error is RetryAfterError) {
|
throw newRequestException(
|
||||||
delay(error.leftToRetry)
|
responseObject,
|
||||||
makeCall(client, urlsKeeper, request, jsonFormatter)
|
content,
|
||||||
} else {
|
"Can't get result object from $content"
|
||||||
null
|
)
|
||||||
}
|
})
|
||||||
} ?: response.let {
|
}
|
||||||
throw newRequestException(
|
|
||||||
responseObject,
|
|
||||||
content,
|
|
||||||
"Can't get result object from $content"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,9 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
Headers.build {
|
Headers.build {
|
||||||
append(HttpHeaders.ContentType, value.mimeType)
|
append(HttpHeaders.ContentType, value.mimeType)
|
||||||
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
||||||
}
|
},
|
||||||
) {
|
block = value.file::input
|
||||||
value.file.asInput()
|
)
|
||||||
}
|
|
||||||
is FileId -> append(key, value.fileId)
|
is FileId -> append(key, value.fileId)
|
||||||
else -> append(key, value.toString())
|
else -> append(key, value.toString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.bot.exceptions
|
package dev.inmo.tgbotapi.bot.exceptions
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
import dev.inmo.tgbotapi.types.Response
|
import dev.inmo.tgbotapi.types.Response
|
||||||
|
import dev.inmo.tgbotapi.types.RetryAfterError
|
||||||
import io.ktor.utils.io.errors.IOException
|
import io.ktor.utils.io.errors.IOException
|
||||||
|
|
||||||
fun newRequestException(
|
fun newRequestException(
|
||||||
@@ -10,12 +12,19 @@ fun newRequestException(
|
|||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
) = response.description ?.let { description ->
|
) = response.description ?.let { description ->
|
||||||
when {
|
when {
|
||||||
description == "Bad Request: reply message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause)
|
description == "Bad Request: reply message not found" || description == "Bad Request: replied message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause)
|
||||||
description == "Bad Request: message to edit not found" -> MessageToEditNotFoundException(response, plainAnswer, message, cause)
|
description == "Bad Request: message to edit not found" -> MessageToEditNotFoundException(response, plainAnswer, message, cause)
|
||||||
description.contains("Bad Request: message is not modified") -> MessageIsNotModifiedException(response, plainAnswer, message, cause)
|
description.contains("Bad Request: message is not modified") -> MessageIsNotModifiedException(response, plainAnswer, message, cause)
|
||||||
description == "Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause)
|
description == "Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause)
|
||||||
description.contains("PHOTO_INVALID_DIMENSIONS") -> InvalidPhotoDimensionsException(response, plainAnswer, message, cause)
|
description.contains("PHOTO_INVALID_DIMENSIONS") -> InvalidPhotoDimensionsException(response, plainAnswer, message, cause)
|
||||||
description.contains("wrong file identifier") -> WrongFileIdentifierException(response, plainAnswer, message, cause)
|
description.contains("wrong file identifier") -> WrongFileIdentifierException(response, plainAnswer, message, cause)
|
||||||
|
description.contains("Too Many Requests") -> TooMuchRequestsException(
|
||||||
|
(response.parameters ?.error as? RetryAfterError) ?: RetryAfterError(60, DateTime.now().unixMillisLong),
|
||||||
|
response,
|
||||||
|
plainAnswer,
|
||||||
|
message,
|
||||||
|
cause
|
||||||
|
)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
} ?: CommonRequestException(response, plainAnswer, message, cause)
|
} ?: CommonRequestException(response, plainAnswer, message, cause)
|
||||||
@@ -49,3 +58,6 @@ class InvalidPhotoDimensionsException(response: Response, plainAnswer: String, m
|
|||||||
|
|
||||||
class WrongFileIdentifierException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
class WrongFileIdentifierException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
RequestException(response, plainAnswer, message, cause)
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
|
class TooMuchRequestsException(val retryAfter: RetryAfterError, response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|||||||
@@ -1,67 +1,41 @@
|
|||||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.tgbotapi.types.MilliSeconds
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.sync.Semaphore
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.Transient
|
||||||
|
import kotlin.math.roundToLong
|
||||||
|
|
||||||
private fun now(): Long = DateTime.nowUnixLong()
|
private fun now(): Long = DateTime.nowUnixLong()
|
||||||
|
|
||||||
|
@Serializable
|
||||||
class CommonLimiter(
|
class CommonLimiter(
|
||||||
private val lockCount: Int = 10,
|
private val lockCount: Int = 10,
|
||||||
private val regenTime: Long = 20 * 1000L // 20 seconds for full regen of opportunity to send message
|
private val regenTime: MilliSeconds = 15 * 1000, // 15 seconds for full regen of opportunity to send message
|
||||||
|
@Transient
|
||||||
|
private val scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||||
) : RequestLimiter {
|
) : RequestLimiter {
|
||||||
private var doLimit: Boolean = false
|
@Transient
|
||||||
|
private val quotaSemaphore = Semaphore(lockCount)
|
||||||
private val counterChannel = Channel<Unit>(Channel.UNLIMITED)
|
@Transient
|
||||||
private val scope = CoroutineScope(Dispatchers.Default)
|
private val counterRegeneratorJob = scope.launch {
|
||||||
private val counterJob = scope.launch {
|
val regenDelay: MilliSeconds = (regenTime.toDouble() / lockCount).roundToLong()
|
||||||
var wasLastSecond = 0
|
while (isActive) {
|
||||||
var lastCountTime = now()
|
delay(regenDelay)
|
||||||
var limitManagementJob: Job? = null
|
if (quotaSemaphore.availablePermits < lockCount) {
|
||||||
var removeLimitTime: Long = lastCountTime
|
try {
|
||||||
for (counter in counterChannel) {
|
quotaSemaphore.release()
|
||||||
val now = now()
|
} catch (_: IllegalStateException) {
|
||||||
if (now - lastCountTime > 1000) {
|
// Skip IllegalStateException due to the fact that this exception may happens in release method
|
||||||
lastCountTime = now
|
|
||||||
wasLastSecond = 1
|
|
||||||
} else {
|
|
||||||
wasLastSecond++
|
|
||||||
}
|
|
||||||
if (wasLastSecond >= lockCount) {
|
|
||||||
removeLimitTime = now + regenTime
|
|
||||||
if (limitManagementJob == null) {
|
|
||||||
limitManagementJob = launch {
|
|
||||||
doLimit = true
|
|
||||||
var internalNow = now()
|
|
||||||
while (internalNow < removeLimitTime) {
|
|
||||||
delay(removeLimitTime - internalNow)
|
|
||||||
internalNow = now()
|
|
||||||
}
|
|
||||||
doLimit = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (now > removeLimitTime) {
|
|
||||||
limitManagementJob = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val quoterChannel = Channel<Unit>(Channel.CONFLATED)
|
|
||||||
private val tickerJob = scope.launch {
|
|
||||||
while (isActive) {
|
|
||||||
quoterChannel.send(Unit)
|
|
||||||
delay(1000L)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun <T> limit(block: suspend () -> T): T {
|
override suspend fun <T> limit(block: suspend () -> T): T {
|
||||||
counterChannel.send(Unit)
|
quotaSemaphore.acquire()
|
||||||
return if (!doLimit) {
|
return block()
|
||||||
block()
|
|
||||||
} else {
|
|
||||||
quoterChannel.receive()
|
|
||||||
block()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
|
||||||
|
|
||||||
object EmptyLimiter : RequestLimiter {
|
|
||||||
override suspend fun <T> limit(block: suspend () -> T): T = block()
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.safely
|
||||||
|
import dev.inmo.tgbotapi.bot.exceptions.TooMuchRequestsException
|
||||||
|
import dev.inmo.tgbotapi.types.MilliSeconds
|
||||||
|
import dev.inmo.tgbotapi.types.RetryAfterError
|
||||||
|
import io.ktor.client.features.ClientRequestException
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This limiter will limit requests only after getting a [RetryAfterError] or [ClientRequestException] with
|
||||||
|
* [HttpStatusCode.TooManyRequests] status code. Important thing is that in case if some of block has been blocked, all
|
||||||
|
* the others will wait until it will be possible to be called
|
||||||
|
*
|
||||||
|
* @param defaultTooManyRequestsDelay This parameter will be used in case of getting [ClientRequestException] with
|
||||||
|
* [HttpStatusCode.TooManyRequests] as a parameter for delay like it would be [TooMuchRequestsException]. The reason of
|
||||||
|
* it is that in [ClientRequestException] there is no information about required delay between requests
|
||||||
|
*/
|
||||||
|
class ExceptionsOnlyLimiter(
|
||||||
|
private val defaultTooManyRequestsDelay: MilliSeconds = 1000L
|
||||||
|
) : RequestLimiter {
|
||||||
|
private val lockState = MutableStateFlow(false)
|
||||||
|
private suspend fun lock(timeMillis: MilliSeconds) {
|
||||||
|
try {
|
||||||
|
safely {
|
||||||
|
lockState.emit(true)
|
||||||
|
delay(timeMillis)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
lockState.emit(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun <T> limit(block: suspend () -> T): T {
|
||||||
|
while (true) {
|
||||||
|
lockState.first { !it }
|
||||||
|
var throwable: Throwable? = null
|
||||||
|
val result = safely({
|
||||||
|
throwable = when (it) {
|
||||||
|
is TooMuchRequestsException -> {
|
||||||
|
lock(it.retryAfter.leftToRetry)
|
||||||
|
it
|
||||||
|
}
|
||||||
|
is ClientRequestException -> {
|
||||||
|
if (it.response.status == HttpStatusCode.TooManyRequests) {
|
||||||
|
lock(defaultTooManyRequestsDelay)
|
||||||
|
} else {
|
||||||
|
throw it
|
||||||
|
}
|
||||||
|
it
|
||||||
|
}
|
||||||
|
else -> throw it
|
||||||
|
}
|
||||||
|
null
|
||||||
|
}) {
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
if (throwable == null) {
|
||||||
|
return result!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.actor
|
||||||
|
import dev.inmo.micro_utils.coroutines.safely
|
||||||
|
import dev.inmo.tgbotapi.types.MilliSeconds
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.Channel
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
@@ -9,62 +11,60 @@ import kotlin.math.pow
|
|||||||
|
|
||||||
private sealed class RequestEvent
|
private sealed class RequestEvent
|
||||||
private class AddRequest(
|
private class AddRequest(
|
||||||
val continuation: Continuation<Long>
|
val continuation: Continuation<MilliSeconds>
|
||||||
) : RequestEvent()
|
) : RequestEvent()
|
||||||
private object CompleteRequest : RequestEvent()
|
private object CompleteRequest : RequestEvent()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PowLimiter(
|
data class PowLimiter(
|
||||||
private val minAwaitTime: Long = 0L,
|
private val minAwaitTime: MilliSeconds = 0L,
|
||||||
private val maxAwaitTime: Long = 10000L,
|
private val maxAwaitTime: MilliSeconds = 10000L,
|
||||||
private val powValue: Double = 4.0,
|
private val powValue: Double = 4.0,
|
||||||
private val powK: Double = 0.0016
|
private val powK: Double = 1.6,
|
||||||
|
@Transient
|
||||||
|
private val scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||||
) : RequestLimiter {
|
) : RequestLimiter {
|
||||||
@Transient
|
|
||||||
private val scope = CoroutineScope(Dispatchers.Default)
|
|
||||||
@Transient
|
|
||||||
private val eventsChannel = Channel<RequestEvent>(Channel.UNLIMITED)
|
|
||||||
@Transient
|
@Transient
|
||||||
private val awaitTimeRange = minAwaitTime .. maxAwaitTime
|
private val awaitTimeRange = minAwaitTime .. maxAwaitTime
|
||||||
|
@Transient
|
||||||
|
private val eventsChannel = let {
|
||||||
|
var requestsInWork = 0.0
|
||||||
|
scope.actor<RequestEvent> {
|
||||||
|
when (it) {
|
||||||
|
is AddRequest -> {
|
||||||
|
val awaitTime = (requestsInWork.pow(powValue) * powK).toLong()
|
||||||
|
requestsInWork++
|
||||||
|
|
||||||
init {
|
it.continuation.resume(
|
||||||
scope.launch {
|
when {
|
||||||
var requestsInWork: Double = 0.0
|
awaitTime in awaitTimeRange -> awaitTime
|
||||||
for (event in eventsChannel) {
|
awaitTime < awaitTimeRange.first -> awaitTimeRange.first
|
||||||
when (event) {
|
else -> awaitTimeRange.last
|
||||||
is AddRequest -> {
|
}
|
||||||
val awaitTime = (((requestsInWork.pow(powValue) * powK) * 1000L).toLong())
|
)
|
||||||
requestsInWork++
|
|
||||||
|
|
||||||
event.continuation.resume(
|
|
||||||
if (awaitTime in awaitTimeRange) {
|
|
||||||
awaitTime
|
|
||||||
} else {
|
|
||||||
if (awaitTime < minAwaitTime) {
|
|
||||||
minAwaitTime
|
|
||||||
} else {
|
|
||||||
maxAwaitTime
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
is CompleteRequest -> requestsInWork--
|
|
||||||
}
|
}
|
||||||
|
is CompleteRequest -> requestsInWork--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun <T> limit(
|
private suspend inline fun <T> withDelay(
|
||||||
block: suspend () -> T
|
crossinline block: suspend () -> T
|
||||||
): T {
|
): T {
|
||||||
val delayMillis = suspendCoroutine<Long> {
|
val delayMillis = suspendCoroutine<Long> {
|
||||||
scope.launch { eventsChannel.send(AddRequest(it)) }
|
scope.launch { eventsChannel.send(AddRequest(it)) }
|
||||||
}
|
}
|
||||||
delay(delayMillis)
|
delay(delayMillis)
|
||||||
return try {
|
return try {
|
||||||
block()
|
safely { block() }
|
||||||
} finally {
|
} finally {
|
||||||
eventsChannel.send(CompleteRequest)
|
eventsChannel.send(CompleteRequest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun <T> limit(
|
||||||
|
block: suspend () -> T
|
||||||
|
): T {
|
||||||
|
return withDelay(block)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.passport.PassportElementError
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetPassportDataErrors(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
val user: UserId,
|
||||||
|
@SerialName(errorsField)
|
||||||
|
val errors: List<PassportElementError>
|
||||||
|
) : SimpleRequest<Boolean> {
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = Boolean.serializer()
|
||||||
|
override fun method(): String = "setPassportDataErrors"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ data class AnswerCallbackQuery(
|
|||||||
val showAlert: Boolean? = null,
|
val showAlert: Boolean? = null,
|
||||||
@SerialName(urlField)
|
@SerialName(urlField)
|
||||||
val url: String? = null,
|
val url: String? = null,
|
||||||
@SerialName(cachedTimeField)
|
@SerialName(cacheTimeField)
|
||||||
val cachedTimeSeconds: Int? = null
|
val cachedTimeSeconds: Int? = null
|
||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerCallbackQuery"
|
override fun method(): String = "answerCallbackQuery"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ data class AnswerInlineQuery(
|
|||||||
@Serializable(InlineQueryAnswersResultsSerializer::class)
|
@Serializable(InlineQueryAnswersResultsSerializer::class)
|
||||||
@SerialName(resultsField)
|
@SerialName(resultsField)
|
||||||
val results: List<InlineQueryResult> = emptyList(),
|
val results: List<InlineQueryResult> = emptyList(),
|
||||||
@SerialName(cachedTimeField)
|
@SerialName(cacheTimeField)
|
||||||
val cachedTime: Int? = null,
|
val cachedTime: Int? = null,
|
||||||
@SerialName(isPersonalField)
|
@SerialName(isPersonalField)
|
||||||
val isPersonal: Boolean? = null,
|
val isPersonal: Boolean? = null,
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.abstracts
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
|
||||||
|
interface ChatInviteLinkRequest : SimpleRequest<CommonInviteLink> {
|
||||||
|
val chatId: ChatIdentifier
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<CommonInviteLink>
|
||||||
|
get() = CommonInviteLink.serializer()
|
||||||
|
}
|
||||||
|
interface KnownChatInviteLinkRequest : ChatInviteLinkRequest {
|
||||||
|
val inviteLink: String
|
||||||
|
}
|
||||||
|
interface EditChatInviteLinkRequest : ChatInviteLinkRequest {
|
||||||
|
val expireDate: DateTime?
|
||||||
|
val membersLimit: MembersLimit?
|
||||||
|
}
|
||||||
@@ -4,13 +4,13 @@ import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMemberSerializerWithoutDeserialization
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMemberSerializer
|
||||||
import dev.inmo.tgbotapi.types.chatIdField
|
import dev.inmo.tgbotapi.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.builtins.ListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
private val chatMembersListSerializer = ListSerializer(
|
private val chatMembersListSerializer = ListSerializer(
|
||||||
AdministratorChatMemberSerializerWithoutDeserialization
|
AdministratorChatMemberSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.abstracts.EditChatInviteLinkRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CreateChatInviteLink(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(expireDateField)
|
||||||
|
private val expirationUnixTimeStamp: TelegramDate? = null,
|
||||||
|
@SerialName(memberLimitField)
|
||||||
|
override val membersLimit: MembersLimit? = null
|
||||||
|
) : EditChatInviteLinkRequest {
|
||||||
|
override val expireDate: DateTime?
|
||||||
|
get() = expirationUnixTimeStamp ?.asDate
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "createChatInviteLink"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun CreateChatInviteLink(
|
||||||
|
chatId: ChatId,
|
||||||
|
expireDate: DateTime,
|
||||||
|
membersLimit: MembersLimit? = null
|
||||||
|
): CreateChatInviteLink = CreateChatInviteLink(
|
||||||
|
chatId, expireDate.toTelegramDate(), membersLimit
|
||||||
|
)
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.abstracts.EditChatInviteLinkRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.abstracts.KnownChatInviteLinkRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class EditChatInviteLink(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(inviteLinkField)
|
||||||
|
override val inviteLink: String,
|
||||||
|
@SerialName(expireDateField)
|
||||||
|
private val expirationUnixTimeStamp: TelegramDate? = null,
|
||||||
|
@SerialName(memberLimitField)
|
||||||
|
override val membersLimit: MembersLimit? = null
|
||||||
|
) : EditChatInviteLinkRequest, KnownChatInviteLinkRequest {
|
||||||
|
override val expireDate: DateTime?
|
||||||
|
get() = expirationUnixTimeStamp ?.asDate
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "editChatInviteLink"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun EditChatInviteLink(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
inviteLink: String,
|
||||||
|
expireDate: DateTime,
|
||||||
|
membersLimit: MembersLimit? = null
|
||||||
|
): EditChatInviteLink = EditChatInviteLink(
|
||||||
|
chatId, inviteLink, expireDate.toTelegramDate(), membersLimit
|
||||||
|
)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.abstracts.KnownChatInviteLinkRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RevokeChatInviteLink(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(inviteLinkField)
|
||||||
|
override val inviteLink: String
|
||||||
|
) : KnownChatInviteLinkRequest {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "revokeChatInviteLink"
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.requests.chat.members
|
|||||||
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatMemberRequest
|
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatMemberRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMemberSerializer
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -15,7 +15,7 @@ data class GetChatMember(
|
|||||||
) : ChatMemberRequest<ChatMember> {
|
) : ChatMemberRequest<ChatMember> {
|
||||||
override fun method(): String = "getChatMember"
|
override fun method(): String = "getChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<ChatMember>
|
override val resultDeserializer: DeserializationStrategy<ChatMember>
|
||||||
get() = ChatMemberDeserializationStrategy
|
get() = ChatMemberSerializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ data class KickChatMember(
|
|||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(untilDateField)
|
@SerialName(untilDateField)
|
||||||
override val untilDate: TelegramDate? = null
|
override val untilDate: TelegramDate? = null,
|
||||||
|
@SerialName(revokeMessagesField)
|
||||||
|
val revokeMessages: Boolean? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "kickChatMember"
|
override fun method(): String = "kickChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ data class PromoteChatMember(
|
|||||||
@SerialName(canPinMessagesField)
|
@SerialName(canPinMessagesField)
|
||||||
private val canPinMessages: Boolean? = null,
|
private val canPinMessages: Boolean? = null,
|
||||||
@SerialName(canPromoteMembersField)
|
@SerialName(canPromoteMembersField)
|
||||||
private val canPromoteMembers: Boolean? = null
|
private val canPromoteMembers: Boolean? = null,
|
||||||
|
@SerialName(canManageVoiceChatsField)
|
||||||
|
private val canManageVoiceChats: Boolean? = null,
|
||||||
|
@SerialName(canManageChatField)
|
||||||
|
private val canManageChat: Boolean? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "promoteChatMember"
|
override fun method(): String = "promoteChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ data class SetChatPhoto (
|
|||||||
override fun method(): String = "setChatPhoto"
|
override fun method(): String = "setChatPhoto"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = Boolean.serializer()
|
get() = Boolean.serializer()
|
||||||
|
@Transient
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
||||||
|
@Transient
|
||||||
override val paramsJson: JsonObject = toJson(serializer())
|
override val paramsJson: JsonObject = toJson(serializer())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ package dev.inmo.tgbotapi.requests.chat.modify
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest
|
import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.chatIdField
|
|
||||||
import dev.inmo.tgbotapi.types.messageIdField
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.utils.throwRangeError
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
||||||
|
const val editMessageLiveLocationMethod = "editMessageLiveLocation"
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditChatMessageLiveLocation(
|
data class EditChatMessageLiveLocation(
|
||||||
@@ -30,7 +31,7 @@ data class EditChatMessageLiveLocation(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage<LocationContent>, EditReplyMessage, EditLocationMessage {
|
) : EditChatMessage<LocationContent>, EditReplyMessage, EditLocationMessage {
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
override fun method(): String = editMessageLiveLocationMethod
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||||
get() = commonResultDeserializer
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ data class EditInlineMessageLiveLocation(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditReplyMessage, EditLocationMessage {
|
) : EditInlineMessage, EditReplyMessage, EditLocationMessage {
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
override fun method(): String = editMessageLiveLocationMethod
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.message.content.LocationContent
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
||||||
|
const val stopMessageLiveLocationMethod = "stopMessageLiveLocation"
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class StopChatMessageLiveLocation(
|
data class StopChatMessageLiveLocation(
|
||||||
@@ -20,7 +21,7 @@ data class StopChatMessageLiveLocation(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage<LocationContent>, EditReplyMessage {
|
) : EditChatMessage<LocationContent>, EditReplyMessage {
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
override fun method(): String = stopMessageLiveLocationMethod
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||||
get() = commonResultDeserializer
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ data class StopInlineMessageLiveLocation(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditReplyMessage {
|
) : EditInlineMessage, EditReplyMessage {
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
override fun method(): String = stopMessageLiveLocationMethod
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.edit.caption
|
package dev.inmo.tgbotapi.requests.edit.caption
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer
|
import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -58,8 +59,8 @@ data class EditChatMessageCaption internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
|
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text) ?.justTextSources()
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = editMessageCaptionMethod
|
override fun method(): String = editMessageCaptionMethod
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.edit.caption
|
package dev.inmo.tgbotapi.requests.edit.caption
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
@@ -47,8 +48,8 @@ data class EditInlineMessageCaption internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text) ?.justTextSources()
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = editMessageCaptionMethod
|
override fun method(): String = editMessageCaptionMethod
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.edit.text
|
package dev.inmo.tgbotapi.requests.edit.text
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer
|
import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -64,8 +65,8 @@ data class EditChatMessageText internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text) ?.justTextSources()
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = editMessageTextMethod
|
override fun method(): String = editMessageTextMethod
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.edit.text
|
package dev.inmo.tgbotapi.requests.edit.text
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.edit.media.editMessageMediaMethod
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
@@ -54,11 +54,11 @@ data class EditInlineMessageText internal constructor(
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = editMessageMediaMethod
|
override fun method(): String = editMessageTextMethod
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.*
|
|||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun CopyMessage(
|
fun CopyMessage(
|
||||||
@@ -64,8 +62,8 @@ data class CopyMessage internal constructor(
|
|||||||
TextedOutput {
|
TextedOutput {
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
get() = fromChatId
|
get() = fromChatId
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "copyMessage"
|
override fun method(): String = "copyMessage"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send
|
package dev.inmo.tgbotapi.requests.send
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
|
import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -83,8 +84,8 @@ data class SendTextMessage internal constructor(
|
|||||||
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
||||||
DisableWebPagePreview
|
DisableWebPagePreview
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text) ?.justTextSources()
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
@@ -20,7 +21,7 @@ fun SendAnimation(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
animation: InputFile,
|
animation: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumb: InputFile? = null,
|
||||||
caption: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
width: Int? = null,
|
width: Int? = null,
|
||||||
@@ -39,7 +40,7 @@ fun SendAnimation(
|
|||||||
chatId,
|
chatId,
|
||||||
animationAsFileId,
|
animationAsFileId,
|
||||||
thumbAsFileId,
|
thumbAsFileId,
|
||||||
caption,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
duration,
|
duration,
|
||||||
@@ -144,8 +145,8 @@ data class SendAnimationData internal constructor(
|
|||||||
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
|
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||||
SizedSendMessageRequest<ContentMessage<AnimationContent>>
|
SizedSendMessageRequest<ContentMessage<AnimationContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ fun SendAudio(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
audio: InputFile,
|
audio: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumb: InputFile? = null,
|
||||||
caption: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
performer: String? = null,
|
performer: String? = null,
|
||||||
@@ -39,7 +39,7 @@ fun SendAudio(
|
|||||||
chatId,
|
chatId,
|
||||||
audioAsFileId,
|
audioAsFileId,
|
||||||
thumbAsFileId,
|
thumbAsFileId,
|
||||||
caption,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
duration,
|
duration,
|
||||||
@@ -145,8 +145,8 @@ data class SendAudioData internal constructor(
|
|||||||
DuratedSendMessageRequest<ContentMessage<AudioContent>>,
|
DuratedSendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
Performerable
|
Performerable
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
@@ -29,7 +30,7 @@ fun SendDocument(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
document: InputFile,
|
document: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumb: InputFile? = null,
|
||||||
caption: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
@@ -46,7 +47,7 @@ fun SendDocument(
|
|||||||
chatId,
|
chatId,
|
||||||
documentAsFileId,
|
documentAsFileId,
|
||||||
thumbAsFileId,
|
thumbAsFileId,
|
||||||
caption,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
@@ -157,8 +158,8 @@ data class SendDocumentData internal constructor(
|
|||||||
TextableSendMessageRequest<ContentMessage<DocumentContent>>,
|
TextableSendMessageRequest<ContentMessage<DocumentContent>>,
|
||||||
ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
|
ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import dev.inmo.tgbotapi.types.*
|
|||||||
import dev.inmo.tgbotapi.types.InputMedia.*
|
import dev.inmo.tgbotapi.types.InputMedia.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.media.AudioContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
|
||||||
import dev.inmo.tgbotapi.utils.*
|
import dev.inmo.tgbotapi.utils.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.builtins.ListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
@@ -17,13 +21,13 @@ const val rawSendingMediaGroupsWarning = "Media groups contains restrictions rel
|
|||||||
" types. Currently it is possible to combine photo + video OR audio OR documents"
|
" types. Currently it is possible to combine photo + video OR audio OR documents"
|
||||||
|
|
||||||
@RiskFeature(rawSendingMediaGroupsWarning)
|
@RiskFeature(rawSendingMediaGroupsWarning)
|
||||||
fun SendMediaGroup(
|
fun <T : MediaGroupContent> SendMediaGroup(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
media: List<MediaGroupMemberInputMedia>,
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null
|
allowSendingWithoutReply: Boolean? = null
|
||||||
): Request<List<MediaGroupMessage>> {
|
): Request<List<MediaGroupMessage<T>>> {
|
||||||
if (media.size !in mediaCountInMediaGroup) {
|
if (media.size !in mediaCountInMediaGroup) {
|
||||||
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
||||||
}
|
}
|
||||||
@@ -47,14 +51,14 @@ fun SendMediaGroup(
|
|||||||
allowSendingWithoutReply
|
allowSendingWithoutReply
|
||||||
)
|
)
|
||||||
|
|
||||||
return if (files.isEmpty()) {
|
return (if (files.isEmpty()) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
MultipartRequestImpl(
|
||||||
data,
|
data,
|
||||||
SendMediaGroupFiles(files)
|
SendMediaGroupFiles(files)
|
||||||
)
|
)
|
||||||
}
|
}) as Request<List<MediaGroupMessage<T>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +73,7 @@ inline fun SendPlaylist(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null
|
allowSendingWithoutReply: Boolean? = null
|
||||||
) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
) = SendMediaGroup<AudioContent>(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this method to be sure that you are correctly sending documents media group
|
* Use this method to be sure that you are correctly sending documents media group
|
||||||
@@ -83,7 +87,7 @@ inline fun SendDocumentsGroup(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null
|
allowSendingWithoutReply: Boolean? = null
|
||||||
) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
) = SendMediaGroup<DocumentContent>(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this method to be sure that you are correctly sending visual media group
|
* Use this method to be sure that you are correctly sending visual media group
|
||||||
@@ -98,9 +102,9 @@ inline fun SendVisualMediaGroup(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null
|
allowSendingWithoutReply: Boolean? = null
|
||||||
) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
) = SendMediaGroup<VisualMediaGroupContent>(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||||
|
|
||||||
private val messagesListSerializer: KSerializer<List<MediaGroupMessage>>
|
private val messagesListSerializer: KSerializer<List<MediaGroupMessage<MediaGroupContent>>>
|
||||||
= ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
|
= ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -114,7 +118,7 @@ data class SendMediaGroupData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(allowSendingWithoutReplyField)
|
@SerialName(allowSendingWithoutReplyField)
|
||||||
override val allowSendingWithoutReply: Boolean? = null
|
override val allowSendingWithoutReply: Boolean? = null
|
||||||
) : DataRequest<List<MediaGroupMessage>>, SendMessageRequest<List<MediaGroupMessage>> {
|
) : DataRequest<List<MediaGroupMessage<MediaGroupContent>>>, SendMessageRequest<List<MediaGroupMessage<MediaGroupContent>>> {
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
private val convertedMedia: String
|
private val convertedMedia: String
|
||||||
get() = buildJsonArray {
|
get() = buildJsonArray {
|
||||||
@@ -127,7 +131,7 @@ data class SendMediaGroupData internal constructor(
|
|||||||
override fun method(): String = "sendMediaGroup"
|
override fun method(): String = "sendMediaGroup"
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage>>
|
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage<MediaGroupContent>>>
|
||||||
get() = messagesListSerializer
|
get() = messagesListSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
@@ -18,7 +19,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendPhoto(
|
fun SendPhoto(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
photo: InputFile,
|
photo: InputFile,
|
||||||
caption: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
@@ -28,7 +29,7 @@ fun SendPhoto(
|
|||||||
val data = SendPhotoData(
|
val data = SendPhotoData(
|
||||||
chatId,
|
chatId,
|
||||||
(photo as? FileId) ?.fileId,
|
(photo as? FileId) ?.fileId,
|
||||||
caption,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
@@ -100,8 +101,8 @@ data class SendPhotoData internal constructor(
|
|||||||
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
|
||||||
TextableSendMessageRequest<ContentMessage<PhotoContent>>
|
TextableSendMessageRequest<ContentMessage<PhotoContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
@@ -20,7 +21,7 @@ fun SendVideo(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
video: InputFile,
|
video: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumb: InputFile? = null,
|
||||||
caption: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
width: Int? = null,
|
width: Int? = null,
|
||||||
@@ -40,7 +41,7 @@ fun SendVideo(
|
|||||||
chatId,
|
chatId,
|
||||||
videoAsFileId,
|
videoAsFileId,
|
||||||
thumbAsFileId,
|
thumbAsFileId,
|
||||||
caption,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
duration,
|
duration,
|
||||||
@@ -150,8 +151,8 @@ data class SendVideoData internal constructor(
|
|||||||
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
|
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
|
||||||
SizedSendMessageRequest<ContentMessage<VideoContent>>
|
SizedSendMessageRequest<ContentMessage<VideoContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
@@ -19,7 +20,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendVoice(
|
fun SendVoice(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
voice: InputFile,
|
voice: InputFile,
|
||||||
caption: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
@@ -33,7 +34,7 @@ fun SendVoice(
|
|||||||
val data = SendVoiceData(
|
val data = SendVoiceData(
|
||||||
chatId,
|
chatId,
|
||||||
voiceAsFileId,
|
voiceAsFileId,
|
||||||
caption,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
duration,
|
duration,
|
||||||
@@ -120,8 +121,8 @@ data class SendVoiceData internal constructor(
|
|||||||
TextableSendMessageRequest<ContentMessage<VoiceContent>>,
|
TextableSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||||
DuratedSendMessageRequest<ContentMessage<VoiceContent>>
|
DuratedSendMessageRequest<ContentMessage<VoiceContent>>
|
||||||
{
|
{
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.payments
|
package dev.inmo.tgbotapi.requests.send.payments
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.types.*
|
import dev.inmo.tgbotapi.CommonAbstracts.types.*
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -9,7 +10,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializ
|
|||||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
||||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||||
import dev.inmo.tgbotapi.types.payments.LabeledPricesSerializer
|
import dev.inmo.tgbotapi.types.payments.LabeledPricesSerializer
|
||||||
import dev.inmo.tgbotapi.types.payments.abstracts.*
|
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
private val invoiceMessageSerializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
private val invoiceMessageSerializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
||||||
@@ -23,36 +24,40 @@ data class SendInvoice(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatId,
|
override val chatId: ChatId,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
val title: String,
|
override val title: String,
|
||||||
@SerialName(descriptionField)
|
@SerialName(descriptionField)
|
||||||
val description: String,
|
override val description: String,
|
||||||
@SerialName(payloadField)
|
@SerialName(payloadField)
|
||||||
val payload: String,
|
override val payload: String,
|
||||||
@SerialName(providerTokenField)
|
@SerialName(providerTokenField)
|
||||||
val providerToken: String,
|
override val providerToken: String,
|
||||||
@SerialName(startParameterField)
|
|
||||||
val startParameter: StartParameter,
|
|
||||||
@SerialName(currencyField)
|
@SerialName(currencyField)
|
||||||
override val currency: Currency,
|
override val currency: Currency,
|
||||||
@Serializable(LabeledPricesSerializer::class)
|
@Serializable(LabeledPricesSerializer::class)
|
||||||
@SerialName(pricesField)
|
@SerialName(pricesField)
|
||||||
override val prices: List<LabeledPrice>,
|
override val prices: List<LabeledPrice>,
|
||||||
|
@SerialName(maxTipAmountField)
|
||||||
|
override val maxTipAmount: Int? = null,
|
||||||
|
@SerialName(suggestedTipAmountsField)
|
||||||
|
override val suggestedTipAmounts: List<Int>? = null,
|
||||||
|
@SerialName(startParameterField)
|
||||||
|
val startParameter: StartParameter? = null,
|
||||||
@SerialName(providerDataField)
|
@SerialName(providerDataField)
|
||||||
val providerData: String? = null,
|
override val providerData: String? = null,
|
||||||
@SerialName(requireNameField)
|
@SerialName(requireNameField)
|
||||||
val requireName: Boolean = false,
|
override val requireName: Boolean = false,
|
||||||
@SerialName(requirePhoneNumberField)
|
@SerialName(requirePhoneNumberField)
|
||||||
val requirePhoneNumber: Boolean = false,
|
override val requirePhoneNumber: Boolean = false,
|
||||||
@SerialName(requireEmailField)
|
@SerialName(requireEmailField)
|
||||||
val requireEmail: Boolean = false,
|
override val requireEmail: Boolean = false,
|
||||||
@SerialName(requireShippingAddressField)
|
@SerialName(requireShippingAddressField)
|
||||||
val requireShippingAddress: Boolean = false,
|
override val requireShippingAddress: Boolean = false,
|
||||||
@SerialName(shouldSendPhoneNumberToProviderField)
|
@SerialName(shouldSendPhoneNumberToProviderField)
|
||||||
val shouldSendPhoneNumberToProvider: Boolean = false,
|
override val shouldSendPhoneNumberToProvider: Boolean = false,
|
||||||
@SerialName(shouldSendEmailToProviderField)
|
@SerialName(shouldSendEmailToProviderField)
|
||||||
val shouldSendEmailToProvider: Boolean = false,
|
override val shouldSendEmailToProvider: Boolean = false,
|
||||||
@SerialName(priceDependOnShipAddressField)
|
@SerialName(priceDependOnShipAddressField)
|
||||||
val priceDependOnShipAddress: Boolean = false,
|
override val priceDependOnShipAddress: Boolean = false,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
override val disableNotification: Boolean = false,
|
override val disableNotification: Boolean = false,
|
||||||
@SerialName(replyToMessageIdField)
|
@SerialName(replyToMessageIdField)
|
||||||
@@ -61,8 +66,7 @@ data class SendInvoice(
|
|||||||
override val allowSendingWithoutReply: Boolean? = null,
|
override val allowSendingWithoutReply: Boolean? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : Currencied,
|
) : CommonSendInvoiceData,
|
||||||
Priced,
|
|
||||||
ChatRequest,
|
ChatRequest,
|
||||||
DisableNotification,
|
DisableNotification,
|
||||||
ReplyMessageId,
|
ReplyMessageId,
|
||||||
@@ -75,24 +79,35 @@ data class SendInvoice(
|
|||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
@SerialName(photoUrlField)
|
@SerialName(photoUrlField)
|
||||||
var photoUrl: String? = null
|
override var photoUrl: String? = null
|
||||||
private set
|
private set
|
||||||
@SerialName(photoSizeField)
|
@SerialName(photoSizeField)
|
||||||
var photoSize: Long? = null
|
override var photoSize: Long? = null
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@SerialName(photoWidthField)
|
@SerialName(photoWidthField)
|
||||||
var photoWidth: Int? = null
|
override var photoWidth: Int? = null
|
||||||
private set
|
private set
|
||||||
@SerialName(photoHeightField)
|
@SerialName(photoHeightField)
|
||||||
var photoHeight: Int? = null
|
override var photoHeight: Int? = null
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setPhoto(
|
init {
|
||||||
|
suggestedTipAmounts ?.let { _ ->
|
||||||
|
require(suggestedTipAmounts.size in suggestedTipAmountsLimit)
|
||||||
|
maxTipAmount ?.let { _ ->
|
||||||
|
require(
|
||||||
|
suggestedTipAmounts.none { it > maxTipAmount }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setPhoto(
|
||||||
photoUrl: String,
|
photoUrl: String,
|
||||||
photoSize: Long? = null,
|
photoSize: Long?,
|
||||||
photoWidth: Int? = null,
|
photoWidth: Int?,
|
||||||
photoHeight: Int? = null
|
photoHeight: Int?
|
||||||
) {
|
) {
|
||||||
this.photoUrl = photoUrl
|
this.photoUrl = photoUrl
|
||||||
this.photoSize = photoSize
|
this.photoSize = photoSize
|
||||||
@@ -100,7 +115,7 @@ data class SendInvoice(
|
|||||||
this.photoHeight = photoHeight
|
this.photoHeight = photoHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unsetPhoto() {
|
override fun unsetPhoto() {
|
||||||
photoUrl = null
|
photoUrl = null
|
||||||
photoSize = null
|
photoSize = null
|
||||||
photoWidth = null
|
photoWidth = null
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ import kotlinx.serialization.*
|
|||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
|
private inline val ApproximateScheduledCloseInfo.openPeriod
|
||||||
|
get() = openDuration.millisecondsLong.div(1000)
|
||||||
|
private inline val ExactScheduledCloseInfo.closeDate
|
||||||
|
get() = closeDateTime.unixMillisLong.div(1000)
|
||||||
|
|
||||||
private fun checkPollInfo(
|
private fun checkPollInfo(
|
||||||
question: String,
|
question: String,
|
||||||
options: List<String>
|
options: List<String>
|
||||||
@@ -87,7 +92,7 @@ fun Poll.createRequest(
|
|||||||
correctOptionId,
|
correctOptionId,
|
||||||
isAnonymous,
|
isAnonymous,
|
||||||
isClosed,
|
isClosed,
|
||||||
fullEntitiesList(),
|
textSources,
|
||||||
scheduledCloseInfo,
|
scheduledCloseInfo,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
@@ -138,12 +143,23 @@ sealed class SendPoll : SendMessageRequest<ContentMessage<PollContent>>,
|
|||||||
abstract val options: List<String>
|
abstract val options: List<String>
|
||||||
abstract val isAnonymous: Boolean
|
abstract val isAnonymous: Boolean
|
||||||
abstract val isClosed: Boolean
|
abstract val isClosed: Boolean
|
||||||
abstract val closeInfo: ScheduledCloseInfo?
|
|
||||||
abstract val type: String
|
abstract val type: String
|
||||||
|
|
||||||
internal abstract val openPeriod: LongSeconds?
|
internal abstract val openPeriod: LongSeconds?
|
||||||
internal abstract val closeDate: LongSeconds?
|
internal abstract val closeDate: LongSeconds?
|
||||||
|
|
||||||
|
protected val creationDate = DateTime.now()
|
||||||
|
open val closeInfo: ScheduledCloseInfo?
|
||||||
|
get() {
|
||||||
|
val openPeriod = openPeriod
|
||||||
|
val closeDate = closeDate
|
||||||
|
return when {
|
||||||
|
openPeriod != null -> openPeriod.asApproximateScheduledCloseInfo(creationDate)
|
||||||
|
closeDate != null -> closeDate.asExactScheduledCloseInfo
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendPoll"
|
override fun method(): String = "sendPoll"
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
||||||
get() = commonResultDeserializer
|
get() = commonResultDeserializer
|
||||||
@@ -163,8 +179,10 @@ data class SendRegularPoll(
|
|||||||
override val isClosed: Boolean = false,
|
override val isClosed: Boolean = false,
|
||||||
@SerialName(allowsMultipleAnswersField)
|
@SerialName(allowsMultipleAnswersField)
|
||||||
val allowMultipleAnswers: Boolean = false,
|
val allowMultipleAnswers: Boolean = false,
|
||||||
@Transient
|
@SerialName(openPeriodField)
|
||||||
override val closeInfo: ScheduledCloseInfo? = null,
|
override val openPeriod: LongSeconds?= null,
|
||||||
|
@SerialName(closeDateField)
|
||||||
|
override val closeDate: LongSeconds?,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
override val disableNotification: Boolean = false,
|
override val disableNotification: Boolean = false,
|
||||||
@SerialName(replyToMessageIdField)
|
@SerialName(replyToMessageIdField)
|
||||||
@@ -178,20 +196,39 @@ data class SendRegularPoll(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
@SerialName(openPeriodField)
|
|
||||||
override val openPeriod: LongSeconds?
|
|
||||||
= (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.millisecondsLong ?.div(1000)
|
|
||||||
|
|
||||||
@SerialName(closeDateField)
|
|
||||||
override val closeDate: LongSeconds?
|
|
||||||
= (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
checkPollInfo(question, options)
|
checkPollInfo(question, options)
|
||||||
closeInfo ?.checkSendData()
|
closeInfo ?.checkSendData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun SendRegularPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
allowMultipleAnswers: Boolean = false,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = SendRegularPoll(
|
||||||
|
chatId,
|
||||||
|
question,
|
||||||
|
options,
|
||||||
|
isAnonymous,
|
||||||
|
isClosed,
|
||||||
|
allowMultipleAnswers,
|
||||||
|
(closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod,
|
||||||
|
(closeInfo as? ExactScheduledCloseInfo) ?.closeDate,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
fun SendQuizPoll(
|
fun SendQuizPoll(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
question: String,
|
question: String,
|
||||||
@@ -253,6 +290,39 @@ fun SendQuizPoll(
|
|||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
internal fun SendQuizPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
correctOptionId: Int,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
explanation: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
rawEntities: List<RawMessageEntity>? = null,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = SendQuizPoll(
|
||||||
|
chatId,
|
||||||
|
question,
|
||||||
|
options,
|
||||||
|
correctOptionId,
|
||||||
|
isAnonymous,
|
||||||
|
isClosed,
|
||||||
|
explanation,
|
||||||
|
parseMode,
|
||||||
|
rawEntities,
|
||||||
|
(closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod,
|
||||||
|
(closeInfo as? ExactScheduledCloseInfo) ?.closeDate,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendQuizPoll internal constructor(
|
data class SendQuizPoll internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@@ -268,13 +338,15 @@ data class SendQuizPoll internal constructor(
|
|||||||
@SerialName(isClosedField)
|
@SerialName(isClosedField)
|
||||||
override val isClosed: Boolean = false,
|
override val isClosed: Boolean = false,
|
||||||
@SerialName(explanationField)
|
@SerialName(explanationField)
|
||||||
override val explanation: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(explanationParseModeField)
|
@SerialName(explanationParseModeField)
|
||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(explanationEntitiesField)
|
@SerialName(explanationEntitiesField)
|
||||||
private val rawEntities: List<RawMessageEntity>? = null,
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
@Transient
|
@SerialName(openPeriodField)
|
||||||
override val closeInfo: ScheduledCloseInfo? = null,
|
override val openPeriod: LongSeconds? = null,
|
||||||
|
@SerialName(closeDateField)
|
||||||
|
override val closeDate: LongSeconds? = null,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
override val disableNotification: Boolean = false,
|
override val disableNotification: Boolean = false,
|
||||||
@SerialName(replyToMessageIdField)
|
@SerialName(replyToMessageIdField)
|
||||||
@@ -283,22 +355,14 @@ data class SendQuizPoll internal constructor(
|
|||||||
override val allowSendingWithoutReply: Boolean? = null,
|
override val allowSendingWithoutReply: Boolean? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendPoll(), ExplainedOutput {
|
) : SendPoll(), ExplainedOutput, TextedOutput {
|
||||||
override val type: String = quizPollType
|
override val type: String = quizPollType
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(explanation ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SerialName(openPeriodField)
|
|
||||||
override val openPeriod: LongSeconds?
|
|
||||||
= (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.millisecondsLong ?.div(1000)
|
|
||||||
|
|
||||||
@SerialName(closeDateField)
|
|
||||||
override val closeDate: LongSeconds?
|
|
||||||
= (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
checkPollInfo(question, options)
|
checkPollInfo(question, options)
|
||||||
closeInfo ?.checkSendData()
|
closeInfo ?.checkSendData()
|
||||||
@@ -307,9 +371,9 @@ data class SendQuizPoll internal constructor(
|
|||||||
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
||||||
"value is $correctOptionId")
|
"value is $correctOptionId")
|
||||||
}
|
}
|
||||||
if (explanation != null && explanation.length !in explanationLimit) {
|
if (text != null && text.length !in explanationLimit) {
|
||||||
error("Quiz poll explanation size must be in range $explanationLimit," +
|
error("Quiz poll explanation size must be in range $explanationLimit," +
|
||||||
"but actual explanation contains ${explanation.length} symbols")
|
"but actual explanation contains ${text.length} symbols")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,15 @@ private fun correctWebhookUrl(sourceUrl: String) = if (sourceUrl.contains("://")
|
|||||||
"https://$sourceUrl"
|
"https://$sourceUrl"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SetWebhook(
|
sealed class SetWebhookRequest : Request<Boolean>
|
||||||
|
class MultipartSetWebhookRequest(
|
||||||
url: String,
|
url: String,
|
||||||
certificate: MultipartFile,
|
certificate: MultipartFile,
|
||||||
ipAddress: String? = null,
|
ipAddress: String? = null,
|
||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null,
|
allowedUpdates: List<String>? = null,
|
||||||
dropPendingUpdates: Boolean? = null
|
dropPendingUpdates: Boolean? = null
|
||||||
): MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean> = MultipartRequestImpl(
|
) : SetWebhookRequest(), MultipartRequest<Boolean> by MultipartRequestImpl(
|
||||||
SetWebhook(
|
SetWebhook(
|
||||||
correctWebhookUrl(url),
|
correctWebhookUrl(url),
|
||||||
null as String?,
|
null as String?,
|
||||||
@@ -32,6 +33,22 @@ fun SetWebhook(
|
|||||||
mapOf(certificateField to certificate)
|
mapOf(certificateField to certificate)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun SetWebhook(
|
||||||
|
url: String,
|
||||||
|
certificate: MultipartFile,
|
||||||
|
ipAddress: String? = null,
|
||||||
|
maxAllowedConnections: Int? = null,
|
||||||
|
allowedUpdates: List<String>? = null,
|
||||||
|
dropPendingUpdates: Boolean? = null
|
||||||
|
): MultipartSetWebhookRequest = MultipartSetWebhookRequest(
|
||||||
|
correctWebhookUrl(url),
|
||||||
|
certificate,
|
||||||
|
ipAddress,
|
||||||
|
maxAllowedConnections,
|
||||||
|
allowedUpdates,
|
||||||
|
dropPendingUpdates
|
||||||
|
)
|
||||||
|
|
||||||
fun SetWebhook(
|
fun SetWebhook(
|
||||||
url: String,
|
url: String,
|
||||||
certificate: FileId,
|
certificate: FileId,
|
||||||
@@ -63,7 +80,7 @@ fun SetWebhook(
|
|||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null,
|
allowedUpdates: List<String>? = null,
|
||||||
dropPendingUpdates: Boolean? = null
|
dropPendingUpdates: Boolean? = null
|
||||||
): Request<Boolean> = when (certificate) {
|
) = when (certificate) {
|
||||||
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
||||||
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
||||||
}
|
}
|
||||||
@@ -82,7 +99,7 @@ fun SetWebhook(
|
|||||||
maxAllowedConnections: Int? = null,
|
maxAllowedConnections: Int? = null,
|
||||||
allowedUpdates: List<String>? = null,
|
allowedUpdates: List<String>? = null,
|
||||||
dropPendingUpdates: Boolean? = null
|
dropPendingUpdates: Boolean? = null
|
||||||
): Request<Boolean> = SetWebhook(
|
) = SetWebhook(
|
||||||
correctWebhookUrl(url),
|
correctWebhookUrl(url),
|
||||||
null,
|
null,
|
||||||
ipAddress,
|
ipAddress,
|
||||||
@@ -112,7 +129,7 @@ data class SetWebhook internal constructor(
|
|||||||
val allowedUpdates: List<String>? = null,
|
val allowedUpdates: List<String>? = null,
|
||||||
@SerialName(dropPendingUpdatesField)
|
@SerialName(dropPendingUpdatesField)
|
||||||
val dropPendingUpdates: Boolean? = null
|
val dropPendingUpdates: Boolean? = null
|
||||||
) : DataRequest<Boolean> {
|
) : SetWebhookRequest(), DataRequest<Boolean> {
|
||||||
override fun method(): String = "setWebhook"
|
override fun method(): String = "setWebhook"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = Boolean.serializer()
|
get() = Boolean.serializer()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.common.Warning
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
@@ -17,9 +18,20 @@ data class ChatId(
|
|||||||
val chatId: Identifier
|
val chatId: Identifier
|
||||||
) : ChatIdentifier()
|
) : ChatIdentifier()
|
||||||
|
|
||||||
|
/**
|
||||||
val ChatId.link: String
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
get() = "tg://user?id=$chatId"
|
*/
|
||||||
|
@Warning("This API have restrictions in Telegram System")
|
||||||
|
val Identifier.link: String
|
||||||
|
get() = "tg://user?id=$this"
|
||||||
|
/**
|
||||||
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
|
*/
|
||||||
|
@Warning("This API have restrictions in Telegram System")
|
||||||
|
val UserId.link: String
|
||||||
|
get() = chatId.link
|
||||||
|
val User.link: String
|
||||||
|
get() = id.link
|
||||||
|
|
||||||
typealias UserId = ChatId
|
typealias UserId = ChatId
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
private data class RawChatInviteLink(
|
||||||
|
@SerialName(inviteLinkField)
|
||||||
|
val inviteLink: String,
|
||||||
|
@SerialName(creatorField)
|
||||||
|
val creator: User,
|
||||||
|
@SerialName(isPrimaryField)
|
||||||
|
val isPrimary: Boolean,
|
||||||
|
@SerialName(isRevokedField)
|
||||||
|
val isRevoked: Boolean,
|
||||||
|
@SerialName(expireDateField)
|
||||||
|
val expirationDateTime: TelegramDate? = null,
|
||||||
|
@SerialName(memberLimitField)
|
||||||
|
val membersLimit: MembersLimit ?= null
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun ChatInviteLink.toRawChatInviteLink() = RawChatInviteLink(
|
||||||
|
inviteLink,
|
||||||
|
creator,
|
||||||
|
isPrimary,
|
||||||
|
isRevoked,
|
||||||
|
expirationDateTime ?.toTelegramDate(),
|
||||||
|
membersLimit
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable(ChatInviteLinkSerializer::class)
|
||||||
|
sealed class ChatInviteLink {
|
||||||
|
abstract val inviteLink: String
|
||||||
|
abstract val creator: User
|
||||||
|
abstract val isPrimary: Boolean
|
||||||
|
abstract val isRevoked: Boolean
|
||||||
|
abstract val expirationDateTime: DateTime?
|
||||||
|
abstract val membersLimit: MembersLimit?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PrimaryInviteLink(
|
||||||
|
@SerialName(inviteLinkField)
|
||||||
|
override val inviteLink: String,
|
||||||
|
@SerialName(creatorField)
|
||||||
|
override val creator: User,
|
||||||
|
@SerialName(isRevokedField)
|
||||||
|
override val isRevoked: Boolean = false,
|
||||||
|
@SerialName(expireDateField)
|
||||||
|
private val expireDate: TelegramDate? = null,
|
||||||
|
@SerialName(memberLimitField)
|
||||||
|
override val membersLimit: MembersLimit? = null
|
||||||
|
) : ChatInviteLink() {
|
||||||
|
override val isPrimary: Boolean
|
||||||
|
get() = true
|
||||||
|
override val expirationDateTime: DateTime?
|
||||||
|
get() = expireDate ?.asDate
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CommonInviteLink(
|
||||||
|
@SerialName(inviteLinkField)
|
||||||
|
override val inviteLink: String,
|
||||||
|
@SerialName(creatorField)
|
||||||
|
override val creator: User,
|
||||||
|
@SerialName(isRevokedField)
|
||||||
|
override val isRevoked: Boolean = false,
|
||||||
|
@SerialName(expireDateField)
|
||||||
|
private val expireDate: TelegramDate? = null,
|
||||||
|
@SerialName(memberLimitField)
|
||||||
|
override val membersLimit: MembersLimit? = null
|
||||||
|
) : ChatInviteLink() {
|
||||||
|
override val isPrimary: Boolean
|
||||||
|
get() = false
|
||||||
|
override val expirationDateTime: DateTime?
|
||||||
|
get() = expireDate ?.asDate
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializer(ChatInviteLink::class)
|
||||||
|
object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = RawChatInviteLink.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): ChatInviteLink {
|
||||||
|
val deserializedRaw = RawChatInviteLink.serializer().deserialize(decoder)
|
||||||
|
return deserializedRaw.run {
|
||||||
|
when {
|
||||||
|
deserializedRaw.isPrimary -> PrimaryInviteLink(
|
||||||
|
inviteLink, creator, isRevoked, expirationDateTime, membersLimit
|
||||||
|
)
|
||||||
|
else -> CommonInviteLink(
|
||||||
|
inviteLink, creator, isRevoked, expirationDateTime, membersLimit
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: ChatInviteLink) {
|
||||||
|
RawChatInviteLink.serializer().serialize(encoder, value.toRawChatInviteLink())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,41 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember
|
package dev.inmo.tgbotapi.types.ChatMember
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
|
||||||
import dev.inmo.tgbotapi.types.User
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
data class AdministratorChatMemberImpl(
|
data class AdministratorChatMemberImpl(
|
||||||
|
@SerialName(userField)
|
||||||
override val user: User,
|
override val user: User,
|
||||||
override val canBeEdited: Boolean,
|
@SerialName(canBeEditedField)
|
||||||
override val canChangeInfo: Boolean,
|
override val canBeEdited: Boolean = false,
|
||||||
override val canPostMessages: Boolean,
|
@SerialName(canChangeInfoField)
|
||||||
override val canEditMessages: Boolean,
|
override val canChangeInfo: Boolean = false,
|
||||||
override val canRemoveMessages: Boolean,
|
@SerialName(canPostMessagesField)
|
||||||
override val canInviteUsers: Boolean,
|
override val canPostMessages: Boolean = false,
|
||||||
override val canRestrictMembers: Boolean,
|
@SerialName(canEditMessagesField)
|
||||||
override val canPinMessages: Boolean,
|
override val canEditMessages: Boolean = false,
|
||||||
override val canPromoteMembers: Boolean,
|
@SerialName(canDeleteMessagesField)
|
||||||
override val isAnonymous: Boolean,
|
override val canRemoveMessages: Boolean = false,
|
||||||
override val customTitle: String?
|
@SerialName(canInviteUsersField)
|
||||||
) : AdministratorChatMember
|
override val canInviteUsers: Boolean = false,
|
||||||
|
@SerialName(canRestrictMembersField)
|
||||||
|
override val canRestrictMembers: Boolean = false,
|
||||||
|
@SerialName(canPinMessagesField)
|
||||||
|
override val canPinMessages: Boolean = false,
|
||||||
|
@SerialName(canPromoteMembersField)
|
||||||
|
override val canPromoteMembers: Boolean = false,
|
||||||
|
@SerialName(canManageVoiceChatsField)
|
||||||
|
override val canManageVoiceChats: Boolean = false,
|
||||||
|
@SerialName(canManageChatField)
|
||||||
|
override val canManageChat: Boolean = false,
|
||||||
|
@SerialName(isAnonymousField)
|
||||||
|
override val isAnonymous: Boolean = false,
|
||||||
|
@SerialName(customTitleField)
|
||||||
|
override val customTitle: String? = null
|
||||||
|
) : AdministratorChatMember {
|
||||||
|
@SerialName(statusField)
|
||||||
|
@Required
|
||||||
|
private val type: String = "administrator"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,20 +1,40 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember
|
package dev.inmo.tgbotapi.types.ChatMember
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
|
||||||
import dev.inmo.tgbotapi.types.User
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
data class CreatorChatMember(
|
data class CreatorChatMember(
|
||||||
override val user: User,
|
override val user: User,
|
||||||
override val isAnonymous: Boolean,
|
@SerialName(isAnonymousField)
|
||||||
override val customTitle: String?
|
override val isAnonymous: Boolean = false,
|
||||||
|
@SerialName(customTitleField)
|
||||||
|
override val customTitle: String? = null
|
||||||
) : AdministratorChatMember {
|
) : AdministratorChatMember {
|
||||||
|
@Transient
|
||||||
override val canBeEdited: Boolean = true
|
override val canBeEdited: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canChangeInfo: Boolean = true
|
override val canChangeInfo: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canPostMessages: Boolean = true
|
override val canPostMessages: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canEditMessages: Boolean = true
|
override val canEditMessages: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canRemoveMessages: Boolean = true
|
override val canRemoveMessages: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canInviteUsers: Boolean = true
|
override val canInviteUsers: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canRestrictMembers: Boolean = true
|
override val canRestrictMembers: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canPinMessages: Boolean = true
|
override val canPinMessages: Boolean = true
|
||||||
|
@Transient
|
||||||
override val canPromoteMembers: Boolean = true
|
override val canPromoteMembers: Boolean = true
|
||||||
|
@Transient
|
||||||
|
override val canManageVoiceChats: Boolean = true
|
||||||
|
@Transient
|
||||||
|
override val canManageChat: Boolean = true
|
||||||
|
@SerialName(statusField)
|
||||||
|
@Required
|
||||||
|
private val type: String = "creator"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember
|
package dev.inmo.tgbotapi.types.ChatMember
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember
|
||||||
import dev.inmo.tgbotapi.types.TelegramDate
|
import kotlinx.serialization.*
|
||||||
import dev.inmo.tgbotapi.types.User
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
data class KickedChatMember(
|
data class KickedChatMember(
|
||||||
|
@SerialName(userField)
|
||||||
override val user: User,
|
override val user: User,
|
||||||
override val untilDate: TelegramDate?
|
@SerialName(untilDateField)
|
||||||
) : BannedChatMember
|
override val untilDate: TelegramDate? = null
|
||||||
|
) : BannedChatMember {
|
||||||
|
@SerialName(statusField)
|
||||||
|
@Required
|
||||||
|
private val type: String = "kicked"
|
||||||
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember
|
package dev.inmo.tgbotapi.types.ChatMember
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
||||||
import dev.inmo.tgbotapi.types.User
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
data class LeftChatMember(override val user: User) :
|
@Serializable
|
||||||
ChatMember
|
data class LeftChatMember(@SerialName(userField) override val user: User) : ChatMember {
|
||||||
|
@SerialName(statusField)
|
||||||
|
@Required
|
||||||
|
private val type: String = "left"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember
|
package dev.inmo.tgbotapi.types.ChatMember
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
||||||
import dev.inmo.tgbotapi.types.User
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
data class MemberChatMember(override val user: User) :
|
@Serializable
|
||||||
ChatMember
|
data class MemberChatMember(@SerialName(userField) override val user: User) : ChatMember {
|
||||||
|
@SerialName(statusField)
|
||||||
|
@Required
|
||||||
|
private val type: String = "member"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
internal data class RawChatMember(
|
|
||||||
val user: User,
|
|
||||||
private val status: String,
|
|
||||||
private val until_date: TelegramDate? = null,
|
|
||||||
@SerialName(canBeEditedField)
|
|
||||||
private val canBeEdited: Boolean = false,
|
|
||||||
@SerialName(canChangeInfoField)
|
|
||||||
private val canChangeInfo: Boolean = false,
|
|
||||||
@SerialName(canPostMessagesField)
|
|
||||||
private val canPostMessages: Boolean = false,
|
|
||||||
@SerialName(canEditMessagesField)
|
|
||||||
private val canEditMessages: Boolean = false,
|
|
||||||
@SerialName(canDeleteMessagesField)
|
|
||||||
private val canDeleteMessages: Boolean = false,
|
|
||||||
@SerialName(canInviteUsersField)
|
|
||||||
private val canInviteUsers: Boolean = false,
|
|
||||||
@SerialName(canRestrictMembersField)
|
|
||||||
private val canRestrictMembers: Boolean = false,
|
|
||||||
@SerialName(canPinMessagesField)
|
|
||||||
private val canPinMessages: Boolean = false,
|
|
||||||
@SerialName(canPromoteMembersField)
|
|
||||||
private val canPromoteMembers: Boolean = false,
|
|
||||||
@SerialName(isMemberField)
|
|
||||||
private val isMember: Boolean = false,
|
|
||||||
@SerialName(canSendMessagesField)
|
|
||||||
private val canSendMessages: Boolean = false,
|
|
||||||
@SerialName(canSendMediaMessagesField)
|
|
||||||
private val canSendMediaMessages: Boolean = false,
|
|
||||||
@SerialName(canSendPollsField)
|
|
||||||
private val canSendPolls: Boolean = false,
|
|
||||||
@SerialName(canSendOtherMessagesField)
|
|
||||||
private val canSendOtherMessages: Boolean = false,
|
|
||||||
@SerialName(canAddWebPagePreviewsField)
|
|
||||||
private val canAddWebPagePreviews: Boolean = false,
|
|
||||||
@SerialName(isAnonymousField)
|
|
||||||
private val isAnonymous: Boolean = false,
|
|
||||||
@SerialName(customTitleField)
|
|
||||||
private val customTitle: String? = null
|
|
||||||
) {
|
|
||||||
val asChatMember: ChatMember by lazy {
|
|
||||||
when (status) {
|
|
||||||
"creator" -> CreatorChatMember(user, isAnonymous, customTitle)
|
|
||||||
"administrator" -> AdministratorChatMemberImpl(
|
|
||||||
user,
|
|
||||||
canBeEdited,
|
|
||||||
canChangeInfo,
|
|
||||||
canPostMessages,
|
|
||||||
canEditMessages,
|
|
||||||
canDeleteMessages,
|
|
||||||
canInviteUsers,
|
|
||||||
canRestrictMembers,
|
|
||||||
canPinMessages,
|
|
||||||
canPromoteMembers,
|
|
||||||
isAnonymous,
|
|
||||||
customTitle
|
|
||||||
)
|
|
||||||
"member" -> MemberChatMember(user)
|
|
||||||
"restricted" -> RestrictedChatMember(
|
|
||||||
user,
|
|
||||||
until_date,
|
|
||||||
isMember,
|
|
||||||
canSendMessages,
|
|
||||||
canSendMediaMessages,
|
|
||||||
canSendPolls,
|
|
||||||
canSendOtherMessages,
|
|
||||||
canAddWebPagePreviews,
|
|
||||||
canChangeInfo,
|
|
||||||
canInviteUsers,
|
|
||||||
canPinMessages
|
|
||||||
)
|
|
||||||
"left" -> LeftChatMember(user)
|
|
||||||
"kicked" -> KickedChatMember(
|
|
||||||
user,
|
|
||||||
until_date
|
|
||||||
)
|
|
||||||
else -> throw IllegalStateException("Can't understand type of user: $status")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,36 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember
|
package dev.inmo.tgbotapi.types.ChatMember
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.SpecialRightsChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.SpecialRightsChatMember
|
||||||
import dev.inmo.tgbotapi.types.TelegramDate
|
import kotlinx.serialization.*
|
||||||
import dev.inmo.tgbotapi.types.User
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
data class RestrictedChatMember(
|
data class RestrictedChatMember(
|
||||||
|
@SerialName(userField)
|
||||||
override val user: User,
|
override val user: User,
|
||||||
override val untilDate: TelegramDate?,
|
@SerialName(untilDateField)
|
||||||
val isMember: Boolean,
|
override val untilDate: TelegramDate? = null,
|
||||||
val canSendMessages: Boolean,
|
@SerialName(isMemberField)
|
||||||
val canSendMediaMessages: Boolean,
|
val isMember: Boolean = false,
|
||||||
val canSendPolls: Boolean,
|
@SerialName(canSendMessagesField)
|
||||||
val canSendOtherMessages: Boolean,
|
val canSendMessages: Boolean = false,
|
||||||
val canAddWebpagePreviews: Boolean,
|
@SerialName(canSendMediaMessagesField)
|
||||||
override val canChangeInfo: Boolean,
|
val canSendMediaMessages: Boolean = false,
|
||||||
override val canInviteUsers: Boolean,
|
@SerialName(canSendPollsField)
|
||||||
override val canPinMessages: Boolean
|
val canSendPolls: Boolean = false,
|
||||||
) : BannedChatMember, SpecialRightsChatMember
|
@SerialName(canSendOtherMessagesField)
|
||||||
|
val canSendOtherMessages: Boolean = false,
|
||||||
|
@SerialName(canAddWebPagePreviewsField)
|
||||||
|
val canAddWebpagePreviews: Boolean = false,
|
||||||
|
@SerialName(canChangeInfoField)
|
||||||
|
override val canChangeInfo: Boolean = false,
|
||||||
|
@SerialName(canInviteUsersField)
|
||||||
|
override val canInviteUsers: Boolean = false,
|
||||||
|
@SerialName(canPinMessagesField)
|
||||||
|
override val canPinMessages: Boolean = false
|
||||||
|
) : BannedChatMember, SpecialRightsChatMember {
|
||||||
|
@SerialName(statusField)
|
||||||
|
@Required
|
||||||
|
private val type: String = "restricted"
|
||||||
|
}
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
@Serializable(AdministratorChatMemberSerializer::class)
|
||||||
interface AdministratorChatMember : SpecialRightsChatMember {
|
interface AdministratorChatMember : SpecialRightsChatMember {
|
||||||
val canBeEdited: Boolean
|
val canBeEdited: Boolean
|
||||||
val canPostMessages: Boolean
|
val canPostMessages: Boolean
|
||||||
@@ -7,6 +14,17 @@ interface AdministratorChatMember : SpecialRightsChatMember {
|
|||||||
val canRemoveMessages: Boolean
|
val canRemoveMessages: Boolean
|
||||||
val canRestrictMembers: Boolean
|
val canRestrictMembers: Boolean
|
||||||
val canPromoteMembers: Boolean
|
val canPromoteMembers: Boolean
|
||||||
|
val canManageVoiceChats: Boolean
|
||||||
|
val canManageChat: Boolean
|
||||||
val isAnonymous: Boolean
|
val isAnonymous: Boolean
|
||||||
val customTitle: String?
|
val customTitle: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializer(AdministratorChatMember::class)
|
||||||
|
@RiskFeature
|
||||||
|
object AdministratorChatMemberSerializer : KSerializer<AdministratorChatMember> {
|
||||||
|
override val descriptor: SerialDescriptor = ChatMemberSerializer.descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): AdministratorChatMember = ChatMemberSerializer.deserialize(decoder) as AdministratorChatMember
|
||||||
|
override fun serialize(encoder: Encoder, value: AdministratorChatMember) = ChatMemberSerializer.serialize(encoder, value)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.types.UntilDate
|
import dev.inmo.tgbotapi.CommonAbstracts.types.UntilDate
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable(ChatMemberSerializer::class)
|
||||||
interface BannedChatMember : ChatMember, UntilDate
|
interface BannedChatMember : ChatMember, UntilDate
|
||||||
@@ -1,27 +1,48 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.RawChatMember
|
import dev.inmo.tgbotapi.types.ChatMember.*
|
||||||
import dev.inmo.tgbotapi.types.User
|
import dev.inmo.tgbotapi.types.User
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import dev.inmo.tgbotapi.types.statusField
|
||||||
import kotlinx.serialization.KSerializer
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
|
||||||
|
@Serializable(ChatMemberSerializer::class)
|
||||||
interface ChatMember {
|
interface ChatMember {
|
||||||
val user: User
|
val user: User
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object AdministratorChatMemberSerializerWithoutDeserialization : KSerializer<AdministratorChatMember> {
|
@Serializer(ChatMember::class)
|
||||||
override val descriptor: SerialDescriptor = ChatMemberDeserializationStrategy.descriptor
|
@RiskFeature
|
||||||
|
object ChatMemberSerializer : KSerializer<ChatMember> {
|
||||||
|
override val descriptor: SerialDescriptor = JsonObject.serializer().descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): AdministratorChatMember
|
override fun deserialize(decoder: Decoder): ChatMember {
|
||||||
= ChatMemberDeserializationStrategy.deserialize(decoder) as AdministratorChatMember
|
val json = JsonObject.serializer().deserialize(decoder)
|
||||||
override fun serialize(encoder: Encoder, value: AdministratorChatMember) = throw UnsupportedOperationException()
|
return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) {
|
||||||
}
|
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.serializer(), json)
|
||||||
|
"administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json)
|
||||||
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
"member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMember.serializer(), json)
|
||||||
override val descriptor: SerialDescriptor = RawChatMember.serializer().descriptor
|
"restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json)
|
||||||
|
"left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMember.serializer(), json)
|
||||||
override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember
|
"kicked" -> nonstrictJsonFormat.decodeFromJsonElement(KickedChatMember.serializer(), json)
|
||||||
|
else -> error("Unknown type of chat member in json: $json")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: ChatMember) {
|
||||||
|
when (value) {
|
||||||
|
is CreatorChatMember -> CreatorChatMember.serializer()
|
||||||
|
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer()
|
||||||
|
is MemberChatMember -> MemberChatMember.serializer()
|
||||||
|
is RestrictedChatMember -> RestrictedChatMember.serializer()
|
||||||
|
is LeftChatMember -> LeftChatMember.serializer()
|
||||||
|
is KickedChatMember -> KickedChatMember.serializer()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
package dev.inmo.tgbotapi.types.ChatMember.abstracts
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable(ChatMemberSerializer::class)
|
||||||
interface SpecialRightsChatMember : ChatMember {
|
interface SpecialRightsChatMember : ChatMember {
|
||||||
val canChangeInfo: Boolean
|
val canChangeInfo: Boolean
|
||||||
val canInviteUsers: Boolean
|
val canInviteUsers: Boolean
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
||||||
|
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ChatMemberUpdated(
|
||||||
|
@SerialName(chatField)
|
||||||
|
val chat: Chat,
|
||||||
|
@SerialName(fromField)
|
||||||
|
val user: User,
|
||||||
|
@SerialName(dateField)
|
||||||
|
val date: TelegramDate,
|
||||||
|
@SerialName(oldChatMemberField)
|
||||||
|
val oldChatMemberState: ChatMember,
|
||||||
|
@SerialName(newChatMemberField)
|
||||||
|
val newChatMemberState: ChatMember,
|
||||||
|
@SerialName(inviteLinkField)
|
||||||
|
val inviteLink: ChatInviteLink? = null
|
||||||
|
)
|
||||||
@@ -26,9 +26,12 @@ typealias FoursquareId = String
|
|||||||
typealias FoursquareType = String
|
typealias FoursquareType = String
|
||||||
typealias GooglePlaceId = String
|
typealias GooglePlaceId = String
|
||||||
typealias GooglePlaceType = String
|
typealias GooglePlaceType = String
|
||||||
|
typealias MembersLimit = Int
|
||||||
|
|
||||||
typealias Seconds = Int
|
typealias Seconds = Int
|
||||||
|
typealias MilliSeconds = Long
|
||||||
typealias LongSeconds = Long
|
typealias LongSeconds = Long
|
||||||
|
typealias UnixTimeStamp = LongSeconds
|
||||||
|
|
||||||
typealias Meters = Float
|
typealias Meters = Float
|
||||||
typealias Degrees = Int
|
typealias Degrees = Int
|
||||||
@@ -60,10 +63,7 @@ val inlineQueryAnswerResultsLimit = 0 .. 50
|
|||||||
|
|
||||||
val customTitleLength = 0 .. 16
|
val customTitleLength = 0 .. 16
|
||||||
|
|
||||||
val dartsAndCubeDiceResultLimit = 1 .. 6
|
val dartsCubeAndBowlingDiceResultLimit = 1 .. 6
|
||||||
@Deprecated("Renamed", ReplaceWith("dartsAndCubeDiceResultLimit", "dev.inmo.tgbotapi.types.dartsAndCubeDiceResultLimit"))
|
|
||||||
val diceResultLimit
|
|
||||||
get() = dartsAndCubeDiceResultLimit
|
|
||||||
val basketballAndFootballDiceResultLimit = 1 .. 5
|
val basketballAndFootballDiceResultLimit = 1 .. 5
|
||||||
val slotMachineDiceResultLimit = 1 .. 64
|
val slotMachineDiceResultLimit = 1 .. 64
|
||||||
|
|
||||||
@@ -78,6 +78,12 @@ val explanationLimit = 0 .. 200
|
|||||||
|
|
||||||
val openPeriodPollSecondsLimit = 5 .. 600
|
val openPeriodPollSecondsLimit = 5 .. 600
|
||||||
|
|
||||||
|
val membersLimit = 1 .. 99999
|
||||||
|
|
||||||
|
val suggestedTipAmountsLimit = 1 .. 4
|
||||||
|
|
||||||
|
const val botActionActualityTime: Seconds = 5
|
||||||
|
|
||||||
// Made as lazy for correct work in K/JS
|
// Made as lazy for correct work in K/JS
|
||||||
val telegramInlineModeGifPermittedMimeTypes by lazy {
|
val telegramInlineModeGifPermittedMimeTypes by lazy {
|
||||||
listOf(
|
listOf(
|
||||||
@@ -125,7 +131,7 @@ const val callbackQueryIdField = "callback_query_id"
|
|||||||
const val inlineQueryIdField = "inline_query_id"
|
const val inlineQueryIdField = "inline_query_id"
|
||||||
const val inlineKeyboardField = "inline_keyboard"
|
const val inlineKeyboardField = "inline_keyboard"
|
||||||
const val showAlertField = "show_alert"
|
const val showAlertField = "show_alert"
|
||||||
const val cachedTimeField = "cached_time"
|
const val cacheTimeField = "cache_time"
|
||||||
const val foursquareIdField = "foursquare_id"
|
const val foursquareIdField = "foursquare_id"
|
||||||
const val foursquareTypeField = "foursquare_type"
|
const val foursquareTypeField = "foursquare_type"
|
||||||
const val googlePlaceIdField = "google_place_id"
|
const val googlePlaceIdField = "google_place_id"
|
||||||
@@ -164,6 +170,12 @@ const val optionIdsField = "option_ids"
|
|||||||
const val ipAddressField = "ip_address"
|
const val ipAddressField = "ip_address"
|
||||||
const val linkedChatIdField = "linked_chat_id"
|
const val linkedChatIdField = "linked_chat_id"
|
||||||
const val horizontalAccuracyField = "horizontal_accuracy"
|
const val horizontalAccuracyField = "horizontal_accuracy"
|
||||||
|
const val revokeMessagesField = "revoke_messages"
|
||||||
|
const val messageAutoDeleteTimeField = "message_auto_delete_time"
|
||||||
|
const val isPrimaryField = "is_primary"
|
||||||
|
const val isRevokedField = "is_revoked"
|
||||||
|
const val expireDateField = "expire_date"
|
||||||
|
const val memberLimitField = "member_limit"
|
||||||
|
|
||||||
const val requestContactField = "request_contact"
|
const val requestContactField = "request_contact"
|
||||||
const val requestLocationField = "request_location"
|
const val requestLocationField = "request_location"
|
||||||
@@ -231,6 +243,7 @@ const val canSendPollsField = "can_send_polls"
|
|||||||
const val canAddWebPagePreviewsField = "can_add_web_page_previews"
|
const val canAddWebPagePreviewsField = "can_add_web_page_previews"
|
||||||
const val canSetStickerSetField = "can_set_sticker_set"
|
const val canSetStickerSetField = "can_set_sticker_set"
|
||||||
|
|
||||||
|
const val statusField = "status"
|
||||||
const val canBeEditedField = "can_be_edited"
|
const val canBeEditedField = "can_be_edited"
|
||||||
const val canChangeInfoField = "can_change_info"
|
const val canChangeInfoField = "can_change_info"
|
||||||
const val canPostMessagesField = "can_post_messages"
|
const val canPostMessagesField = "can_post_messages"
|
||||||
@@ -240,8 +253,12 @@ const val canInviteUsersField = "can_invite_users"
|
|||||||
const val canRestrictMembersField = "can_restrict_members"
|
const val canRestrictMembersField = "can_restrict_members"
|
||||||
const val canPinMessagesField = "can_pin_messages"
|
const val canPinMessagesField = "can_pin_messages"
|
||||||
const val canPromoteMembersField = "can_promote_members"
|
const val canPromoteMembersField = "can_promote_members"
|
||||||
|
const val canManageVoiceChatsField = "can_manage_voice_chats"
|
||||||
|
const val canManageChatField = "can_manage_chat"
|
||||||
const val pngStickerField = "png_sticker"
|
const val pngStickerField = "png_sticker"
|
||||||
const val tgsStickerField = "tgs_sticker"
|
const val tgsStickerField = "tgs_sticker"
|
||||||
|
const val oldChatMemberField = "old_chat_member"
|
||||||
|
const val newChatMemberField = "new_chat_member"
|
||||||
|
|
||||||
const val okField = "ok"
|
const val okField = "ok"
|
||||||
const val captionField = "caption"
|
const val captionField = "caption"
|
||||||
@@ -293,12 +310,17 @@ const val payField = "pay"
|
|||||||
const val permissionsField = "permissions"
|
const val permissionsField = "permissions"
|
||||||
const val typeField = "type"
|
const val typeField = "type"
|
||||||
const val valueField = "value"
|
const val valueField = "value"
|
||||||
|
const val creatorField = "creator"
|
||||||
|
|
||||||
const val pointField = "point"
|
const val pointField = "point"
|
||||||
const val xShiftField = "x_shift"
|
const val xShiftField = "x_shift"
|
||||||
const val yShiftField = "y_shift"
|
const val yShiftField = "y_shift"
|
||||||
const val scaleField = "scale"
|
const val scaleField = "scale"
|
||||||
|
|
||||||
|
const val maxTipAmountField = "max_tip_amount"
|
||||||
|
const val suggestedTipAmountsField = "suggested_tip_amounts"
|
||||||
|
const val chatTypeField = "chat_type"
|
||||||
|
|
||||||
const val explanationEntitiesField = "explanation_entities"
|
const val explanationEntitiesField = "explanation_entities"
|
||||||
const val explanationParseModeField = "explanation_parse_mode"
|
const val explanationParseModeField = "explanation_parse_mode"
|
||||||
const val openPeriodField = "open_period"
|
const val openPeriodField = "open_period"
|
||||||
@@ -332,6 +354,8 @@ const val telegramPaymentChargeIdField = "telegram_payment_charge_id"
|
|||||||
const val providerPaymentChargeIdField = "provider_payment_charge_id"
|
const val providerPaymentChargeIdField = "provider_payment_charge_id"
|
||||||
const val providerTokenField = "provider_token"
|
const val providerTokenField = "provider_token"
|
||||||
const val providerDataField = "provider_data"
|
const val providerDataField = "provider_data"
|
||||||
|
const val usersField = "users"
|
||||||
|
const val startDateField = "start_date"
|
||||||
|
|
||||||
const val requireNameField = "need_name"
|
const val requireNameField = "need_name"
|
||||||
const val requirePhoneNumberField = "need_phone_number"
|
const val requirePhoneNumberField = "need_phone_number"
|
||||||
@@ -358,3 +382,39 @@ const val forceField = "force"
|
|||||||
|
|
||||||
const val regularPollType = "regular"
|
const val regularPollType = "regular"
|
||||||
const val quizPollType = "quiz"
|
const val quizPollType = "quiz"
|
||||||
|
|
||||||
|
const val dataField = "data"
|
||||||
|
const val credentialsField = "credentials"
|
||||||
|
const val hashField = "hash"
|
||||||
|
const val translationField = "translation"
|
||||||
|
const val translationFileField = "translation_file"
|
||||||
|
const val fileField = "file"
|
||||||
|
const val filesField = "files"
|
||||||
|
const val translationFilesField = "translation_files"
|
||||||
|
const val frontSideField = "front_side"
|
||||||
|
const val reverseSideField = "reverse_side"
|
||||||
|
const val selfieField = "selfie"
|
||||||
|
const val secretField = "secret"
|
||||||
|
|
||||||
|
const val errorsField = "errors"
|
||||||
|
const val sourceField = "source"
|
||||||
|
const val fieldNameField = "field_name"
|
||||||
|
const val dataHashField = "data_hash"
|
||||||
|
const val fileHashField = "file_hash"
|
||||||
|
const val fileHashesField = "file_hashes"
|
||||||
|
const val messageField = "message"
|
||||||
|
const val unspecifiedField = "unspecified"
|
||||||
|
|
||||||
|
const val secureDataField = "secure_data"
|
||||||
|
const val nonceField = "nonce"
|
||||||
|
|
||||||
|
const val personalDetailsField = "personal_details"
|
||||||
|
const val passportField = "passport"
|
||||||
|
const val internalPassportField = "internal_passport"
|
||||||
|
const val driverLicenseField = "driver_license"
|
||||||
|
const val identityCardField = "identity_card"
|
||||||
|
const val utilityBillField = "utility_bill"
|
||||||
|
const val bankStatementField = "bank_statement"
|
||||||
|
const val rentalAgreementField = "rental_agreement"
|
||||||
|
const val passportRegistrationField = "passport_registration"
|
||||||
|
const val temporaryRegistrationField = "temporary_registration"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached
|
||||||
@@ -48,7 +49,7 @@ data class InlineQueryResultAudioCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultAudioCached {
|
) : InlineQueryResultAudioCached {
|
||||||
override val type: String = inlineQueryResultAudioType
|
override val type: String = inlineQueryResultAudioType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType
|
||||||
@@ -59,7 +60,7 @@ data class InlineQueryResultAudioImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultAudio {
|
) : InlineQueryResultAudio {
|
||||||
override val type: String = inlineQueryResultAudioType
|
override val type: String = inlineQueryResultAudioType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached
|
||||||
@@ -56,7 +57,7 @@ data class InlineQueryResultDocumentCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultDocumentCached {
|
) : InlineQueryResultDocumentCached {
|
||||||
override val type: String = inlineQueryResultDocumentType
|
override val type: String = inlineQueryResultDocumentType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType
|
||||||
@@ -73,7 +74,7 @@ data class InlineQueryResultDocumentImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultDocument {
|
) : InlineQueryResultDocument {
|
||||||
override val type: String = inlineQueryResultDocumentType
|
override val type: String = inlineQueryResultDocumentType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached
|
||||||
@@ -52,7 +53,7 @@ data class InlineQueryResultGifCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultGifCached {
|
) : InlineQueryResultGifCached {
|
||||||
override val type: String = inlineQueryResultGifType
|
override val type: String = inlineQueryResultGifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType
|
||||||
@@ -72,8 +73,8 @@ data class InlineQueryResultGifImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultGif {
|
) : InlineQueryResultGif {
|
||||||
override val type: String = inlineQueryResultGifType
|
override val type: String = inlineQueryResultGifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached
|
||||||
@@ -52,7 +53,7 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultMpeg4GifCached {
|
) : InlineQueryResultMpeg4GifCached {
|
||||||
override val type: String = inlineQueryResultMpeg4GifType
|
override val type: String = inlineQueryResultMpeg4GifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType
|
||||||
@@ -72,8 +73,8 @@ data class InlineQueryResultMpeg4GifImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultMpeg4Gif {
|
) : InlineQueryResultMpeg4Gif {
|
||||||
override val type: String = inlineQueryResultMpeg4GifType
|
override val type: String = inlineQueryResultMpeg4GifType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached
|
||||||
@@ -56,7 +57,7 @@ data class InlineQueryResultPhotoCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultPhotoCached {
|
) : InlineQueryResultPhotoCached {
|
||||||
override val type: String = inlineQueryResultPhotoType
|
override val type: String = inlineQueryResultPhotoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType
|
||||||
@@ -67,7 +68,7 @@ data class InlineQueryResultPhotoImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultPhoto {
|
) : InlineQueryResultPhoto {
|
||||||
override val type: String = inlineQueryResultPhotoType
|
override val type: String = inlineQueryResultPhotoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached
|
||||||
@@ -56,7 +57,7 @@ data class InlineQueryResultVideoCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVideoCached {
|
) : InlineQueryResultVideoCached {
|
||||||
override val type: String = inlineQueryResultVideoType
|
override val type: String = inlineQueryResultVideoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType
|
||||||
@@ -77,7 +78,7 @@ data class InlineQueryResultVideoImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVideo {
|
) : InlineQueryResultVideo {
|
||||||
override val type: String = inlineQueryResultVideoType
|
override val type: String = inlineQueryResultVideoType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached
|
||||||
@@ -52,7 +53,7 @@ data class InlineQueryResultVoiceCachedImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVoiceCached {
|
) : InlineQueryResultVoiceCached {
|
||||||
override val type: String = inlineQueryResultVoiceType
|
override val type: String = inlineQueryResultVoiceType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||||
|
import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType
|
||||||
@@ -65,7 +66,7 @@ data class InlineQueryResultVoiceImpl internal constructor(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultVoice {
|
) : InlineQueryResultVoice {
|
||||||
override val type: String = inlineQueryResultVoiceType
|
override val type: String = inlineQueryResultVoiceType
|
||||||
override val entities: List<TextSource>? by lazy {
|
override val textSources: List<TextSource>? by lazy {
|
||||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult
|
||||||
@@ -8,10 +7,5 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInp
|
|||||||
const val inlineQueryResultAudioType = "audio"
|
const val inlineQueryResultAudioType = "audio"
|
||||||
|
|
||||||
interface InlineQueryResultAudioCommon : InlineQueryResult,
|
interface InlineQueryResultAudioCommon : InlineQueryResult,
|
||||||
CaptionedOutput,
|
|
||||||
TextedOutput,
|
TextedOutput,
|
||||||
WithInputMessageContentInlineQueryResult {
|
WithInputMessageContentInlineQueryResult
|
||||||
@Deprecated("Will be removed in next major release")
|
|
||||||
override val caption: String?
|
|
||||||
get() = text
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||||
|
|
||||||
@@ -9,10 +8,5 @@ const val inlineQueryResultDocumentType = "document"
|
|||||||
interface InlineQueryResultDocumentCommon : InlineQueryResult,
|
interface InlineQueryResultDocumentCommon : InlineQueryResult,
|
||||||
TitledInlineQueryResult,
|
TitledInlineQueryResult,
|
||||||
DescribedInlineQueryResult,
|
DescribedInlineQueryResult,
|
||||||
CaptionedOutput,
|
|
||||||
TextedOutput,
|
TextedOutput,
|
||||||
WithInputMessageContentInlineQueryResult {
|
WithInputMessageContentInlineQueryResult
|
||||||
@Deprecated("Will be removed in next major release")
|
|
||||||
override val caption: String?
|
|
||||||
get() = text
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||||
|
|
||||||
@@ -8,10 +7,5 @@ const val inlineQueryResultGifType = "gif"
|
|||||||
|
|
||||||
interface InlineQueryResultGifCommon : InlineQueryResult,
|
interface InlineQueryResultGifCommon : InlineQueryResult,
|
||||||
OptionallyTitledInlineQueryResult,
|
OptionallyTitledInlineQueryResult,
|
||||||
CaptionedOutput,
|
|
||||||
TextedOutput,
|
TextedOutput,
|
||||||
WithInputMessageContentInlineQueryResult {
|
WithInputMessageContentInlineQueryResult
|
||||||
@Deprecated("Will be removed in next major release")
|
|
||||||
override val caption: String?
|
|
||||||
get() = text
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||||
|
|
||||||
@@ -8,10 +7,5 @@ const val inlineQueryResultMpeg4GifType = "mpeg4_gif"
|
|||||||
|
|
||||||
interface InlineQueryResultMpeg4GifCommon : InlineQueryResult,
|
interface InlineQueryResultMpeg4GifCommon : InlineQueryResult,
|
||||||
OptionallyTitledInlineQueryResult,
|
OptionallyTitledInlineQueryResult,
|
||||||
CaptionedOutput,
|
|
||||||
TextedOutput,
|
TextedOutput,
|
||||||
WithInputMessageContentInlineQueryResult {
|
WithInputMessageContentInlineQueryResult
|
||||||
@Deprecated("Will be removed in next major release")
|
|
||||||
override val caption: String?
|
|
||||||
get() = text
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo
|
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||||
|
|
||||||
@@ -9,10 +8,5 @@ const val inlineQueryResultPhotoType = "photo"
|
|||||||
interface InlineQueryResultPhotoCommon : InlineQueryResult,
|
interface InlineQueryResultPhotoCommon : InlineQueryResult,
|
||||||
OptionallyTitledInlineQueryResult,
|
OptionallyTitledInlineQueryResult,
|
||||||
DescribedInlineQueryResult,
|
DescribedInlineQueryResult,
|
||||||
CaptionedOutput,
|
|
||||||
TextedOutput,
|
TextedOutput,
|
||||||
WithInputMessageContentInlineQueryResult {
|
WithInputMessageContentInlineQueryResult
|
||||||
@Deprecated("Will be removed in next major release")
|
|
||||||
override val caption: String?
|
|
||||||
get() = text
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user