mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 12:00:18 +00:00
Compare commits
351 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35e28c00cb | |||
| 1913f1a900 | |||
| cbfd34098d | |||
| e5618f4705 | |||
| c9f2166e7d | |||
| eb960290c6 | |||
| 100f8b564a | |||
| 8e1ad9ffbc | |||
| 8875e2a986 | |||
| 7478b151eb | |||
| 959136479e | |||
| a52a62837e | |||
| 17dd694044 | |||
| 34fcfe2e20 | |||
| 64862ecd2d | |||
| c9edbbf7af | |||
| a2f9a5a432 | |||
| 8337da34ca | |||
| f45956b554 | |||
| bec1255d67 | |||
| 39ca29279f | |||
| 70b592baad | |||
| 403aa684a8 | |||
| e10e257c80 | |||
| 5e7bc96b44 | |||
| 79d0eda61d | |||
| 9916b3f469 | |||
| 2bac5f0eed | |||
|
|
01eb072caa | ||
| 496af479b0 | |||
| 386e91e28b | |||
| 91dbcecefc | |||
| 2d743e4c19 | |||
| 8804a24013 | |||
| 8b5244d8df | |||
| 034901a479 | |||
| 7043647584 | |||
| acd9505a5d | |||
| 46c33d5ec4 | |||
| 89dc7a4b2a | |||
| e4f305b3ec | |||
| d56c132201 | |||
| d336e177dd | |||
| 15e29286fb | |||
| 314ceed78e | |||
| 3fa3aa50d9 | |||
| 571296b9a0 | |||
| 3f13e5d062 | |||
| 1874023c05 | |||
| dc0fda2066 | |||
| c0d4a4f01b | |||
| 603762bc22 | |||
| 4db82d6ce2 | |||
| 9bf8f56254 | |||
| 9c926a2265 | |||
| 747854f4f4 | |||
| dcfb14553d | |||
| 6eaa9d699b | |||
| 6788c4d1dd | |||
| 6420737a82 | |||
| 4c36750431 | |||
| fd022742aa | |||
| 0472e35752 | |||
| 768d00eedd | |||
| e9347075ed | |||
|
|
3da74b0c66 | ||
|
|
8b79c5c76b | ||
|
|
a1b471d2ca | ||
|
|
e2c7125f6c | ||
| ec8df3c31c | |||
| 94a35349aa | |||
| 046402454f | |||
| c3978f2dab | |||
| 1019fd4d19 | |||
| 76a9fd1a55 | |||
| aec4c7323a | |||
| 7bdfd5cf69 | |||
| ce95a60fbc | |||
| 3c17a67b01 | |||
| 35bf5b9e9d | |||
| 0087d02b5f | |||
| 212d8946c8 | |||
| 319e43901a | |||
| da01955507 | |||
| 095382040c | |||
| 5545708d38 | |||
| 5d06d86549 | |||
| c081e5c457 | |||
| 555c2ffa04 | |||
| bcee64c103 | |||
| 44a35bd26e | |||
| 1f5c719294 | |||
| 6013c3ba86 | |||
| d4551490f7 | |||
| cc0498a89a | |||
| 0b78c0382f | |||
| c91426a910 | |||
| 5d1c59ff75 | |||
| d2228e274c | |||
| 790959ea49 | |||
| ce9f7f35dc | |||
| 4f984d1dbc | |||
| c83da6be70 | |||
|
|
710438489c | ||
| 6f650f6d6c | |||
| 2d15e13ae6 | |||
| d60ee7b8a5 | |||
| 8f882e9825 | |||
| 48e946c2d0 | |||
| 1758d80020 | |||
| 63b2bd61b5 | |||
| ff2c70fc76 | |||
| e3bfc4472a | |||
| 1cff6f616f | |||
| 1dfe4bf276 | |||
| e4b09032cd | |||
| e8e54a0aea | |||
| 8f85b4cba3 | |||
| 46d65a271d | |||
| e088329ce1 | |||
| 8d9ebb754b | |||
| c0a43077ad | |||
| 1811a63a13 | |||
| cba0e30710 | |||
| ff0b7faa48 | |||
| 975898660c | |||
| cfb7f35d20 | |||
| 147889a66a | |||
| ed9ed715a0 | |||
| a9a3f55c8d | |||
| 58943f2504 | |||
| 5f7633a57e | |||
| 65cfc3220d | |||
| 36d30ef91b | |||
| 41e5c579a2 | |||
| bbf63c51ec | |||
| fb91199f83 | |||
| d76c09ffb2 | |||
| acfb7066d2 | |||
| 7507c107b4 | |||
| 2acb177ad6 | |||
| b5a14077fd | |||
| 5f60bf003f | |||
| f9b2c4c403 | |||
| c909774403 | |||
| 670cfcca13 | |||
| 130e00b62b | |||
| ca4beee95f | |||
| ca784e67df | |||
| 835b8b34f9 | |||
| e6430a729c | |||
| 6c4c9f2fc6 | |||
| 310a7e6e82 | |||
| 7375894645 | |||
| 69973c597b | |||
| 22e8b06fda | |||
| 7ede53fdbb | |||
| ca9051920d | |||
| b477e8d585 | |||
| 8ae2f57d55 | |||
| 1fb2ecf15f | |||
| 6073d914d5 | |||
| 16f55d70af | |||
| b484a31a4a | |||
| 0a162c4129 | |||
| 648f1b488b | |||
| 5fbde4bc06 | |||
| 2a276d9272 | |||
| 9ae252717d | |||
| 456143a266 | |||
| 0bcc98e126 | |||
| ab9ceba41c | |||
| 7cd5666e88 | |||
| 35dcd6ada7 | |||
| ec37df82a9 | |||
| 220cb47615 | |||
| d79b8a337a | |||
| cef6a6f741 | |||
| 9471df1f2d | |||
| f121e5f9c3 | |||
| 7f4fe318c5 | |||
| dbf5c2dbb2 | |||
| 105415873d | |||
| ff32fd1dfc | |||
| 006251ed07 | |||
| 9307582654 | |||
| fe11a2119e | |||
| c31403c1a2 | |||
| 0260e7bedc | |||
| fa43a55f26 | |||
| e9e1f4b9cf | |||
| e7b5b9184d | |||
| 81aa3f2307 | |||
| a9fe584504 | |||
| 4c8861ba79 | |||
| 0ec18cbf06 | |||
| 7008f312dc | |||
| 85317a510e | |||
| d629aa206e | |||
| 6394e1a52b | |||
| 23dca3d307 | |||
| 3032aa8474 | |||
| db19b69ca0 | |||
| f3827f81a7 | |||
| 0532dbb1ae | |||
| efc2681da8 | |||
| 735ed9fd86 | |||
| e856dc4754 | |||
| 0706ff1f95 | |||
| 336b830b0b | |||
| 1a638fe0a5 | |||
| 45467e5bd7 | |||
| 8419b0ab6a | |||
| 49573607fb | |||
| 35fe48db35 | |||
| 590db3e672 | |||
| ea40474c47 | |||
| 7354389f2d | |||
| 1f20ae16aa | |||
| 095c91bf39 | |||
| dc173d752c | |||
| a1788e35b2 | |||
| ea224fd765 | |||
| 7f51544bb9 | |||
| dfb22b0e89 | |||
| e675e841da | |||
| dea43aad8e | |||
| 52e25e934d | |||
| acc067585d | |||
| 47aa1a0795 | |||
| b40cc0c1ea | |||
| b5632626ad | |||
| 67fafdac00 | |||
| 738e628a89 | |||
| 420b846466 | |||
| 05e8c9c90d | |||
| e776c5182f | |||
| be5b3745b9 | |||
| 0de1d9cfda | |||
| 01da98d2fe | |||
| e985100c21 | |||
| 671faabef9 | |||
| bb9c9e22a2 | |||
| 42228f0eaa | |||
| dafd0a8ece | |||
| bee9d82372 | |||
| ec6cf0f029 | |||
| 9cee22165d | |||
| a58aad1198 | |||
| aa78d99179 | |||
| 603efe9259 | |||
| 21e3e10222 | |||
| 34eb6eb4bf | |||
| 565a724b9c | |||
| e87c4a0126 | |||
| 9b16d5d82b | |||
| 9747c8bff1 | |||
| 3ee84700f4 | |||
| 04a463f42c | |||
| 668a201789 | |||
| b336b17eef | |||
| 76b25d719a | |||
| a4d077dd17 | |||
| 469712150b | |||
| fad27ede78 | |||
| 1de90412b3 | |||
| 215c8793e1 | |||
| 54835f97d1 | |||
| 923e929670 | |||
| 37488e92e6 | |||
| 830ca8122d | |||
| fbb2758bdb | |||
| a5c3e06f1c | |||
| c6fb50c4a6 | |||
| 976c0b86dc | |||
| fee5d8f925 | |||
| 808746e12d | |||
| 3fb80dd475 | |||
| db8ea0da94 | |||
| fbdfb714a3 | |||
| 1facfbc2b7 | |||
| 914a0662a9 | |||
| eda3003b7d | |||
| 459942de36 | |||
| 17f64f9b48 | |||
| 3f896c2240 | |||
| 94f8c971c5 | |||
| c43109c063 | |||
| f6058e29b4 | |||
| 3a37311331 | |||
| 9fe1472e64 | |||
| f1480c40a7 | |||
| 88eebdc448 | |||
| 8c76283db5 | |||
| 7668c48081 | |||
| 35d2135f73 | |||
| 1cb0e096be | |||
| 31f7c7f31b | |||
| 82d3b3bc48 | |||
| b3734a5c2a | |||
| 55b8736d50 | |||
| 3334fd3ca6 | |||
|
|
e2416b405a | ||
| 14f012fbfa | |||
| 1ff55057f2 | |||
| 71b5e33dbc | |||
| 08d9d183f4 | |||
| 7183634fd6 | |||
| cf9f270651 | |||
| bd87938e9c | |||
| ba76eaeb90 | |||
| d8492ae168 | |||
| 0db85232d3 | |||
| bcf2325be8 | |||
| 51174a13de | |||
| dfc1fa4d7e | |||
| 10a1d1cb38 | |||
| 6c39dc4d06 | |||
| 4877b8958e | |||
| db9c460e66 | |||
| 2bd5d53b2a | |||
| 577436843d | |||
| 048aa93044 | |||
| 4e49de0dd7 | |||
| 9dc5a7624d | |||
| 21a15db031 | |||
| a6aa4b8758 | |||
| e85d5df03e | |||
| 6833640c48 | |||
| c22c1bb144 | |||
| 8293d6683c | |||
| 7e6e892c45 | |||
| 43ac09a79b | |||
| ee1f115d77 | |||
| 7d85b6fb88 | |||
| 013944c5c9 | |||
| 55ed3e165b | |||
| 9c0106d229 | |||
| 9cd2a6220c | |||
| 033ec8f2da | |||
| 274afe8efc | |||
| e60630b331 | |||
| f6692a22d1 | |||
| 53257ff131 | |||
| ec70813e49 | |||
| 54589ed17b | |||
| 1d3736c44e | |||
| 8ef7acab2d | |||
| c3fca5c6c4 | |||
| 84d2c88032 | |||
| b7ec2f2b86 |
10
.github/labeler.yml
vendored
Normal file
10
.github/labeler.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
api: "TelegramBotAPI-extensions-api/**"
|
||||
utils: "TelegramBotAPI-extensions-utils/**"
|
||||
core: "TelegramBotAPI/**" # currently not work
|
||||
|
||||
code: "**/*.kt"
|
||||
gradle: "**/*.gradle"
|
||||
versions: "**/gradle.properties"
|
||||
markdown:
|
||||
- "**/*.md"
|
||||
- "!CHANGELOG.md"
|
||||
13
.github/workflows/greetings.yml
vendored
Normal file
13
.github/workflows/greetings.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
name: Greetings
|
||||
|
||||
on: [pull_request, issues]
|
||||
|
||||
jobs:
|
||||
greeting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/first-interaction@v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-message: 'Welcome with your first issue'
|
||||
pr-message: 'Welcome with your first PullRequest'
|
||||
18
.github/workflows/label.yml
vendored
Normal file
18
.github/workflows/label.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# This workflow will triage pull requests and apply a label based on the
|
||||
# paths that are modified in the pull request.
|
||||
#
|
||||
# To use this workflow, you will need to set up a .github/labeler.yml
|
||||
# file with configuration. For more information, see:
|
||||
# https://github.com/actions/labeler/blob/master/README.md
|
||||
|
||||
name: "Pull Request Labeler"
|
||||
on:
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v2
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
1
.github/write-good.yml
vendored
Normal file
1
.github/write-good.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
spellchecker: true
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,3 +8,6 @@ settings.xml
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
|
||||
local.properties
|
||||
secret.gradle
|
||||
|
||||
@@ -5,6 +5,9 @@ os: linux
|
||||
dist: trusty
|
||||
jdk: oraclejdk8
|
||||
|
||||
script:
|
||||
- ./gradlew build -s
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: build
|
||||
script: ./gradlew build -s -x jvmTest -x jsIrTest -x jsIrBrowserTest -x jsIrNodeTest -x jsLegacyTest -x jsLegacyBrowserTest -x jsLegacyNodeTest
|
||||
- state: test
|
||||
script: ./gradlew allTests
|
||||
|
||||
513
CHANGELOG.md
513
CHANGELOG.md
@@ -1,5 +1,518 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.29.0
|
||||
|
||||
* **THIS VERSION CONTAINS BREAKING CHANGES**
|
||||
* ***PROJECT PACKAGES WERE CHANGED***
|
||||
* Packages in the whole project were changed `com.github.insanusmokrassar.TelegramBotAPI` -> `dev.inmo.tgbotapi`
|
||||
* Project group in repositories were changed: `com.github.insanusmokrassar` -> `dev.inmo`
|
||||
* Migration ([Examples migration](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/pull/11)):
|
||||
1. Change implementation in your gradle files:
|
||||
* `implementation "com.github.insanusmokrassar:TelegramBotAPI-core:*"` -> `implementation "dev.inmo:tgbotapi.core:*"`
|
||||
* `implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-utils:*"` -> `implementation "dev.inmo:tgbotapi.extensions.utils:*"`
|
||||
* `implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:*"` -> `implementation "dev.inmo:tgbotapi.extensions.api:*"`
|
||||
* `implementation "com.github.insanusmokrassar:TelegramBotAPI:*"` -> `implementation "dev.inmo:tgbotapi:*"`
|
||||
2. Replace packages `com.github.insanusmokrassar.TelegramBotAPI` in the whole project by `dev.inmo.tgbotapi`
|
||||
|
||||
|
||||
* `TelegramBotAPI-core`:
|
||||
* Now in forward info you can get `ForwardFromSupergroupInfo`
|
||||
* **BREAKING CHANGE** `SendVoice` factory function has changed its signature: now it have now `thumb`
|
||||
(according to the [documentation](https://core.telegram.org/bots/api#sendvoice))
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* ALL REQUESTS EXECUTOR USAGES WERE REPLACED WITH `TelegramBot` TYPEALIAS. It should not bring any break changes
|
||||
* Internal changes of `sendRegularPoll` and `sendQuizPoll` extensions
|
||||
* Variable `defaultLivePeriodDelayMillis` now is public
|
||||
* All `send` extensions for `TelegramBot` got their `reply` variations (issue [#144](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/144))
|
||||
* A lot of `send` extensions for `TelegramBot` got their variation with `Chat` instead of `ChatIdentifier`
|
||||
|
||||
## 0.28.0
|
||||
|
||||
* **THIS VERSION CONTAINS BREAKING CHANGES**
|
||||
* ***PROJECT PACKAGES WERE CHANGED***
|
||||
* Project `TelegramBotAPI` -> `TelegramBotAPI-core`
|
||||
* Project `TelegramBotAPI-all` -> `TelegramBotAPI`
|
||||
|
||||
* `Common`:
|
||||
* Version updates:
|
||||
* `Kotlin`: `1.3.72` -> `1.4.0`
|
||||
* `Coroutines`: `1.3.8` -> `1.3.9`
|
||||
* `Serialization`: `0.20.0` -> `1.0.0-RC`
|
||||
* `Klock`: `1.11.14` -> `1.12.0`
|
||||
* `UUID`: `0.1.1` -> `0.2.1`
|
||||
* `Ktor`: `1.3.2` -> `1.4.0`
|
||||
* `buildMimeType` function now is cache-oriented getter which will save already got mime types into internal map
|
||||
* All deprecations from previous versions were removed
|
||||
* `TelegramBotAPI-core`:
|
||||
* Typealias `TelegramBot` was added
|
||||
* Fully rebuilt `KtorCallFactory` interface to be able to handle custom answers from telegram bot api system
|
||||
* New implementation of `KtorCallFactory` was added: `DownloadFileRequestCallFactory`
|
||||
* `DownloadFile` request was added
|
||||
* All included `KtorCallFactory` realizations (except of abstract) now are objects:
|
||||
* `MultipartRequestCallFactory`
|
||||
* `SimpleRequestCallFactory`
|
||||
* `MediaGroupMemberInputMedia` members now will not have `arguments` property due to redundancy and buggy of that
|
||||
* Field `media` now is common for all `InputMedia` objects
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* Extensions `TelegramBot#downloadFile` were added
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* All extensions for media groups (except of `mediaGroupId`) have changed their context: `List<MediaGroupMessage>`
|
||||
-> `List<CommonMessage<MediaGroupContent>>`
|
||||
* `forwardInfo`
|
||||
* `replyTo`
|
||||
* `chat`
|
||||
* `createResend` (several extensions)
|
||||
* Several extensions for downloading of files:
|
||||
* `HttpClient#loadFile`
|
||||
* `PathedFile#download`
|
||||
|
||||
### 0.28.4
|
||||
|
||||
* `Common`:
|
||||
* Version updates:
|
||||
* `Ktor`: `1.4.0` -> `1.4.1`
|
||||
* `TelegramBotAPI-core`
|
||||
* Interface `GroupEventMessage` has been added ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Old `GroupEventMessage` was renamed to `CommonGroupEventMessage` ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Interface `SupergroupEventMessage` has been added ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Old `SupergroupEventMessage` was renamed to `CommonSupergroupEventMessage` ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Any `GroupEventMessage` now have `from` field ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* `TelegramBotAPI-extensions-utils`
|
||||
* Extensions `Flow<ChatEventMessage>#onlyGroupEvents` and `Flow<ChatEventMessage>#onlySupergroupEvents` now returns
|
||||
`CommonGroupEventMessage` and `CommonSupergroupEventMessage`
|
||||
|
||||
### 0.28.3
|
||||
|
||||
* Common:
|
||||
* Version updates:
|
||||
* `Klock`: `0.12.0` -> `0.12.1`
|
||||
* `Kotlin serialization`: `1.0.0-RC` -> `1.0.0-RC2` (dependency `kotlinx-serialization-core` was replaced with
|
||||
`kotlinx-serialization-json` due to [kotlinx.serialization library update](https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md#100-rc2--2020-09-21))
|
||||
* `TelegramBotAPI-core`:
|
||||
* All `InlineQueryResult` has changed their type of id for more obvious relation between `InlineQueryResult#id` and
|
||||
`ChosenInlineResult#resultId`: `String` -> `InlineQueryIdentifier`
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Several extensions for updates flows based on `InlineQueryUpdate` has been added:
|
||||
* `Flow<InlineQueryUpdate>#onlyBaseInlineQueriesWithUpdates`
|
||||
* `Flow<InlineQueryUpdate>#onlyBaseInlineQueries`
|
||||
* `Flow<InlineQueryUpdate>#onlyLocationInlineQueriesWithUpdates`
|
||||
* `Flow<InlineQueryUpdate>#onlyLocationInlineQueries`
|
||||
* Several extensions for updates flows based on `ChosenInlineResultUpdate` has been added:
|
||||
* `Flow<ChosenInlineResultUpdate>.onlyBaseChosenInlineResultsWithUpdates`
|
||||
* `Flow<ChosenInlineResultUpdate>.onlyBaseChosenInlineResults`
|
||||
* `Flow<ChosenInlineResultUpdate>.onlyLocationChosenInlineResultsWithUpdates`
|
||||
* `Flow<ChosenInlineResultUpdate>.onlyLocationChosenInlineResults`
|
||||
|
||||
### 0.28.2
|
||||
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Several commands shortcuts for `Flow<ContentMessage<TextContent>>` has been added:
|
||||
* `filterExactCommands`
|
||||
* `filterCommandsInsideTextMessages`
|
||||
* `filterCommandsWithArgs`
|
||||
* Extension `Flow<BaseSentMessageUpdate>.filterCommandsWithArgs` has changed its signature: now it will also have
|
||||
original message paired with list of text sources
|
||||
* Shortcut method `commonMessages` for `onlyCommonMessages`
|
||||
* Shortcuts `onlySentViaBot` and `withoutSentViaBot` now are extensions for any `Flow` with types which implementing
|
||||
`ContentMessage`
|
||||
|
||||
### 0.28.1
|
||||
|
||||
* Common:
|
||||
* Versions updates:
|
||||
* `Kotlin`: `1.4.0` -> `1.4.10`
|
||||
* `UUID`: `0.2.1` -> `0.2.2`
|
||||
* `TelegramBotAPI-core`:
|
||||
* `ExceptionHandler` has changed its incoming type: `Exception` -> `Throwable`
|
||||
* `handleSafely` has changed its signature
|
||||
* `executeUnsafe` has changed its signature
|
||||
|
||||
## 0.27.0
|
||||
|
||||
* `Common`:
|
||||
* Versions updates:
|
||||
* `Kotlin`: `1.3.71` -> `1.3.72`
|
||||
* `Klock`: `1.10.3` -> `1.10.5`
|
||||
* `TelegramBotAPI`:
|
||||
* Typealias `LongSeconds` was added for correct explanation of seconds in `Long` primitive type
|
||||
* Several new fields was added:
|
||||
* `explanationField`
|
||||
* `explanationEntitiesField`
|
||||
* `openPeriodField`
|
||||
* `closeDateField`
|
||||
* Extension `List<TextPart>#justTextSources` was added for mapping of `List<TextPart>` to `List<TextSource>`
|
||||
* Field `SendPoll#closeInfo` was added
|
||||
* Range `openPeriodPollSecondsLimit` was added and used in all `SendPoll` requests for checking income data
|
||||
* `SendQuizPoll` now able to use fields `caption` and `parseMode` for `explanation` functionality
|
||||
* `quizPollExplanationLimit` was added for checking `QuizPoll` explanation size
|
||||
* Field `TextLinkTextSource#url` was added
|
||||
* Field `TextMentionTextSource#user` was added
|
||||
* Sealed class `ScheduledCloseInfo` was added
|
||||
* Class `ExactScheduledCloseInfo` was added for cases with `close_date`
|
||||
* Class `ApproximateScheduledCloseInfo` was added for cases with `open_period`
|
||||
* Field `Poll#scheduledCloseInfo` was added
|
||||
* Sealed class `MultipleAnswersPoll` was added
|
||||
* Class `RegularPoll` now extends `MultipleAnswersPoll`
|
||||
* `Dice` class was replaced into new package
|
||||
* Sealed class `DiceAnimationType` was added
|
||||
* Field `Dice#animationType` was added as `emoji` API representation
|
||||
* `SendDice` now receive `animationType` as second parameter
|
||||
* For `List<TextSource>` was added several extensions:
|
||||
* `toMarkdownCaptions`
|
||||
* `toMarkdownTexts`
|
||||
* `toMarkdownV2Captions`
|
||||
* `toMarkdownV2Texts`
|
||||
* `toHtmlCaptions`
|
||||
* `toHtmlTexts`
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* All `RequestsExecutor#sendDice` extensions now accept `DiceAnimationType?` as second parameter
|
||||
* All `RequestsExecutor#sendRegularPoll` extensions now accept `ScheduledCloseInfo` fourth parameter
|
||||
* All `RequestsExecutor#sendQuizPoll` extensions now accept additional parameters `caption: String` and
|
||||
`parseMode: ParseMode` for `explanation` functionality and `closeInfo: ScheduledCloseInfo?` for autoclose poll
|
||||
functionality
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Several shortcuts for `ScheduledCloseInfo` was added:
|
||||
* `closePollExactAt`
|
||||
* `closePollExactAfter`
|
||||
* `closePollAfter`
|
||||
|
||||
### 0.27.11
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* Extension `String#filenameFromUrl` was created
|
||||
* Extension `PathedFile#filename` was created
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* `Flow<Iterable<T>>.flatMap` extension was added
|
||||
* Extensions for `FlowUpdatesFilter` were added:
|
||||
* `FlowsUpdatesFilter#allSentMessagesFlow` (combination of `messageFlow` and `channelPostFlow`)
|
||||
* `FlowsUpdatesFilter#allSentMediaGroupsFlow` (combination of `messageMediaGroupFlow` and `channelPostMediaGroupFlow`)
|
||||
* `FlowsUpdatesFilter#sentMessages`
|
||||
* `FlowsUpdatesFilter#sentMessagesWithMediaGroups`
|
||||
* `FlowsUpdatesFilter#photoMessagesWithMediaGroups`
|
||||
* `FlowsUpdatesFilter#imageMessagesWithMediaGroups`
|
||||
* `FlowsUpdatesFilter#videoMessagesWithMediaGroups`
|
||||
* `FlowsUpdatesFilter#mediaGroupMessages`
|
||||
* `FlowsUpdatesFilter#mediaGroupPhotosMessages`
|
||||
* `FlowsUpdatesFilter#mediaGroupVideosMessages`
|
||||
* A lot of extensions like `Flow<BaseSentMessageUpdate>#textMessages` were added:
|
||||
* `Flow<BaseSentMessageUpdate>#animationMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#audioMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#contactMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#diceMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#documentMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#gameMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#invoiceMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#locationMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#photoMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#imageMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#pollMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#stickerMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#textMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#venueMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#videoMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#videoNoteMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#voiceMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#mediaGroupMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#mediaGroupPhotosMessages`
|
||||
* `Flow<BaseSentMessageUpdate>#mediaGroupVideosMessages`
|
||||
|
||||
### 0.27.10
|
||||
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* Function `telegramBot(TelegramAPIUrlsKeeper)` was added
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Extension `Route#includeWebhookHandlingInRouteWithFlows` was added
|
||||
* A lot of extensions like `FlowsUpdatesFilter#textMessages` were added:
|
||||
* `FlowsUpdatesFilter#animationMessages`
|
||||
* `FlowsUpdatesFilter#audioMessages`
|
||||
* `FlowsUpdatesFilter#contactMessages`
|
||||
* `FlowsUpdatesFilter#diceMessages`
|
||||
* `FlowsUpdatesFilter#documentMessages`
|
||||
* `FlowsUpdatesFilter#gameMessages`
|
||||
* `FlowsUpdatesFilter#invoiceMessages`
|
||||
* `FlowsUpdatesFilter#locationMessages`
|
||||
* `FlowsUpdatesFilter#photoMessages`
|
||||
* `FlowsUpdatesFilter#imageMessages`
|
||||
* `FlowsUpdatesFilter#pollMessages`
|
||||
* `FlowsUpdatesFilter#stickerMessages`
|
||||
* `FlowsUpdatesFilter#textMessages`
|
||||
* `FlowsUpdatesFilter#venueMessages`
|
||||
* `FlowsUpdatesFilter#videoMessages`
|
||||
* `FlowsUpdatesFilter#videoNoteMessages`
|
||||
* `FlowsUpdatesFilter#voiceMessages`
|
||||
|
||||
### 0.27.9
|
||||
|
||||
* `Common`
|
||||
* Versions updates:
|
||||
* `Gradle Wrapper`: `6.5-all` -> `6.5.1-bin`
|
||||
* `Coroutines`: `1.3.7` -> `1.3.8`
|
||||
* `Klock`: `1.11.3` -> `1.11.14`
|
||||
* `UUID`: `0.1.0` -> `0.1.1`
|
||||
|
||||
### 0.27.8
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* `UnknownUpdateType` was renamed to `UnknownUpdate`
|
||||
* Refactoring and optimization of `FlowsUpdatesFilter`
|
||||
* `Venue` type was replaced to a new package: `com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue`
|
||||
* `Venue` type now implements `Locationed` and delegate realisation to its `location` field
|
||||
* `FoursquareId` and `FoursquareType` typealiases were added
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Several new functions `makeLinkToMessage` was added
|
||||
* `Foursquare` data class was added
|
||||
* Extension `Venue#foursquare` was added
|
||||
* Factory function `Venue` with `Foursquare` parameter was added
|
||||
|
||||
### 0.27.7
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* Operator function `unaryPlus` was added to `RowBuilder`. Now it is possible to write `row { +button }`
|
||||
* Function `flatMatrix` was added for single-row columns
|
||||
* Operator extension `RowBuilder#plus` was added to be able to write things like `row { this + button }`
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* Extensions `RequestsExecutor#sendVenue` with `Location` args were added
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Function `InlineKeyboardMarkup` for flat keyboards was added
|
||||
* Function `ReplyKeyboardMarkup` for flat keyboards was added
|
||||
|
||||
### 0.27.6
|
||||
|
||||
* `Common`:
|
||||
* Versions:
|
||||
* `Kotlin Coroutines`: `1.3.6` -> `1.3.7`
|
||||
* `TelegramBotAPI`:
|
||||
* Interface `PossiblySentViaBot` has been added
|
||||
* Additional interface `PossiblySentViaBotCommonMessage` was added for more explicit typing declaration for
|
||||
compiler
|
||||
* Currently, only `ChannelMessage` and `CommonMessageImpl` are implementing the interface
|
||||
`PossiblySentViaBotCommonMessage`. It could be changed in future
|
||||
* Factory `buildMimeType` was added
|
||||
* `BuiltinMimeTypes` was added
|
||||
* Abstraction `ThumbedWithMimeTypeInlineQueryResult` with `thumbMimeType` field was added
|
||||
* `InlineQueryResultGif` and `InlineQueryResultMpeg4Gif` now extend `ThumbedWithMimeTypeInlineQueryResult`
|
||||
instead of `ThumbedInlineQueryResult`
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* New extensions `onlyCommonMessages`, `onlySentViaBot` and `withoutSentViaBot` was added
|
||||
|
||||
### 0.27.5
|
||||
|
||||
* `Common`:
|
||||
* Versions:
|
||||
* `Klock`: `1.11.1` -> `1.11.3`
|
||||
* `TelegramotAPI`:
|
||||
* Fix: for sending requests caption and text lengths limits were updated
|
||||
* New variant of `row` was added
|
||||
* `makeLinkToMessage` extensions has been deprecated (replaced into `TelegramBotAPI-extensions-utils`)
|
||||
* Next things was deprecated and replaced into `TelegramBotAPI-extensions-utils`:
|
||||
* All `String` formatting public extensions and functions
|
||||
* All extensions like `CaptionedInput#toHtmlCaptions`
|
||||
* All helper extensions for `List<BaseMessageUpdate>`
|
||||
* All `RequestsExecutor#executeAsync` and `RequestsExecutor#executeUnsafe`
|
||||
* `BotCommand` now more strictly check commands which passed to it
|
||||
* Regex `BotCommandNameRegex` was added
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* A lot of `RequesstExecutor#getChat` extensions was added for more explicit types showing
|
||||
* New `RequesstExecutor#setMyCommands` extension was added
|
||||
* New field `BotBuilder#ktorClientEngineFactory` introduced
|
||||
* Field `BotBuilder#ktorClientEngine` now is deprecated
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* `safely` function was introduced. It is in `PreviewFeature` state currently
|
||||
* `makeLinkToMessage` extensions has been added
|
||||
* `makeLinkToAddStickerSet` function and its variations were added
|
||||
* Next tools was added from `TelegramBotAPI`:
|
||||
* All `String` formatting extensions and functions
|
||||
* All extensions like `CaptionedInput#toHtmlCaptions`
|
||||
* All helper extensions for `List<BaseMessageUpdate>`
|
||||
* Several new extensions for `SentMediaGroupUpdate` were added:
|
||||
* `SentMediaGroupUpdate#forwardInfo`
|
||||
* `SentMediaGroupUpdate#replyTo`
|
||||
* `SentMediaGroupUpdate#chat`
|
||||
* `SentMediaGroupUpdate#mediaGroupId`
|
||||
* Several `List<MediaGroupMessage>.createResend` extensions were added
|
||||
* `RequestsExecutor#executeAsync` and `RequestsExecutor#executeUnsafe`
|
||||
|
||||
### 0.27.4
|
||||
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Several extensions for updates was added:
|
||||
* `onlyBaseMessageUpdates`
|
||||
* `onlySentMessageUpdates`
|
||||
* `onlyEditMessageUpdates`
|
||||
* `onlyMediaGroupsUpdates`
|
||||
* `onlySentMediaGroupUpdates`
|
||||
* `onlyEditMediaGroupUpdates`
|
||||
* Renames in chat filters extensions:
|
||||
* `filterBaseMessageUpdates` -> `filterBaseMessageUpdatesByChatId` and `filterBaseMessageUpdatesByChat`
|
||||
* `filterSentMediaGroupUpdates` -> `filterSentMediaGroupUpdatesByChatId` and `filterSentMediaGroupUpdatesByChat`
|
||||
|
||||
### 0.27.3
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* `UpdateDeserializationStrategy` is publicly available now
|
||||
* All `setWebhook` extensions was marked as deprecated, renamed and replaced into `TelegramBotAPI-extensions-utils`
|
||||
* Typealias `ExceptionHandler` was added - it will be used for `handleSafely`
|
||||
* `SetWebhook` factories signatures was changed (backward compatibility was not broken)
|
||||
* `executeUnsafe` now working differently
|
||||
* Now it is possible to pass exceptions handler into `executeUnsafe`
|
||||
* `BasketballDiceAnimationType` was added
|
||||
* `UnknownDiceAnimationType` now is deprecated due to renaming - currently it is typealias for `CustomDiceAnimationType`
|
||||
* `CustomDiceAnimationType` now is `data` class instead of common class
|
||||
* `FlowsUpdatesFilter` will use size 64 by default for internal broadcast channels
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* Long Polling extensions now are deprecated in this project. It was replaced into `TelegramBotAPI-extensions-utils`
|
||||
* Several `telegramBot` functions was renamed into `telegramBotWithCustomClientConfig`
|
||||
* Add one more `setWebhookInfo` realisation
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Extension `toTelegramUpdate` was added
|
||||
* Long Polling extensions were added
|
||||
* Updates utils were added
|
||||
* New extensions `startListenWebhooks`, `setWebhookInfoAndStartListenWebhooks` and `includeWebhookHandlingInRoute` was added
|
||||
* New extension `CoroutineScope#updateHandlerWithMediaGroupsAdaptation` was added
|
||||
* New extension `flowsUpdatesFilter` was added
|
||||
* `TelegramBotAPI-all`:
|
||||
* Project was created
|
||||
|
||||
### 0.27.2
|
||||
|
||||
* `Common`:
|
||||
* Versions:
|
||||
* Coroutines: `1.3.5` -> `1.3.6`
|
||||
* Klock: `1.10.5` -> `1.11.1`
|
||||
* `TelegramBotAPI`:
|
||||
* Expected class `MimeType` was added
|
||||
* Field `MimeTyped#mimeType` now typed by `MimeType` instead of `String`
|
||||
* `MediaGroupMemberInputMedia` children now can be deserialized (but only those ones who are declared inside library)
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Chat events splitters added:
|
||||
* Extension `Flow<ChatEventMessage>#onlyChannelEvents` was added
|
||||
* Extension `Flow<ChatEventMessage>#onlyGroupEvents` was added
|
||||
* Extension `Flow<ChatEventMessage>#onlySupergroupEvents` was added
|
||||
|
||||
### 0.27.1
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* Interface `Explained` and subsinterfaces `ExplainedInput` and `ExplainedOutput` was added
|
||||
* Class `QuizPoll` now implement `ExplainedInput`
|
||||
* In `QuizPoll#caption` and `QuizPoll#captionEntities` are deprecated now
|
||||
* Class `SendQuizPoll` now implement `ExplainedOutput`
|
||||
* In `SendQuizPoll#caption` is deprecated now
|
||||
* `explanationLimit` range was added as future replacement of `quizPollExplanationLimit`
|
||||
* `quizPollExplanationLimit` now is deprecated
|
||||
* Extensions `toMarkdownExplanations`, `toMarkdownV2Explanations` and `toHtmlExplanations` was added
|
||||
* Typealias `FullTextSourcesList` was added
|
||||
* All extensions `fullEntitiesList` now return `FullTextSourcesList`
|
||||
* All extensions of `List<TextSource>` now are extensions for `FullTextSourcesList`
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* `sendQuizPoll` now is using `explanation` parameter instead of `caption`
|
||||
|
||||
## 0.26.0
|
||||
|
||||
* `Common`:
|
||||
* Versions updates:
|
||||
* `Klock`: `1.10.0` -> `1.10.3`
|
||||
* `TelegramBotAPI`:
|
||||
* Request `SendDice` was added (calling [sendDice](https://core.telegram.org/bots/api#senddice))
|
||||
* Class `Dice` was added (type [dice](https://core.telegram.org/bots/api#dice))
|
||||
* Class `DiceContent` was added (for including it in [message](https://core.telegram.org/bots/api#message) object)
|
||||
* `BotCommand` was added
|
||||
* `GetMyCommands` request was added
|
||||
* `SetMyCommands` request was added
|
||||
* `GetMe` now is object instead of class
|
||||
* `GetMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.requests.bot.GetMe`
|
||||
* `CreateNewStickerSet` renamed to `CreateStaticNewStickerSet`
|
||||
* `CreateNewAnimatedStickerSet` request was added (it handle work with `tgs_sticker`)
|
||||
* `StickerSet#thumb` was added
|
||||
* `AddStickerToSet` renamed to `AddStaticStickerToSet`
|
||||
* `AddAnimatedStickerToSet` request was added
|
||||
* `SetStickerSetThumb` request was added
|
||||
* Most of sticker actions now implements `StandardStickerSetAction` instead of `StickerSetAction`
|
||||
* `getUpdatesLimit` was added to be ensure in get updates limit
|
||||
* `GetUpdates` now will check count of requesting updates and throw exception if it is not in range `1 .. 100`
|
||||
* `GetUpdates#limit` now is not nullable and by default set up to 100
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* Extensions `sendDice` was added
|
||||
* Extension `getMyCommands` request was added
|
||||
* Extension `setMyCommands` request was added
|
||||
* Extension `getMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.GetMeKt.getMe`
|
||||
* **All extensions `createNewStickerSet` was renamed to `createNewStaticStickerSet`**
|
||||
* Extensions `createNewAnimatedStickerSet` was added
|
||||
* **All extensions `addStickerToSet` was renamed to `addStaticStickerToSet`**
|
||||
* Extensions `addAnimatedStickerToSet` was added
|
||||
* Extensions `setStickerSetThumb` was added
|
||||
* Extension `startGettingUpdates` now will drop `SentMediaGroupUpdate` in case if it is the last in updates group
|
||||
and size of retrieved updates is equal to 100 (max count of retrieved updates)
|
||||
* Extensions `getUpdates` now will receive only not nullable `limit` parameter
|
||||
|
||||
### 0.26.4
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* Now any getting of updates will return `UnknownUpdateType` when inside of deserialization will be
|
||||
`SerializationException` or `NotImplemented` error
|
||||
* `CallbackGame` currently is an object
|
||||
* It is possible to use `CallbackGame` for now
|
||||
* `CallbackGameInlineKeyboardButton` now will not accept `callbackGame` as income object
|
||||
* Now it is possible to pass exception handler in webhook
|
||||
|
||||
### 0.26.3
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* `CallbackGameInlineKeyboardButton` was added
|
||||
([Issue-79](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/79),
|
||||
[PR-80](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/80))
|
||||
* `UnknownInlineKeyboardButton` was added. It is unavailable for creating, but you can receive it, for example, in
|
||||
`InlineQueryResult`
|
||||
* `Update` now will be created even if was `SerializationException` inside of creating the update instance - in this
|
||||
case will be created `UnknownUpdateType`
|
||||
* `UnknownUpdateType$rawJson` value now is included (`JsonElement`)
|
||||
* **EXPERIMENTALLY** `BaseEditMessageUpdate#data` now is `CommonMessage<*>`
|
||||
* Suspend inline function `handleSafely` was added
|
||||
* `KtorRequestsExecutor` now use `handleSafely` instead of `try` with `supervisorScope`
|
||||
* `UpdatesPolling` now use `handleSafely` instead of `try` with `supervisorScope`
|
||||
|
||||
### 0.26.2
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* Now `EditMediaGroupUpdate` also extends `BaseEditMessageUpdate`
|
||||
* **EXPERIMENTALLY** Now all `TextSource` realisations will contain `source` field as a property inside of them
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* `startGettingFlowsUpdates` extension which do not require filter (but return a new one) was added
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Subproject was added
|
||||
* `filterBaseMessageUpdates`, `filterSentMediaGroupUpdates` and `filterEditMediaGroupUpdates` extensions was added
|
||||
* `filterCommandsWithArgs`, `filterExactCommands` and `filterCommandsInsideTextMessages` extensions was added
|
||||
* `asContentMessagesFlow`, `asChatEventsFlow` and `asUnknownMessagesFlow` extensions was added
|
||||
* `withContentType` extension was added
|
||||
* `onlyAnimationContentMessages` extension was added
|
||||
* `onlyAudioContentMessages` extension was added
|
||||
* `onlyContactContentMessages` extension was added
|
||||
* `onlyDiceContentMessages` extension was added
|
||||
* `onlyDocumentContentMessages` extension was added
|
||||
* `onlyGameContentMessages` extension was added
|
||||
* `onlyInvoiceContentMessages` extension was added
|
||||
* `onlyLocationContentMessages` extension was added
|
||||
* `onlyPhotoContentMessages` extension was added
|
||||
* `onlyPollContentMessages` extension was added
|
||||
* `onlyStickerContentMessages` extension was added
|
||||
* `onlyTextContentMessages` extension was added
|
||||
* `onlyVenueContentMessages` extension was added
|
||||
* `onlyVideoContentMessages` extension was added
|
||||
* `onlyVideoNoteContentMessages` extension was added
|
||||
* `onlyVoiceContentMessages` extension was added
|
||||
|
||||
### 0.26.1
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* `BotCommand` now will check and throw error in case when command or description lengths is/are incorrect
|
||||
* `StorageFile` now is common for all platforms
|
||||
* JavaScript realization was removed due to its redundancy
|
||||
* JVM realization was replaced with `fun` factory
|
||||
* `StorageFile` now able to accept any factory of `Input`
|
||||
* `StorageFileInfo` was added to avoid strange collisions with throws in `StorageFile`
|
||||
* Fixes issue with `hashTag` for markdown
|
||||
* `InvalidPhotoDimensionsException` was added for cases when `PHOTO_INVALID_DIMENSION` answer received
|
||||
* Other fixes
|
||||
|
||||
## 0.25.0
|
||||
|
||||
* Common:
|
||||
|
||||
136
README.md
136
README.md
@@ -1,27 +1,137 @@
|
||||
# TelegramBotAPI
|
||||
|
||||
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://t.me/InMoTelegramBotAPI) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) |
|
||||
| -----------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| TelegramBotAPI status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI) |
|
||||
| TelegramBotAPI Extensions status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api) |
|
||||
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) [Small survey](https://forms.gle/tnjuExdSKEr32ygKA)|
|
||||
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| 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) |
|
||||
| TelegramBotAPI Core status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion) [](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 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 All status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi/_latestVersion) [](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
|
||||
[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`**
|
||||
|
||||
|
||||
It is a complex of libraries for working with `TelegramBotAPI` in type-safe and strict way as much as it possible. In
|
||||
the list of this complex currently next projects:
|
||||
|
||||
* [TelegramBotAPI](TelegramBotAPI/README.md) - core of library. In fact it is independent library and can be used alone
|
||||
without any additional library
|
||||
* [TelegramBotAPI Extensions](TelegramBotAPI-extensions-api/README.md) - contains extensions (mostly for
|
||||
`RequestsExecutor`), which allows to use the core library in more pleasant way
|
||||
* [TelegramBotAPI Core](tgbotapi.core/README.md) - core of library. In fact it is independent library and can be used alone
|
||||
without any additional library
|
||||
* [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
|
||||
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||
|
||||
## JavaScript notes
|
||||
|
||||
### Versions before `0.28.0`
|
||||
|
||||
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)):
|
||||
|
||||
<details>
|
||||
<summary>Gradle build script help (for versions before 0.28.0)</summary>
|
||||
|
||||
```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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Ok, where should I start?
|
||||
|
||||
Firstly, look at the [TelegramBotAPI](TelegramBotAPI/README.md). Here you can find all information about currently
|
||||
covered Telegram Bot API and other things. After this you can look at the
|
||||
[TelegramBotAPI Extensions](TelegramBotAPI-extensions-api/README.md).
|
||||

|
||||
|
||||
Anyway, all libraries are very typical inside of them. For example, any request in TelegramBotAPI look like
|
||||
`requestsExecutor.execute(SomeRequest())`.
|
||||
In most cases, the most simple way will be to implement [TelegramBotAPI](TelegramBotAPI/README.md) - it contains
|
||||
all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just
|
||||
[TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md),
|
||||
[TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) or even
|
||||
[TelegramBotAPI Core](tgbotapi.core/README.md).
|
||||
|
||||
If you want to dive deeper in the core of library or develop something for it - welcome to learn more from
|
||||
[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).
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
# TelegramBotAPI extensions
|
||||
|
||||
[](https://github.com/KotlinBy/awesome-kotlin)
|
||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api)
|
||||
[](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI-extensions-api_master__publishing/)
|
||||
|
||||
## What is it?
|
||||
|
||||
It is wrapper library for [TelegramBotAPI](../TelegramBotAPI/README.md). Here you can find extensions for
|
||||
`RequestsExecutor`, which are more look like Telegram Bot API requests and in the same time have more obvious signatures
|
||||
to help understand some restrictions in Telegram system.
|
||||
|
||||
## Compatibility
|
||||
|
||||
This library always compatible with original `TelegramBotAPI` library version
|
||||
|
||||
## How to implement library?
|
||||
|
||||
Common ways to implement this library are presented here. In some cases it will require additional steps
|
||||
like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable
|
||||
`telegrambotapi-extensions-api.version`, which must be set up by developer. Available versions are presented on
|
||||
[bintray](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api), next version is last published:
|
||||
|
||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion)
|
||||
|
||||
### Maven
|
||||
|
||||
Dependency config presented here:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.github.insanusmokrassar</groupId>
|
||||
<artifactId>TelegramBotAPI-extensions-api</artifactId>
|
||||
<version>${telegrambotapi-extensions-api.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Gradle
|
||||
|
||||
To use last versions you will need to add one line in repositories block of your `build.gradle`:
|
||||
|
||||
`jcenter()` or `mavenCentral()`
|
||||
|
||||
And add next line to your dependencies block:
|
||||
|
||||
```groovy
|
||||
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$telegrambotapi_extensions_api_version"
|
||||
```
|
||||
|
||||
or for old gradle:
|
||||
|
||||
```groovy
|
||||
compile "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$telegrambotapi_extensions_api_version"
|
||||
```
|
||||
|
||||
## Example of usage and comparison with `TelegramBotAPI`
|
||||
|
||||
As said in [TelegramBotAPI](../TelegramBotAPI/README.md#Requests), it is possible to use next syntax for requests:
|
||||
|
||||
```kotlin
|
||||
val requestsExecutor: RequestsExecutor = ...
|
||||
requestsExecutor.execute(GetMe())
|
||||
```
|
||||
|
||||
This library offer a little bit another way for this:
|
||||
|
||||
```kotlin
|
||||
val bot: RequestsExecutor = ...
|
||||
bot.getMe()
|
||||
```
|
||||
|
||||
The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
|
||||
request is
|
||||
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
|
||||
@@ -1,57 +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.withXml {
|
||||
asNode().children().last() + {
|
||||
resolveStrategy = Closure.DELEGATE_FIRST
|
||||
|
||||
description "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference"
|
||||
name "Telegram Bot API Extensions for API"
|
||||
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 +0,0 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"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 Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.DeleteMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
|
||||
suspend fun RequestsExecutor.deleteMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier
|
||||
) = execute(
|
||||
DeleteMessage(chatId, messageId)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.deleteMessage(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
) = deleteMessage(chat.id, messageId)
|
||||
|
||||
suspend fun RequestsExecutor.deleteMessage(
|
||||
message: Message
|
||||
) = deleteMessage(message.chat, message.messageId)
|
||||
|
||||
suspend fun Message.delete(
|
||||
requestsExecutor: RequestsExecutor
|
||||
) = requestsExecutor.deleteMessage(this)
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetMe
|
||||
|
||||
suspend fun RequestsExecutor.getMe() = execute(GetMe())
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
|
||||
suspend fun RequestsExecutor.getUpdates(
|
||||
offset: UpdateIdentifier? = null,
|
||||
limit: Int? = null,
|
||||
timeout: Seconds? = null,
|
||||
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
) = execute(
|
||||
GetUpdates(
|
||||
offset, limit, timeout, allowed_updates
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getUpdates(
|
||||
lastUpdate: Update,
|
||||
limit: Int? = null,
|
||||
timeout: Seconds? = null,
|
||||
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
) = getUpdates(
|
||||
lastUpdate.updateId + 1, limit, timeout, allowed_updates
|
||||
)
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.StopPoll
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
|
||||
suspend fun RequestsExecutor.stopPoll(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopPoll(chatId, messageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.stopPoll(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopPoll(chat.id, messageId, replyMarkup)
|
||||
|
||||
suspend fun RequestsExecutor.stopPoll(
|
||||
chatId: ChatId,
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopPoll(chatId, message.messageId, replyMarkup)
|
||||
|
||||
suspend fun RequestsExecutor.stopPoll(
|
||||
chat: Chat,
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopPoll(chat.id, message.messageId, replyMarkup)
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.AnswerCallbackQuery
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQueryIdentifier
|
||||
|
||||
suspend fun RequestsExecutor.answerCallbackQuery(
|
||||
callbackQueryId: CallbackQueryIdentifier,
|
||||
text: String? = null,
|
||||
showAlert: Boolean? = null,
|
||||
url: String? = null,
|
||||
cachedTimeSeconds: Int? = null
|
||||
) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
|
||||
|
||||
suspend fun RequestsExecutor.answerCallbackQuery(
|
||||
callbackQuery: CallbackQuery,
|
||||
text: String? = null,
|
||||
showAlert: Boolean? = null,
|
||||
url: String? = null,
|
||||
cachedTimeSeconds: Int? = null
|
||||
) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers.payments
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerPreCheckoutQueryError
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerPreCheckoutQueryOk
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
||||
|
||||
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
|
||||
id: PreCheckoutQueryId
|
||||
) = execute(AnswerPreCheckoutQueryOk(id))
|
||||
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
|
||||
preCheckoutQuery: PreCheckoutQuery
|
||||
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
|
||||
|
||||
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
|
||||
id: PreCheckoutQueryId,
|
||||
error: String
|
||||
) = execute(AnswerPreCheckoutQueryError(id, error))
|
||||
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
|
||||
preCheckoutQuery: PreCheckoutQuery,
|
||||
error: String
|
||||
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers.payments
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerShippingQueryError
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerShippingQueryOk
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
||||
|
||||
suspend fun RequestsExecutor.answerShippingQueryOk(
|
||||
id: ShippingQueryIdentifier,
|
||||
shippingOptions: List<ShippingOption>
|
||||
) = execute(AnswerShippingQueryOk(id, shippingOptions))
|
||||
suspend fun RequestsExecutor.answerShippingQueryOk(
|
||||
shippingQuery: ShippingQuery,
|
||||
shippingOptions: List<ShippingOption>
|
||||
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
|
||||
|
||||
suspend fun RequestsExecutor.answerShippingQueryError(
|
||||
id: ShippingQueryIdentifier,
|
||||
error: String
|
||||
) = execute(AnswerShippingQueryError(id, error))
|
||||
suspend fun RequestsExecutor.answerShippingQueryError(
|
||||
shippingQuery: ShippingQuery,
|
||||
error: String
|
||||
) = answerShippingQueryError(shippingQuery.id, error)
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.ExportChatInviteLink
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.exportChatInviteLink(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(ExportChatInviteLink(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.exportChatInviteLink(
|
||||
chat: PublicChat
|
||||
) = exportChatInviteLink(chat.id)
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.LeaveChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.leaveChat(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(LeaveChat(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.leaveChat(
|
||||
chat: PublicChat
|
||||
) = leaveChat(chat.id)
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
|
||||
suspend fun RequestsExecutor.getChat(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChat(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.getChat(
|
||||
chat: Chat
|
||||
) = getChat(chat.id)
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChatAdministrators
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.getChatAdministrators(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatAdministrators(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.getChatAdministrators(
|
||||
chat: PublicChat
|
||||
) = getChatAdministrators(chat.id)
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChatMembersCount
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.getChatMembersCount(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatMembersCount(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.getChatMembersCount(
|
||||
chat: PublicChat
|
||||
) = getChatMembersCount(chat.id)
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.GetChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(GetChatMember(chatId, userId))
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId
|
||||
) = getChatMember(chat.id, userId)
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chatId: ChatId,
|
||||
user: User
|
||||
) = getChatMember(chatId, user.id)
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chat: PublicChat,
|
||||
user: User
|
||||
) = getChatMember(chat.id, user.id)
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.KickChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null
|
||||
) = execute(KickChatMember(chatId, userId, untilDate))
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chat.id, userId, untilDate)
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chatId, user.id, untilDate)
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chat.id, user.id, untilDate)
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.SetChatAdministratorCustomTitle
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.UnbanChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(UnbanChatMember(chatId, userId))
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId
|
||||
) = unbanChatMember(chat.id, userId)
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chatId: ChatId,
|
||||
user: User
|
||||
) = unbanChatMember(chatId, user.id)
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chat: PublicChat,
|
||||
user: User
|
||||
) = unbanChatMember(chat.id, user.id)
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.DeleteChatPhoto
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(DeleteChatPhoto(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||
chat: PublicChat
|
||||
) = deleteChatPhoto(chat.id)
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.PinChatMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
|
||||
suspend fun RequestsExecutor.pinChatMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = execute(PinChatMessage(chatId, messageId, disableNotification))
|
||||
|
||||
suspend fun RequestsExecutor.pinChatMessage(
|
||||
chat: PublicChat,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = pinChatMessage(chat.id, messageId, disableNotification)
|
||||
|
||||
suspend fun RequestsExecutor.pinChatMessage(
|
||||
message: Message,
|
||||
disableNotification: Boolean = false
|
||||
) = if (message.chat is PublicChat) {
|
||||
pinChatMessage(message.chat.id, message.messageId, disableNotification)
|
||||
} else {
|
||||
error("It is possible to pin messages only in non one-to-one chats")
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatDescription
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.setChatDescription(
|
||||
chatId: ChatIdentifier,
|
||||
description: String
|
||||
) = execute(SetChatDescription(chatId, description))
|
||||
|
||||
suspend fun RequestsExecutor.setChatDescription(
|
||||
chat: PublicChat,
|
||||
description: String
|
||||
) = setChatDescription(chat.id, description)
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatPermissions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||
chatId: ChatIdentifier,
|
||||
permissions: ChatPermissions
|
||||
) = execute(SetChatPermissions(chatId, permissions))
|
||||
|
||||
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||
chat: PublicChat,
|
||||
permissions: ChatPermissions
|
||||
) = setDefaultChatMembersPermissions(chat.id, permissions)
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatPhoto
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.setChatPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: MultipartFile
|
||||
) = execute(SetChatPhoto(chatId, photo))
|
||||
|
||||
suspend fun RequestsExecutor.setChatPhoto(
|
||||
chat: PublicChat,
|
||||
photo: MultipartFile
|
||||
) = setChatPhoto(chat.id, photo)
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatTitle
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.setChatTitle(
|
||||
chatId: ChatIdentifier,
|
||||
title: String
|
||||
) = execute(SetChatTitle(chatId, title))
|
||||
|
||||
suspend fun RequestsExecutor.setChatTitle(
|
||||
chat: PublicChat,
|
||||
title: String
|
||||
) = setChatTitle(chat.id, title)
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.UnpinChatMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun RequestsExecutor.unpinChatMessage(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(UnpinChatMessage(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.unpinChatMessage(
|
||||
chat: PublicChat
|
||||
) = unpinChatMessage(chat.id)
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers.DeleteChatStickerSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(DeleteChatStickerSet(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||
chat: SupergroupChat
|
||||
) = deleteChatStickerSet(chat.id)
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers.SetChatStickerSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.StickerSetName
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
||||
|
||||
suspend fun RequestsExecutor.setChatStickerSet(
|
||||
chatId: ChatIdentifier,
|
||||
stickerSetName: StickerSetName
|
||||
) = execute(SetChatStickerSet(chatId, stickerSetName))
|
||||
|
||||
suspend fun RequestsExecutor.setChatStickerSet(
|
||||
chat: SupergroupChat,
|
||||
stickerSetName: StickerSetName
|
||||
) = setChatStickerSet(chat.id, stickerSetName)
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditInlineMessageLiveLocation
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Location
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.editLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditInlineMessageLiveLocation(
|
||||
inlineMessageId, latitude, longitude, replyMarkup
|
||||
)
|
||||
)
|
||||
suspend fun RequestsExecutor.editLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
location: Location,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, replyMarkup)
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.StopChatMessageLiveLocation
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||
|
||||
suspend fun RequestsExecutor.stopLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopChatMessageLiveLocation(
|
||||
chatId, messageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.stopLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(chat.id, messageId, replyMarkup)
|
||||
|
||||
suspend fun RequestsExecutor.stopLiveLocation(
|
||||
message: ContentMessage<LocationContent>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.StopInlineMessageLiveLocation
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.stopLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopInlineMessageLiveLocation(
|
||||
inlineMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.ReplyMarkup
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditChatMessageReplyMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
|
||||
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
|
||||
|
||||
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.ReplyMarkup
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditInlineMessageReplyMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.caption
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditChatMessageCaption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
|
||||
|
||||
suspend fun <T> RequestsExecutor.editMessageCaption(
|
||||
message: ContentMessage<T>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
|
||||
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.caption
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditInlineMessageCaption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditChatMessageMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
|
||||
suspend fun RequestsExecutor.editMessageMedia(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageMedia(chatId, messageId, media, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.editMessageMedia(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
|
||||
|
||||
suspend fun RequestsExecutor.editMessageMedia(
|
||||
message: ContentMessage<out MediaContent>,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup)
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditInlineMessageMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.text
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditChatMessageText
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||
|
||||
suspend fun RequestsExecutor.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
|
||||
suspend fun RequestsExecutor.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.text
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditInlineMessageText
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.GetGameHighScoresByChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
userId: UserId,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier
|
||||
) = execute(
|
||||
GetGameHighScoresByChat(userId, chatId, messageId)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
user: CommonUser,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier
|
||||
) = getGameScore(
|
||||
user.id, chatId, messageId
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
userId: UserId,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
) = getGameScore(
|
||||
userId, chat.id, messageId
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
user: CommonUser,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
) = getGameScore(
|
||||
user.id, chat.id, messageId
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
userId: UserId,
|
||||
message: ContentMessage<GameContent>
|
||||
) = getGameScore(
|
||||
userId, message.chat.id, message.messageId
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
user: CommonUser,
|
||||
message: ContentMessage<GameContent>
|
||||
) = getGameScore(
|
||||
user.id, message.chat.id, message.messageId
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.GetGameHighScoresByInlineMessageId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
userId: UserId,
|
||||
inlineMessageId: InlineMessageIdentifier
|
||||
) = execute(
|
||||
GetGameHighScoresByInlineMessageId(
|
||||
userId, inlineMessageId
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getGameScore(
|
||||
user: CommonUser,
|
||||
inlineMessageId: InlineMessageIdentifier
|
||||
) = getGameScore(user.id, inlineMessageId)
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.TelegramMediaFile
|
||||
|
||||
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||
fileId: FileId
|
||||
) = execute(
|
||||
GetFile(fileId)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||
file: TelegramMediaFile
|
||||
) = getFileAdditionalInfo(file.fileId)
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetStickerSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||
|
||||
suspend fun RequestsExecutor.getStickerSet(
|
||||
name: String
|
||||
) = execute(
|
||||
GetStickerSet(name)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getStickerSet(
|
||||
sticker: Sticker
|
||||
) = getStickerSet(
|
||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||
)
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetUserProfilePhotos
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||
|
||||
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||
userId: UserId,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = execute(
|
||||
GetUserProfilePhotos(
|
||||
userId, offset, limit
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||
user: CommonUser,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = getUserProfilePhotos(user.id, offset, limit)
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
|
||||
suspend fun RequestsExecutor.sendBotAction(
|
||||
chatId: ChatIdentifier,
|
||||
action: BotAction
|
||||
) = execute(
|
||||
SendAction(chatId, action)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendBotAction(
|
||||
chat: Chat,
|
||||
action: BotAction
|
||||
) = sendBotAction(chat.id, action)
|
||||
|
||||
|
||||
suspend fun RequestsExecutor.sendActionTyping(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, TypingAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadPhotoAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordVideoAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadVideoAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordAudioAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadAudioAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadDocumentAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, FindLocationAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordVideoNoteAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadVideoNoteAction)
|
||||
|
||||
|
||||
suspend fun RequestsExecutor.sendActionTyping(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, TypingAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadPhotoAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordVideoAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadVideoAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordAudioAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadAudioAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadDocumentAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, FindLocationAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordVideoNoteAction)
|
||||
|
||||
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadVideoNoteAction)
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
|
||||
suspend fun RequestsExecutor.sendVenue(
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVenue(
|
||||
chatId, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendVenue(
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendVenue(
|
||||
chatId: ChatIdentifier,
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVenue(
|
||||
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendVenue(
|
||||
chat: Chat,
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
chat.id, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.games
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.games.SendGame
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||
|
||||
suspend fun RequestsExecutor.sendGame(
|
||||
chatId: ChatIdentifier,
|
||||
gameShortName: String,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendGame(
|
||||
chatId, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendGame(
|
||||
chat: Chat,
|
||||
gameShortName: String,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
chat.id, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendGame(
|
||||
chatId: ChatIdentifier,
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
chatId, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendGame(
|
||||
chat: Chat,
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
chat.id, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
||||
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendAnimation(
|
||||
chatId,
|
||||
animation,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||
|
||||
suspend fun RequestsExecutor.sendAudio(
|
||||
chatId: ChatIdentifier,
|
||||
audio: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
performer: String? = null,
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendAudio(
|
||||
chatId,
|
||||
audio,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
performer,
|
||||
title,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendAudio(
|
||||
chatId: ChatIdentifier,
|
||||
audio: AudioFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
title: String? = audio.title,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(
|
||||
chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||
|
||||
suspend fun RequestsExecutor.sendDocument(
|
||||
chatId: ChatIdentifier,
|
||||
document: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendDocument(
|
||||
chatId,
|
||||
document,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendDocument(
|
||||
chatId: ChatIdentifier,
|
||||
document: DocumentFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDocument(
|
||||
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendMediaGroup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
|
||||
suspend fun RequestsExecutor.sendMediaGroup(
|
||||
chatId: ChatIdentifier,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
) = execute(
|
||||
SendMediaGroup(
|
||||
chatId, media, disableNotification, replyToMessageId
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendMediaGroup(
|
||||
chat: Chat,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
) = sendMediaGroup(
|
||||
chat.id, media, disableNotification, replyToMessageId
|
||||
)
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
fileId: InputFile,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendPhoto(
|
||||
chatId,
|
||||
fileId,
|
||||
caption,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticker
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
|
||||
suspend fun RequestsExecutor.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: InputFile,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||
)
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideo
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVideo(
|
||||
chatId,
|
||||
video,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
null,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(
|
||||
chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideoNote
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||
|
||||
suspend fun RequestsExecutor.sendVideoNote(
|
||||
chatId: ChatIdentifier,
|
||||
videoNote: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
size: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVideoNote(
|
||||
chatId,
|
||||
videoNote,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
size,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendVideoNote(
|
||||
chatId: ChatIdentifier,
|
||||
videoNote: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(
|
||||
chatId, videoNote.fileId, videoNote.thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVoice(
|
||||
chatId,
|
||||
voice,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: AudioFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(
|
||||
chatId, voice.fileId, voice.thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,135 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.polls
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendQuizPoll
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendRegularPoll
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.QuizPoll
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.RegularPoll
|
||||
|
||||
suspend fun RequestsExecutor.sendRegularPoll(
|
||||
chatId: ChatIdentifier,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
allowMultipleAnswers: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendRegularPoll(
|
||||
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
suspend fun RequestsExecutor.sendRegularPoll(
|
||||
chatId: ChatIdentifier,
|
||||
poll: RegularPoll,
|
||||
isClosed: Boolean = false,
|
||||
question: String = poll.question,
|
||||
options: List<String> = poll.options.map { it.text },
|
||||
isAnonymous: Boolean = poll.isAnonymous,
|
||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendRegularPoll(
|
||||
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendRegularPoll(
|
||||
chat: Chat,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
allowMultipleAnswers: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendRegularPoll(
|
||||
chat: Chat,
|
||||
poll: RegularPoll,
|
||||
isClosed: Boolean = false,
|
||||
question: String = poll.question,
|
||||
options: List<String> = poll.options.map { it.text },
|
||||
isAnonymous: Boolean = poll.isAnonymous,
|
||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
|
||||
suspend fun RequestsExecutor.sendQuizPoll(
|
||||
chatId: ChatIdentifier,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendQuizPoll(
|
||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendQuizPoll(
|
||||
chat: Chat,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendQuizPoll(
|
||||
chatId: ChatIdentifier,
|
||||
isClosed: Boolean = false,
|
||||
quizPoll: QuizPoll,
|
||||
question: String = quizPoll.question,
|
||||
options: List<String> = quizPoll.options.map { it.text },
|
||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendQuizPoll(
|
||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.sendQuizPoll(
|
||||
chat: Chat,
|
||||
isClosed: Boolean = false,
|
||||
quizPoll: QuizPoll,
|
||||
question: String = quizPoll.question,
|
||||
options: List<String> = quizPoll.options.map { it.text },
|
||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.CreateNewStickerSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.DeleteStickerFromSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||
|
||||
suspend fun RequestsExecutor.deleteStickerFromSet(
|
||||
sticker: FileId
|
||||
) = execute(
|
||||
DeleteStickerFromSet(
|
||||
sticker
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.deleteStickerFromSet(
|
||||
sticker: Sticker
|
||||
) = deleteStickerFromSet(
|
||||
sticker.fileId
|
||||
)
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.SetStickerPositionInSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||
|
||||
suspend fun RequestsExecutor.setStickerPositionInSet(
|
||||
sticker: FileId,
|
||||
position: Int
|
||||
) = execute(
|
||||
SetStickerPositionInSet(
|
||||
sticker,
|
||||
position
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.setStickerPositionInSet(
|
||||
sticker: Sticker,
|
||||
position: Int
|
||||
) = setStickerPositionInSet(
|
||||
sticker.fileId,
|
||||
position
|
||||
)
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.UploadStickerFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||
|
||||
suspend fun RequestsExecutor.uploadStickerFile(
|
||||
userId: UserId,
|
||||
sticker: MultipartFile
|
||||
) = execute(
|
||||
UploadStickerFile(userId, sticker)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.uploadStickerFile(
|
||||
user: CommonUser,
|
||||
sticker: MultipartFile
|
||||
) = execute(
|
||||
UploadStickerFile(user.id, sticker)
|
||||
)
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.DeleteWebhook
|
||||
|
||||
suspend fun RequestsExecutor.deleteWebhook() = execute(DeleteWebhook())
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.GetWebhookInfo
|
||||
|
||||
suspend fun RequestsExecutor.getWebhookInfo() = execute(GetWebhookInfo())
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.SetWebhook
|
||||
|
||||
suspend fun RequestsExecutor.setWebhookInfo(
|
||||
url: String,
|
||||
certificate: FileId,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, maxAllowedConnections, allowedUpdates
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.setWebhookInfo(
|
||||
url: String,
|
||||
certificate: MultipartFile,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, maxAllowedConnections, allowedUpdates
|
||||
)
|
||||
)
|
||||
125
TelegramBotAPI.minder
Normal file
125
TelegramBotAPI.minder
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0"?>
|
||||
<minder version="1.11.1">
|
||||
<theme name="default" label="Default" index="-1"/>
|
||||
<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="1" 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="2" 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="3" 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="4" 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="5" 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="6" 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="7" 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="8" 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"/>
|
||||
</styles>
|
||||
<drawarea x="-320.56697591145837" y="-10.028254191080691" scale="0.75"/>
|
||||
<images/>
|
||||
<nodes>
|
||||
<node id="0" posx="748.88964843749955" posy="119.42341613769531" width="472" height="168" side="top" fold="false" treesize="603" 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"/>
|
||||
<nodename posx="764.88964843749955" posy="135.42341613769531" 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"/>
|
||||
</nodename>
|
||||
<nodenote></nodenote>
|
||||
<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">
|
||||
<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">
|
||||
<text data="TelegramBotAPI extensions Family of projects which are fully based on TelegramBotAPI and extend its functionality"/>
|
||||
</nodename>
|
||||
<nodenote></nodenote>
|
||||
<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">
|
||||
<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">
|
||||
<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>
|
||||
<nodenote></nodenote>
|
||||
</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">
|
||||
<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">
|
||||
<text data="tgbotapi.extensions.utils Extensions project with utils things which will make easier different operations"/>
|
||||
</nodename>
|
||||
<nodenote></nodenote>
|
||||
</node>
|
||||
</nodes>
|
||||
</node>
|
||||
</nodes>
|
||||
</node>
|
||||
<node id="4" posx="815.52319335937455" posy="948.04447937011719" width="329" height="213" side="top" fold="false" treesize="329" 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"/>
|
||||
<nodename posx="831.52319335937455" posy="964.04447937011719" maxwidth="394.3671875">
|
||||
<text data="tgbotapi Here included all available TelegramBotAPI libraries: * tgbotapi.core * tgbotapi.extensions.api * tgbotapi.extensions.utils">
|
||||
<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)"/>
|
||||
<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="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)"/>
|
||||
</color>
|
||||
</text>
|
||||
</nodename>
|
||||
<nodenote></nodenote>
|
||||
</node>
|
||||
</nodes>
|
||||
<groups/>
|
||||
<connections>
|
||||
<connection from_id="2" to_id="4" drag_x="905.70642089843705" drag_y="891.23394775390625" 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="4" drag_x="1056.456420898437" drag_y="885.48394775390625" color="#777777">
|
||||
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||
<title></title>
|
||||
<note></note>
|
||||
</connection>
|
||||
</connections>
|
||||
<stickers/>
|
||||
</minder>
|
||||
@@ -1,204 +0,0 @@
|
||||
# TelegramBotAPI
|
||||
|
||||
[](https://github.com/KotlinBy/awesome-kotlin)
|
||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI)
|
||||
[](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI_master__publishing/)
|
||||
|
||||
## What is it?
|
||||
|
||||
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
|
||||
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||
|
||||
## Compatibility
|
||||
|
||||
This version compatible with [23th of January 2020 update of TelegramBotAPI (version 4.6)](https://core.telegram.org/bots/api#january-23-2020).
|
||||
There is Telegram Passport API exception of implemented functionality, 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. All APIs that are not included are presented
|
||||
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Not-included-API).
|
||||
|
||||
## How to implement library?
|
||||
|
||||
Common ways to implement this library are presented here. In some cases it will require additional steps
|
||||
like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable
|
||||
`telegrambotapi.version`, which must be set up by developer. Available versions are presented on
|
||||
[bintray](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI), next version is last published:
|
||||
|
||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
||||
|
||||
Currently, last versions of library can be available from the Maven repository with errors (for the reason difficult in publishing
|
||||
of signed artifacts in Bintray). You can:
|
||||
|
||||
* Use earlier version (available version you can find
|
||||
[here](https://mvnrepository.com/artifact/com.github.insanusmokrassar/TelegramBotAPI))
|
||||
* Add `jCenter` repository in build config
|
||||
|
||||
### Maven
|
||||
|
||||
Dependency config presented here:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.github.insanusmokrassar</groupId>
|
||||
<artifactId>TelegramBotAPI</artifactId>
|
||||
<version>${telegrambotapi.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Gradle
|
||||
|
||||
To use last versions you will need to add one line in repositories block of your `build.gradle`:
|
||||
|
||||
`jcenter()` or `mavenCentral()`
|
||||
|
||||
And add next line to your dependencies block:
|
||||
|
||||
```groovy
|
||||
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
||||
```
|
||||
|
||||
or for old gradle:
|
||||
|
||||
```groovy
|
||||
compile "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
||||
```
|
||||
|
||||
## How to work with library?
|
||||
|
||||
For now, this library have no some API god-object. Instead of this, this library has several
|
||||
important objects:
|
||||
|
||||
* [RequestsExecutor](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/RequestsExecutor.kt)
|
||||
* [Requests](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests)
|
||||
* [Types](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types)
|
||||
|
||||
### Types
|
||||
|
||||
Types declare different objects representation. For example, `Chat` for now represented as
|
||||
interface and has several realisations:
|
||||
|
||||
* `PrivateChat`
|
||||
* `GroupChat`
|
||||
* `SupergroupChat`
|
||||
* `ChannelChat`
|
||||
|
||||
Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat),
|
||||
here it was separated for more obvious difference between chats types and their possible content.
|
||||
|
||||
The same principle work with a lot of others things in this Telegram bot API.
|
||||
|
||||
### Requests
|
||||
|
||||
Requests usually are very simple objects, but some of them are using their own
|
||||
build factories. For example, the next code show, how to get information about bot:
|
||||
|
||||
```kotlin
|
||||
val requestsExecutor: RequestsExecutor = ...
|
||||
requestsExecutor.execute(GetMe())
|
||||
```
|
||||
|
||||
Also there is an alternative syntax for requests (like `requestsExecutor.getMe()` in project
|
||||
[TelegramBotAPI-extensions-api](../TelegramBotAPI-extensions-api/README.md))
|
||||
|
||||
The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
|
||||
request is
|
||||
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
|
||||
|
||||
### RequestsExecutor
|
||||
|
||||
It is base object which can be used to execute requests in API. For now by default included Ktor
|
||||
realisation of `RequestsExecutor`, but it is possible, that in future it will be extracted in separated
|
||||
project. How to create `RequestsExecutor`:
|
||||
|
||||
```kotlin
|
||||
val requestsExecutor = KtorRequestsExecutor(
|
||||
TelegramAPIUrlsKeeper(TOKEN)
|
||||
)
|
||||
```
|
||||
|
||||
Here:
|
||||
|
||||
* `KtorRequestsExecutor` - default realisation with [ktor](https://ktor.io)
|
||||
* `TelegramAPIUrlsKeeper` - special keeper, which you can save and use for getting files full urls (`resolveFileURL`
|
||||
extension inside of `PathedFile.kt`)
|
||||
* `TOKEN` is just a token of bot which was retrieved according to
|
||||
[instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
|
||||
|
||||
By default, for JVM there is implemented `CIO` client engine, but there is not server engine. Both can be changed like
|
||||
here:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
// ...
|
||||
implementation "io.ktor:ktor-server-cio:$ktor_version" // for implementing of server engine
|
||||
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
You can avoid using of `server` dependency in case if you will not use `Webhook`s. In this case,
|
||||
dependencies list will be simplify:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
// ...
|
||||
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
Here was used `okhttp` realisation of client, but there are several others engines for Ktor. More information
|
||||
available on ktor.io site for [client](https://ktor.io/clients/http-client/engines.html) and [server](https://ktor.io/quickstart/artifacts.html)
|
||||
engines.
|
||||
|
||||
## Getting updates
|
||||
|
||||
In this library currently realised two ways to get updates from telegram:
|
||||
|
||||
* Polling - in this case bot will request updates from time to time (you can set up delay between requests)
|
||||
* Webhook via reverse proxy or something like this
|
||||
|
||||
### Updates filters
|
||||
|
||||
Currently webhook method contains `UpdatesFilter` as necessary argument for getting updates.
|
||||
`UpdatesFilter` will sort updates and throw their into different callbacks. Currently supporting
|
||||
separate getting updates for media groups - they are accumulating with debounce in one second
|
||||
(for being sure that all objects of media group was received).
|
||||
|
||||
Updates polling also support `UpdatesFilter` but it is not required to use it and you can get updates directly
|
||||
in `UpdateReceiver`, which you will provide to `startGettingOfUpdates` method
|
||||
|
||||
### Webhook set up
|
||||
|
||||
If you wish to use webhook method, you will need:
|
||||
|
||||
* White IP - your IP address or host, which available for calling. [TelegramBotAPI](https://core.telegram.org/bots/api#setwebhook)
|
||||
recommend to use some unique address for each bot which you are using
|
||||
* SSL certificate. Usually you can obtain the certificate using your domain provider, [Let'sEncrypt](https://letsencrypt.org/) or [create it](https://core.telegram.org/bots/self-signed)
|
||||
* Nginx or something like this
|
||||
|
||||
Template for Nginx server config you can find in [this gist](https://gist.github.com/InsanusMokrassar/fcc6e09cebd07e46e8f0fdec234750c4#file-nginxssl-conf).
|
||||
|
||||
For webhook you can provide `File` with public part of certificate, `URL` where bot will be available and inner `PORT` which
|
||||
will be used to start receiving of updates. Actually, you can skip passing of `File` when you have something like
|
||||
nginx for proxy forwarding.
|
||||
|
||||
In case of using `nginx` with reverse-proxy config, setting up of Webhook will look like:
|
||||
|
||||
```kotlin
|
||||
requestsExecutor.setWebhook(
|
||||
WEBHOOK_URL,
|
||||
INTERNAL_PORT,
|
||||
filter,
|
||||
ENGINE_FACTORY
|
||||
)
|
||||
```
|
||||
|
||||
Here:
|
||||
|
||||
* `WEBHOOK_URL` - the url which will be used by Telegram system to send updates
|
||||
* `INTERNAL_PORT` - the port which will be used in bot for listening of updates
|
||||
* `filter` - instance of [UpdatesFilter](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt),
|
||||
which will be used to filter incoming updates
|
||||
* `ENGINE_FACTORY` - used factory name, for example, `CIO` in case of usage `io.ktor:ktor-server-cio` as server engine
|
||||
@@ -1,57 +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.withXml {
|
||||
asNode().children().last() + {
|
||||
resolveStrategy = Closure.DELEGATE_FIRST
|
||||
|
||||
description "Library for Object-Oriented and type-safe work with Telegram Bot API"
|
||||
name "Telegram Bot API"
|
||||
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 +0,0 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"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","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"}]}}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.fullListOfSubSource
|
||||
|
||||
interface Captioned {
|
||||
val caption: String?
|
||||
}
|
||||
|
||||
interface CaptionedOutput : Captioned {
|
||||
val parseMode: ParseMode?
|
||||
}
|
||||
|
||||
interface CaptionedInput : Captioned {
|
||||
val captionEntities: List<TextPart>
|
||||
}
|
||||
|
||||
fun CaptionedInput.fullEntitiesList() = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList()
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
||||
|
||||
interface MimeTyped {
|
||||
val mimeType: String? // TODO::replace by something like enum or interface
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
||||
|
||||
interface Performerable {
|
||||
val performer: String?
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
||||
|
||||
interface Titled {
|
||||
val title: String?
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
|
||||
interface ChatRequest {
|
||||
val chatId: ChatIdentifier
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||
|
||||
interface DisableNotification {
|
||||
val disableNotification: Boolean
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||
|
||||
interface InlineMessageAction {
|
||||
val inlineMessageId: InlineMessageIdentifier
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
|
||||
interface MessageAction: ChatRequest {
|
||||
val messageId: MessageIdentifier
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
|
||||
interface ReplyMarkup {
|
||||
val replyMarkup: KeyboardMarkup?
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
|
||||
interface ReplyMessageId {
|
||||
val replyToMessageId: MessageIdentifier?
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate
|
||||
|
||||
interface UntilDate {
|
||||
val untilDate: TelegramDate?
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||
|
||||
abstract class BaseRequestsExecutor(
|
||||
protected val telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
||||
) : RequestsExecutor
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.statement.HttpStatement
|
||||
|
||||
interface KtorCallFactory {
|
||||
suspend fun <T: Any> prepareCall(
|
||||
client: HttpClient,
|
||||
baseUrl: String,
|
||||
request: Request<T>
|
||||
) : HttpStatement?
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.MultipartRequestCallFactory
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.SimpleRequestCallFactory
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.newRequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.receive
|
||||
import io.ktor.client.features.*
|
||||
import io.ktor.client.statement.HttpStatement
|
||||
import io.ktor.client.statement.readText
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
class KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient = HttpClient(),
|
||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||
excludeDefaultFactories: Boolean = false,
|
||||
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
||||
private val jsonFormatter: Json = nonstrictJsonFormat
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||
if (!excludeDefaultFactories) {
|
||||
asSequence().plus(SimpleRequestCallFactory()).plus(MultipartRequestCallFactory()).toList()
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
private val client = client.config {
|
||||
if (client.feature(HttpTimeout) == null) {
|
||||
install(HttpTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> execute(request: Request<T>): T {
|
||||
return try {
|
||||
supervisorScope {
|
||||
requestsLimiter.limit {
|
||||
var statement: HttpStatement? = null
|
||||
for (factory in callsFactories) {
|
||||
statement = factory.prepareCall(
|
||||
client,
|
||||
telegramAPIUrlsKeeper.commonAPIUrl,
|
||||
request
|
||||
)
|
||||
if (statement != null) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
val response = statement?.execute() ?: throw IllegalArgumentException("Can't execute request: $request")
|
||||
val content = response.receive<String>()
|
||||
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||
|
||||
(responseObject.result?.let {
|
||||
jsonFormatter.fromJson(request.resultDeserializer, it)
|
||||
} ?: responseObject.parameters?.let {
|
||||
val error = it.error
|
||||
if (error is RetryAfterError) {
|
||||
delay(error.leftToRetry)
|
||||
execute(request)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} ?: response.let {
|
||||
throw newRequestException(
|
||||
responseObject,
|
||||
content,
|
||||
"Can't get result object from $content"
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (e: ClientRequestException) {
|
||||
val content = e.response.readText()
|
||||
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||
throw newRequestException(
|
||||
responseObject,
|
||||
content,
|
||||
"Can't get result object from $content"
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
client.close()
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.features.timeout
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.HttpStatement
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.HttpMethod
|
||||
import kotlin.collections.set
|
||||
|
||||
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
||||
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
||||
override suspend fun <T : Any> prepareCall(
|
||||
client: HttpClient,
|
||||
baseUrl: String,
|
||||
request: Request<T>
|
||||
): HttpStatement? {
|
||||
val preparedBody = prepareCallBody(client, baseUrl, request) ?: return null
|
||||
|
||||
return HttpStatement(
|
||||
HttpRequestBuilder().apply {
|
||||
url(
|
||||
methodsCache[request.method()] ?: "$baseUrl/${request.method()}".also {
|
||||
methodsCache[request.method()] = it
|
||||
}
|
||||
)
|
||||
method = HttpMethod.Post
|
||||
accept(ContentType.Application.Json)
|
||||
|
||||
if (request is GetUpdates) {
|
||||
request.timeout ?.times(1000L) ?.let { customTimeoutMillis ->
|
||||
if (customTimeoutMillis > 0) {
|
||||
timeout {
|
||||
requestTimeoutMillis = customTimeoutMillis
|
||||
socketTimeoutMillis = customTimeoutMillis
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body = preparedBody
|
||||
},
|
||||
client
|
||||
)
|
||||
}
|
||||
|
||||
protected abstract fun <T : Any> prepareCallBody(
|
||||
client: HttpClient,
|
||||
baseUrl: String,
|
||||
request: Request<T>
|
||||
): Any?
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
|
||||
interface RequestsExecutor : Closeable {
|
||||
/**
|
||||
* @throws com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
||||
*/
|
||||
suspend fun <T : Any> execute(request: Request<T>): T
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
private val updatesListSerializer = ListSerializer(
|
||||
UpdateSerializerWithoutDeserialization
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GetUpdates(
|
||||
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
||||
val limit: Int? = null,
|
||||
val timeout: Seconds? = null,
|
||||
val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
): SimpleRequest<List<Update>> {
|
||||
override fun method(): String = "getUpdates"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<List<Update>>
|
||||
get() = updatesListSerializer
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||
|
||||
interface ChatMemberRequest<T: Any> : ChatRequest, SimpleRequest<T> {
|
||||
val userId: UserId
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ExtendedChatSerializer
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetChat(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<ExtendedChat> {
|
||||
override fun method(): String = "getChat"
|
||||
override val resultDeserializer: DeserializationStrategy<ExtendedChat>
|
||||
get() = ExtendedChatSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
|
||||
interface EditChatMessage<MT: MessageContent> : SimpleRequest<ContentMessage<MT>>, MessageAction
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||
|
||||
interface EditMediaMessage {
|
||||
val media: InputMedia
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
interface EditReplyMessage : ReplyMarkup {
|
||||
override val replyMarkup: InlineKeyboardMarkup?
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
|
||||
interface EditTextChatMessage {
|
||||
val text: String
|
||||
val parseMode: ParseMode?
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
||||
|
||||
interface ReplyingMarkupSendMessageRequest<T: Any>: SendMessageRequest<T>, ReplyMarkup
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user