mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-17 12:30:20 +00:00
Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ced11ab336 | |||
| 6686aef4fa | |||
| 9ede545e56 | |||
| a74066cf62 | |||
| 0a7e99bbb3 | |||
| 913f584469 | |||
| 20278804bf | |||
| 631f1b9427 | |||
| 5e0106beb5 | |||
| d37e01f93e | |||
|
|
d4492ec7ac | ||
| 60d24259f4 | |||
| 8e6b3b7260 | |||
| e2cbd5ee0b | |||
| 1e87677ea7 | |||
| cb3494cb39 | |||
| ce81be9dcb | |||
| 2cc02c8c85 | |||
| f5b2ee79d6 | |||
| 0ba6ebb20f | |||
| 3d2df4e255 | |||
| 33b6ff1c1e | |||
| 2859f8ca2f | |||
| f1aa67ceda | |||
| 1c66d1e2fc | |||
| 44e6d7adbc | |||
| 61a6d4a880 | |||
| e37237cb71 | |||
| 9a5a196e41 | |||
| 68f6d8553c | |||
| 6fe8e73fca | |||
| 241545c0cb | |||
| 3b2310ece1 | |||
| e1adde0978 | |||
| 3b17bce71a | |||
| 999efc64eb | |||
| 05c99642cb | |||
| cd6f4831ae | |||
| 2778315aed | |||
| ff8d67a780 | |||
| 2a5f9a629d | |||
| 75b27858dd | |||
| 034e2d7ff3 | |||
| 1f69c16f2a | |||
| 8d24512413 | |||
| 09009003e3 | |||
| 048486146c | |||
| b688fa570a | |||
| 0eba0c4e15 | |||
| f8bbfa2b1e | |||
| fec2715dc1 | |||
|
|
941a25b116 | ||
| 741d808db2 | |||
| 69683a4e6a | |||
| e5a48e9684 | |||
| 6722ab5f50 | |||
| 810b2ab5a1 | |||
| 5992fdd456 | |||
| 3c4f8787a6 | |||
| 0c24aa1270 | |||
| 988d9995c5 | |||
| f75df0a425 | |||
| 9f14eb2ca3 | |||
| 6f9f880b79 | |||
| 2d2310daca | |||
| dff04d26ca | |||
| 4390c12180 | |||
| 1b4d13e452 | |||
| afda5e0e7f | |||
| cd354e9456 | |||
| b0e32e8ad9 | |||
| 79c9e6258f | |||
| 90b9c66bea | |||
| e7b21dcd3d | |||
| e30361ad1e | |||
| d8c659f866 | |||
| 5533303d86 | |||
| 1633b9baaf | |||
| a9725eb439 | |||
| a0aadef31b | |||
| ac88fd1d02 | |||
| e3e318312d | |||
| 4c08fb7d26 | |||
| d83ff12560 | |||
| 818ef8481d | |||
| f8cd446133 | |||
| 804b991921 | |||
| 817068aa71 | |||
|
|
0cca343612 | ||
| 6532bf255b |
4
.github/workflows/kdocs.yml
vendored
4
.github/workflows/kdocs.yml
vendored
@@ -12,10 +12,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: 11
|
java-version: 11
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew dokkaHtml
|
run: ./gradlew dokkaHtmlMultiModule
|
||||||
- name: Publish KDocs
|
- name: Publish KDocs
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./docs/build/dokka/html
|
publish_dir: ./build/dokka/htmlMultiModule
|
||||||
publish_branch: kdocs
|
publish_branch: kdocs
|
||||||
|
|||||||
4
.github/workflows/packages_publishing.yml
vendored
4
.github/workflows/packages_publishing.yml
vendored
@@ -8,12 +8,16 @@ jobs:
|
|||||||
- uses: actions/setup-java@v1
|
- uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
java-version: 11
|
||||||
|
- name: Setup LibCurl
|
||||||
|
run: sudo apt install -y libcurl4-openssl-dev
|
||||||
- name: Rewrite version
|
- name: Rewrite version
|
||||||
run: |
|
run: |
|
||||||
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
||||||
cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
|
cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
|
||||||
rm gradle.properties
|
rm gradle.properties
|
||||||
mv gradle.properties.tmp gradle.properties
|
mv gradle.properties.tmp gradle.properties
|
||||||
|
- name: KotlinSymbolProcessing execution
|
||||||
|
run: ./gradlew ksp
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
- name: Publish to Gitea
|
- name: Publish to Gitea
|
||||||
|
|||||||
73
CHANGELOG.md
73
CHANGELOG.md
@@ -1,5 +1,78 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 7.1.2
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `MicroUtils`: `0.18.0` -> `0.18.1`
|
||||||
|
* `Core`:
|
||||||
|
* Now it is possible to serialize `Sticker`s
|
||||||
|
|
||||||
|
## 7.1.1
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Kotlin`: `1.8.20` -> `1.8.21`
|
||||||
|
* `MicroUtils`: `0.17.8` -> `0.18.0`
|
||||||
|
* `Utils`:
|
||||||
|
* Fixes in `makeLinkToMessage`
|
||||||
|
|
||||||
|
## 7.1.0
|
||||||
|
|
||||||
|
**This update contains changes according to the [Telegram Bot API 6.7](https://core.telegram.org/bots/api-changelog#april-21-2023)**
|
||||||
|
|
||||||
|
* `API`:
|
||||||
|
* Rename `editMessageCaption` to `editMessageMedia` due to wrong old naming
|
||||||
|
* Add `edit` extensions for `InlineMessageIdentifier`s
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* `BehaviourContext` extensions `onDeepLink` and `waitDeepLinks` now can be used with `Regex` or `String` as first parameters
|
||||||
|
|
||||||
|
## 7.0.2
|
||||||
|
|
||||||
|
_This update brings experimental support of `linuxX64` and `mingwX64` platforms_
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Kotlin`: `1.8.10` -> `1.8.20`
|
||||||
|
* `MicroUtils`: `0.17.5` -> `0.17.8`
|
||||||
|
* `Ktor`: `2.2.4` -> `2.3.0`
|
||||||
|
* `Core`:
|
||||||
|
* New `RequestsExecutor` - `MultipleClientKtorRequestsExecutor`
|
||||||
|
* Old `KtorRequestsExecutor` has been renamed to `DefaultKtorRequestsExecutor`
|
||||||
|
* `KtorRequestsExecutor` now is `expect class`
|
||||||
|
* On `JS`, `JVM` and `MinGWX64` platforms it is `DefaultKtorRequestsExecutor`
|
||||||
|
* On `LinuxX64` platform it is `MultipleClientKtorRequestsExecutor`
|
||||||
|
|
||||||
|
## 7.0.1
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* New interface `WithChat` which contains `chat` field
|
||||||
|
* `Message` now inherits `WithChat`
|
||||||
|
* `ChatMemberUpdated` now inherits `WithChat`
|
||||||
|
* `Utils`:
|
||||||
|
* Improvements in `same`-notations
|
||||||
|
|
||||||
|
## 7.0.0
|
||||||
|
|
||||||
|
This update contains support of [Telegram Bot API 6.6](https://core.telegram.org/bots/api-changelog#march-9-2023)
|
||||||
|
|
||||||
|
**THIS VERSION CONTAINS BREAKING CHANGES**:
|
||||||
|
|
||||||
|
* All previous deprecations have been removed
|
||||||
|
* Fully reworked mechanism of stickers creating and adding
|
||||||
|
* All separations of stickers types like `Animeted` have been replaces with type `StickerFormat`
|
||||||
|
* New `InputSticker` type (and all subtypes) as replacements for old raw fields in methods
|
||||||
|
* Reworked mechanism of files uploading
|
||||||
|
|
||||||
|
Other changes
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `MicroUtils`: `0.17.3` -> `0.17.5`
|
||||||
|
|
||||||
|
## 6.1.0
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `MicroUtils`: `0.17.2` -> `0.17.3`
|
||||||
|
* `API`:
|
||||||
|
* Fix of [#732](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/732)
|
||||||
|
|
||||||
## 6.0.3
|
## 6.0.3
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -1,9 +1,11 @@
|
|||||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#february-3-2023)
|
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-21-2023)
|
||||||
|
|
||||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
|:---:|:---:|
|
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
||||||
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
||||||
|
| Platforms |   |
|
||||||
|
| Experimental Platforms | [](https://kotlinlang.org/docs/native-target-support.html#tier-1) [](https://kotlinlang.org/docs/native-target-support.html#tier-1) |
|
||||||
|
|
||||||
<!--- [](https://t.me/ktgbotapi) --->
|
<!--- [](https://t.me/ktgbotapi) --->
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.kotlin.dokka)
|
||||||
|
}
|
||||||
|
|
||||||
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=6.0.3
|
library_version=7.1.2
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "1.8.10"
|
kotlin = "1.8.21"
|
||||||
kotlin-serialization = "1.5.0"
|
kotlin-serialization = "1.5.0"
|
||||||
kotlin-coroutines = "1.6.4"
|
kotlin-coroutines = "1.6.4"
|
||||||
|
|
||||||
@@ -8,15 +8,15 @@ javax-activation = "1.1.1"
|
|||||||
|
|
||||||
korlibs = "3.4.0"
|
korlibs = "3.4.0"
|
||||||
uuid = "0.7.0"
|
uuid = "0.7.0"
|
||||||
ktor = "2.2.4"
|
ktor = "2.3.0"
|
||||||
|
|
||||||
ksp = "1.8.10-1.0.9"
|
ksp = "1.8.21-1.0.11"
|
||||||
kotlin-poet = "1.12.0"
|
kotlin-poet = "1.13.2"
|
||||||
|
|
||||||
microutils = "0.17.2"
|
microutils = "0.18.1"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
dokka = "1.7.20"
|
dokka = "1.8.10"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
||||||
@@ -31,6 +31,8 @@ kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref =
|
|||||||
|
|
||||||
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
||||||
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
||||||
|
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
|
||||||
|
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
|
||||||
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
|
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
|
||||||
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
|
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
|
||||||
|
|
||||||
@@ -45,6 +47,7 @@ microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.re
|
|||||||
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" }
|
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" }
|
||||||
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
|
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
|
||||||
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" }
|
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" }
|
||||||
|
microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization.mapper", version.ref = "microutils" }
|
||||||
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
|
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
|
||||||
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
||||||
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
||||||
@@ -67,3 +70,4 @@ github-release-plugin = { module = "com.github.breadmoirai:github-release", vers
|
|||||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||||
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||||
|
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ kotlin {
|
|||||||
browser()
|
browser()
|
||||||
nodejs()
|
nodejs()
|
||||||
}
|
}
|
||||||
|
linuxX64()
|
||||||
|
mingwX64()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
|
|||||||
@@ -19,4 +19,3 @@ include ":tgbotapi.behaviour_builder"
|
|||||||
include ":tgbotapi.behaviour_builder.fsm"
|
include ":tgbotapi.behaviour_builder.fsm"
|
||||||
include ":tgbotapi"
|
include ":tgbotapi"
|
||||||
include ":tgbotapi.webapps"
|
include ":tgbotapi.webapps"
|
||||||
include ":docs"
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "org.jetbrains.kotlin.multiplatform"
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "org.jetbrains.dokka"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor"
|
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor"
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import dev.inmo.tgbotapi.requests.DeleteMessage
|
|||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageId
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||||
|
|
||||||
suspend fun TelegramBot.deleteMessage(
|
suspend fun TelegramBot.deleteMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@@ -21,7 +24,16 @@ suspend fun TelegramBot.deleteMessage(
|
|||||||
|
|
||||||
suspend fun TelegramBot.deleteMessage(
|
suspend fun TelegramBot.deleteMessage(
|
||||||
message: Message
|
message: Message
|
||||||
) = deleteMessage(message.chat, message.messageId)
|
): Boolean {
|
||||||
|
val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>)
|
||||||
|
if (mediaGroupContent == null) {
|
||||||
|
return deleteMessage(message.chat, message.messageId)
|
||||||
|
} else {
|
||||||
|
return mediaGroupContent.group.map {
|
||||||
|
deleteMessage(it.sourceMessage)
|
||||||
|
}.all { it }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun TelegramBot.delete(
|
suspend fun TelegramBot.delete(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.answers
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery
|
import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery
|
||||||
|
import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
||||||
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||||
@@ -12,8 +13,37 @@ suspend fun TelegramBot.answerInlineQuery(
|
|||||||
cachedTime: Int? = null,
|
cachedTime: Int? = null,
|
||||||
isPersonal: Boolean? = null,
|
isPersonal: Boolean? = null,
|
||||||
nextOffset: String? = null,
|
nextOffset: String? = null,
|
||||||
switchPmText: String? = null,
|
button: InlineQueryResultsButton? = null
|
||||||
switchPmParameter: String? = null
|
) = execute(
|
||||||
|
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, button)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.answerInlineQuery(
|
||||||
|
inlineQuery: InlineQuery,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
button: InlineQueryResultsButton? = null
|
||||||
|
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.answer(
|
||||||
|
inlineQuery: InlineQuery,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
button: InlineQueryResultsButton? = null
|
||||||
|
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.answerInlineQuery(
|
||||||
|
inlineQueryID: InlineQueryIdentifier,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
switchPmText: String?,
|
||||||
|
switchPmParameter: String?
|
||||||
) = execute(
|
) = execute(
|
||||||
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||||
)
|
)
|
||||||
@@ -24,8 +54,8 @@ suspend fun TelegramBot.answerInlineQuery(
|
|||||||
cachedTime: Int? = null,
|
cachedTime: Int? = null,
|
||||||
isPersonal: Boolean? = null,
|
isPersonal: Boolean? = null,
|
||||||
nextOffset: String? = null,
|
nextOffset: String? = null,
|
||||||
switchPmText: String? = null,
|
switchPmText: String?,
|
||||||
switchPmParameter: String? = null
|
switchPmParameter: String?
|
||||||
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||||
|
|
||||||
suspend fun TelegramBot.answer(
|
suspend fun TelegramBot.answer(
|
||||||
@@ -34,6 +64,6 @@ suspend fun TelegramBot.answer(
|
|||||||
cachedTime: Int? = null,
|
cachedTime: Int? = null,
|
||||||
isPersonal: Boolean? = null,
|
isPersonal: Boolean? = null,
|
||||||
nextOffset: String? = null,
|
nextOffset: String? = null,
|
||||||
switchPmText: String? = null,
|
switchPmText: String?,
|
||||||
switchPmParameter: String? = null
|
switchPmParameter: String?
|
||||||
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getMyDescription(
|
||||||
|
languageCode: IetfLanguageCode? = null
|
||||||
|
) = execute(GetMyDescription(languageCode))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getMyDescription(
|
||||||
|
languageCode: String?
|
||||||
|
) = getMyDescription(languageCode ?.let(::IetfLanguageCode))
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getMyName(
|
||||||
|
languageCode: IetfLanguageCode? = null
|
||||||
|
) = execute(GetMyName(languageCode))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getMyName(
|
||||||
|
languageCode: String?
|
||||||
|
) = getMyName(languageCode ?.let(::IetfLanguageCode))
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getMyShortDescription(
|
||||||
|
languageCode: IetfLanguageCode? = null
|
||||||
|
) = execute(GetMyShortDescription(languageCode))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getMyShortDescription(
|
||||||
|
languageCode: String?
|
||||||
|
) = getMyShortDescription(languageCode ?.let(::IetfLanguageCode))
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.SetMyDescription
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMyDescription(
|
||||||
|
description: String? = null,
|
||||||
|
languageCode: IetfLanguageCode? = null
|
||||||
|
) = execute(SetMyDescription(description, languageCode))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMyDescription(
|
||||||
|
description: String?,
|
||||||
|
languageCode: String?
|
||||||
|
) = setMyDescription(description, languageCode ?.let(::IetfLanguageCode))
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.SetMyName
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
|
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMyName(
|
||||||
|
name: String? = null,
|
||||||
|
languageCode: IetfLanguageCode? = null
|
||||||
|
) = execute(SetMyName(name, languageCode))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMyName(
|
||||||
|
name: String?,
|
||||||
|
languageCode: String?
|
||||||
|
) = setMyName(name, languageCode ?.let(::IetfLanguageCode))
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMyShortDescription(
|
||||||
|
shortDescription: String? = null,
|
||||||
|
languageCode: IetfLanguageCode? = null
|
||||||
|
) = execute(SetMyShortDescription(shortDescription, languageCode))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMyShortDescription(
|
||||||
|
shortDescription: String?,
|
||||||
|
languageCode: String?
|
||||||
|
) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLanguageCode))
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.edit
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.TextedWithTextSources
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.caption.editMessageCaption
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.media.editMessageMedia
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.media.TelegramMedia
|
||||||
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
|
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||||
|
import dev.inmo.tgbotapi.utils.buildEntities
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
location: LiveLocation,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(
|
||||||
|
messageId, location, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
media: TelegramMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageMedia(messageId, media, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageReplyMarkup(messageId, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageText(messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageText(messageId, entities, disableWebPagePreview, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
separator: TextSource? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
|
builderBody: EntitiesBuilderBody
|
||||||
|
) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.edit(
|
||||||
|
messageId: InlineMessageIdentifier,
|
||||||
|
separator: String,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
|
builderBody: EntitiesBuilderBody
|
||||||
|
) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||||
@@ -10,6 +10,17 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
suspend fun TelegramBot.editMessageMedia(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
media: TelegramMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("this.editMessageMedia(inlineMessageId, media, replyMarkup)", "dev.inmo.tgbotapi.extensions.api.edit.media.editMessageMedia"))
|
||||||
suspend fun TelegramBot.editMessageCaption(
|
suspend fun TelegramBot.editMessageCaption(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
media: TelegramMedia,
|
media: TelegramMedia,
|
||||||
|
|||||||
@@ -10,13 +10,6 @@ suspend fun TelegramBot.getStickerSet(
|
|||||||
GetStickerSet(name)
|
GetStickerSet(name)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("getStickerSetOrThrow(sticker)", "dev.inmo.tgbotapi.extensions.api.get.getStickerSetOrThrow"))
|
|
||||||
suspend fun TelegramBot.getStickerSet(
|
|
||||||
sticker: Sticker
|
|
||||||
) = getStickerSet(
|
|
||||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getStickerSetOrNull(
|
suspend fun TelegramBot.getStickerSetOrNull(
|
||||||
sticker: Sticker
|
sticker: Sticker
|
||||||
) = sticker.stickerSetName ?.let {
|
) = sticker.stickerSetName ?.let {
|
||||||
|
|||||||
@@ -685,20 +685,22 @@ suspend inline fun TelegramBot.reply(
|
|||||||
suspend inline fun TelegramBot.replyWithSticker(
|
suspend inline fun TelegramBot.replyWithSticker(
|
||||||
to: Message,
|
to: Message,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
suspend inline fun TelegramBot.reply(
|
suspend inline fun TelegramBot.reply(
|
||||||
to: Message,
|
to: Message,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
// Videos
|
// Videos
|
||||||
|
|||||||
@@ -761,22 +761,24 @@ suspend inline fun TelegramBot.replyWithSticker(
|
|||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
suspend inline fun TelegramBot.reply(
|
suspend inline fun TelegramBot.reply(
|
||||||
toChatId: IdChatIdentifier,
|
toChatId: IdChatIdentifier,
|
||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
// Videos
|
// Videos
|
||||||
|
|||||||
@@ -1111,12 +1111,13 @@ suspend fun TelegramBot.send(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will execute [sendSticker] request
|
* Will execute [sendSticker] request
|
||||||
@@ -1127,12 +1128,13 @@ suspend fun TelegramBot.send(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chat, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chat, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ suspend fun TelegramBot.sendAnimation(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendAnimation(
|
) = sendAnimation(
|
||||||
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
chatId, animation.fileId, animation.thumbnail ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,7 +177,7 @@ suspend fun TelegramBot.sendAnimation(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendAnimation(
|
) = sendAnimation(
|
||||||
chatId, animation.fileId, animation.thumb ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
chatId, animation.fileId, animation.thumbnail ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ suspend fun TelegramBot.sendAudio(
|
|||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -180,7 +180,7 @@ suspend inline fun TelegramBot.sendAudio(
|
|||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ suspend fun TelegramBot.sendDocument(
|
|||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
disableContentTypeDetection: Boolean? = null
|
disableContentTypeDetection: Boolean? = null
|
||||||
) = sendDocument(
|
) = sendDocument(
|
||||||
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
chatId, document.fileId, document.thumbnail ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,7 +170,7 @@ suspend inline fun TelegramBot.sendDocument(
|
|||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
disableContentTypeDetection: Boolean? = null
|
disableContentTypeDetection: Boolean? = null
|
||||||
) = sendDocument(
|
) = sendDocument(
|
||||||
chatId, document.fileId, document.thumb ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
chatId, document.fileId, document.thumbnail ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
SendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,12 +37,13 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chat.id, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chat.id, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -51,12 +53,13 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chatId, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chatId, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -66,9 +69,10 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chat, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chat, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ suspend fun TelegramBot.sendVideo(
|
|||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -167,7 +167,7 @@ suspend inline fun TelegramBot.sendVideo(
|
|||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ suspend fun TelegramBot.sendVideoNote(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendVideoNote(
|
) = sendVideoNote(
|
||||||
chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
chatId, videoNote.fileId, videoNote.thumbnail ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.AddAnimatedStickerToSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.AddStaticStickerToSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.AddStickerToSet
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||||
|
import dev.inmo.tgbotapi.types.StickerType
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
inputSticker: InputSticker
|
||||||
|
) = execute(
|
||||||
|
AddStickerToSet(userId, stickerSetName, inputSticker)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputSticker
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId,
|
||||||
|
stickerSet.name,
|
||||||
|
sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
keywords: List<String> = emptyList()
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId,
|
||||||
|
stickerSet,
|
||||||
|
when (stickerSet.stickerType) {
|
||||||
|
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
keywords
|
||||||
|
)
|
||||||
|
StickerType.Mask -> InputSticker.Mask(
|
||||||
|
sticker,
|
||||||
|
emojis
|
||||||
|
)
|
||||||
|
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
keywords
|
||||||
|
)
|
||||||
|
is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId,
|
||||||
|
stickerSet.name,
|
||||||
|
when (stickerSet.stickerType) {
|
||||||
|
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
emptyList()
|
||||||
|
)
|
||||||
|
StickerType.Mask -> InputSticker.Mask(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
maskPosition
|
||||||
|
)
|
||||||
|
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
emptyList()
|
||||||
|
)
|
||||||
|
is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputSticker
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id,
|
||||||
|
stickerSet.name,
|
||||||
|
sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
keywords: List<String> = emptyList()
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSet, sticker, emojis, keywords
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSet, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.AddVideoStickerToSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewAnimatedStickerSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewStaticStickerSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewStaticStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewStaticStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.CreateNewStickerSet
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||||
|
import dev.inmo.tgbotapi.types.StickerFormat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
title: String,
|
||||||
|
stickersFormat: StickerFormat,
|
||||||
|
stickers: List<InputSticker>,
|
||||||
|
needsRepainting: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
CreateNewStickerSet(userId, name, title, stickersFormat, stickers, needsRepainting)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
title: String,
|
||||||
|
stickersFormat: StickerFormat,
|
||||||
|
stickers: List<InputSticker>,
|
||||||
|
needsRepainting: Boolean = false,
|
||||||
|
) = createNewStickerSet(
|
||||||
|
user.id, name, title, stickersFormat, stickers, needsRepainting
|
||||||
|
)
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewVideoStickerSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.DeleteStickerFromSet
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.DeleteStickerSet
|
||||||
|
import dev.inmo.tgbotapi.types.StickerSetName
|
||||||
|
import dev.inmo.tgbotapi.types.files.Sticker
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.deleteStickerSet(
|
||||||
|
name: StickerSetName
|
||||||
|
) = execute(
|
||||||
|
DeleteStickerSet(name)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.deleteStickerSet(
|
||||||
|
sticker: Sticker
|
||||||
|
) = deleteStickerSet(
|
||||||
|
sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker")
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.deleteStickerSet(
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
) = deleteStickerSet(stickerSet.name)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.thumbs
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetCustomEmojiStickerSetThumbnail
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail
|
||||||
|
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||||
|
import dev.inmo.tgbotapi.types.StickerSetName
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
|
||||||
|
stickerSetName: StickerSetName,
|
||||||
|
customEmojiId: CustomEmojiId
|
||||||
|
) = execute(
|
||||||
|
SetCustomEmojiStickerSetThumbnail(stickerSetName, customEmojiId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
customEmojiId: CustomEmojiId
|
||||||
|
) = setCustomEmojiStickerSetThumbnail(
|
||||||
|
stickerSet.name, customEmojiId
|
||||||
|
)
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerEmojiList
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||||
|
import dev.inmo.tgbotapi.types.files.Sticker
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerEmojiList(
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: List<String>
|
||||||
|
) = execute(
|
||||||
|
SetStickerEmojiList(
|
||||||
|
sticker,
|
||||||
|
emojis
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerEmojiList(
|
||||||
|
sticker: Sticker,
|
||||||
|
vararg emojis: String
|
||||||
|
) = setStickerEmojiList(
|
||||||
|
sticker.fileId,
|
||||||
|
emojis.toList()
|
||||||
|
)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerEmojiList
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerKeywords
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||||
|
import dev.inmo.tgbotapi.types.files.Sticker
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerKeywords(
|
||||||
|
sticker: FileId,
|
||||||
|
keywords: List<String>
|
||||||
|
) = execute(
|
||||||
|
SetStickerKeywords(
|
||||||
|
sticker,
|
||||||
|
keywords
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerKeywords(
|
||||||
|
sticker: Sticker,
|
||||||
|
vararg keywords: String
|
||||||
|
) = setStickerKeywords(
|
||||||
|
sticker.fileId,
|
||||||
|
keywords.toList()
|
||||||
|
)
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerEmojiList
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerMaskPosition
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||||
|
import dev.inmo.tgbotapi.types.files.Sticker
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerMaskPosition(
|
||||||
|
sticker: FileId,
|
||||||
|
maskPosition: MaskPosition
|
||||||
|
) = execute(
|
||||||
|
SetStickerMaskPosition(
|
||||||
|
sticker,
|
||||||
|
maskPosition
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -3,27 +3,95 @@ package dev.inmo.tgbotapi.extensions.api.thumbs
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumb
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail
|
||||||
|
import dev.inmo.tgbotapi.types.StickerSetName
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: StickerSetName,
|
||||||
|
thumbnail: FileId
|
||||||
|
) = execute(
|
||||||
|
SetStickerSetThumbnail(userId, stickerSetName, thumbnail)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: StickerSetName,
|
||||||
|
thumbnail: MultipartFile
|
||||||
|
) = execute(
|
||||||
|
SetStickerSetThumbnail(userId, stickerSetName, thumbnail)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: StickerSetName,
|
||||||
|
thumbnail: FileId
|
||||||
|
) = setStickerSetThumbnail(
|
||||||
|
user.id, stickerSetName, thumbnail
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: StickerSetName,
|
||||||
|
thumbnail: MultipartFile
|
||||||
|
) = setStickerSetThumbnail(
|
||||||
|
user.id, stickerSetName, thumbnail
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
thumbnail: FileId
|
||||||
|
) = setStickerSetThumbnail(
|
||||||
|
userId, stickerSet.name, thumbnail
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
thumbnail: MultipartFile
|
||||||
|
) = setStickerSetThumbnail(
|
||||||
|
userId, stickerSet.name, thumbnail
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
thumbnail: FileId
|
||||||
|
) = setStickerSetThumbnail(
|
||||||
|
user.id, stickerSet.name, thumbnail
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetThumbnail(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
thumbnail: MultipartFile
|
||||||
|
) = setStickerSetThumbnail(
|
||||||
|
user.id, stickerSet.name, thumbnail
|
||||||
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
thumbSetName: String,
|
thumbSetName: String,
|
||||||
thumb: FileId
|
thumb: FileId
|
||||||
) = execute(
|
) = execute(
|
||||||
SetStickerSetThumb(userId, thumbSetName, thumb)
|
SetStickerSetThumbnail(userId, thumbSetName, thumb)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
thumbSetName: String,
|
thumbSetName: String,
|
||||||
thumb: MultipartFile
|
thumb: MultipartFile
|
||||||
) = execute(
|
) = execute(
|
||||||
SetStickerSetThumb(userId, thumbSetName, thumb)
|
SetStickerSetThumbnail(userId, thumbSetName, thumb)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
thumbSetName: String,
|
thumbSetName: String,
|
||||||
@@ -32,6 +100,7 @@ suspend fun TelegramBot.setStickerSetThumb(
|
|||||||
user.id, thumbSetName, thumb
|
user.id, thumbSetName, thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSetName, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
thumbSetName: String,
|
thumbSetName: String,
|
||||||
@@ -40,6 +109,7 @@ suspend fun TelegramBot.setStickerSetThumb(
|
|||||||
user.id, thumbSetName, thumb
|
user.id, thumbSetName, thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
thumbSet: StickerSet,
|
thumbSet: StickerSet,
|
||||||
@@ -48,6 +118,7 @@ suspend fun TelegramBot.setStickerSetThumb(
|
|||||||
userId, thumbSet.name, thumb
|
userId, thumbSet.name, thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(userId, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
thumbSet: StickerSet,
|
thumbSet: StickerSet,
|
||||||
@@ -56,6 +127,7 @@ suspend fun TelegramBot.setStickerSetThumb(
|
|||||||
userId, thumbSet.name, thumb
|
userId, thumbSet.name, thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
thumbSet: StickerSet,
|
thumbSet: StickerSet,
|
||||||
@@ -64,6 +136,7 @@ suspend fun TelegramBot.setStickerSetThumb(
|
|||||||
user.id, thumbSet.name, thumb
|
user.id, thumbSet.name, thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("setStickerSetThumbnail(user, thumbSet, thumb)", "dev.inmo.tgbotapi.extensions.api.thumbs.setStickerSetThumbnail"))
|
||||||
suspend fun TelegramBot.setStickerSetThumb(
|
suspend fun TelegramBot.setStickerSetThumb(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
thumbSet: StickerSet,
|
thumbSet: StickerSet,
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetTitle
|
||||||
|
import dev.inmo.tgbotapi.types.StickerSetName
|
||||||
|
import dev.inmo.tgbotapi.types.files.Sticker
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetTitle(
|
||||||
|
name: StickerSetName,
|
||||||
|
title: String
|
||||||
|
) = execute(SetStickerSetTitle(name, title))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetTitle(
|
||||||
|
sticker: Sticker,
|
||||||
|
title: String
|
||||||
|
) = setStickerSetTitle(sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker"), title)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setStickerSetTitle(
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
title: String
|
||||||
|
) = setStickerSetTitle(stickerSet.name, title)
|
||||||
@@ -3,19 +3,22 @@ package dev.inmo.tgbotapi.extensions.api.stickers
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
||||||
|
import dev.inmo.tgbotapi.types.StickerFormat
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
|
||||||
suspend fun TelegramBot.uploadStickerFile(
|
suspend fun TelegramBot.uploadStickerFile(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
sticker: MultipartFile
|
sticker: MultipartFile,
|
||||||
|
stickerFormat: StickerFormat
|
||||||
) = execute(
|
) = execute(
|
||||||
UploadStickerFile(userId, sticker)
|
UploadStickerFile(userId, sticker, stickerFormat)
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.uploadStickerFile(
|
suspend fun TelegramBot.uploadStickerFile(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
sticker: MultipartFile
|
sticker: MultipartFile,
|
||||||
|
stickerFormat: StickerFormat
|
||||||
) = execute(
|
) = execute(
|
||||||
UploadStickerFile(user.id, sticker)
|
UploadStickerFile(user.id, sticker, stickerFormat)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
|||||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
import io.ktor.util.cio.use
|
import io.ktor.util.cio.use
|
||||||
import io.ktor.util.cio.writeChannel
|
import io.ktor.util.cio.writeChannel
|
||||||
|
import io.ktor.utils.io.copyAndClose
|
||||||
import io.ktor.utils.io.copyTo
|
import io.ktor.utils.io.copyTo
|
||||||
import kotlinx.coroutines.job
|
import kotlinx.coroutines.job
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -25,7 +26,7 @@ suspend fun TelegramBot.downloadFile(
|
|||||||
doOutsideOfCoroutine { destFile.createNewFile() }
|
doOutsideOfCoroutine { destFile.createNewFile() }
|
||||||
|
|
||||||
destFile.writeChannel(coroutineContext.job).use {
|
destFile.writeChannel(coroutineContext.job).use {
|
||||||
readChannel.copyTo(this)
|
readChannel.copyAndClose(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
return destFile
|
return destFile
|
||||||
|
|||||||
@@ -30,11 +30,17 @@ suspend fun TelegramBot.downloadFileToTemp(
|
|||||||
|
|
||||||
suspend fun TelegramBot.downloadFileToTemp(
|
suspend fun TelegramBot.downloadFileToTemp(
|
||||||
pathedFile: PathedFile
|
pathedFile: PathedFile
|
||||||
) = downloadFileToTemp(
|
): File = downloadFileToTemp(
|
||||||
pathedFile.filePath
|
pathedFile.filePath
|
||||||
).apply {
|
).run {
|
||||||
runCatching {
|
val newFile = File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}")
|
||||||
renameTo(File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}"))
|
val success = runCatching {
|
||||||
|
renameTo(newFile)
|
||||||
|
}.getOrElse { false }
|
||||||
|
if (success) {
|
||||||
|
newFile
|
||||||
|
} else {
|
||||||
|
this@run
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "org.jetbrains.kotlin.multiplatform"
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "org.jetbrains.dokka"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.description = "Behaviour Builder DSL"
|
project.description = "Behaviour Builder DSL"
|
||||||
|
|||||||
@@ -93,8 +93,9 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
|
|||||||
behaviourContext: BehaviourContext,
|
behaviourContext: BehaviourContext,
|
||||||
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||||
statesManager: StatesManager<T>,
|
statesManager: StatesManager<T>,
|
||||||
|
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||||
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, onStateHandlingErrorHandler)
|
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, fallbackHandler, onStateHandlingErrorHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,11 +130,12 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
private val behaviourContext: BehaviourContext,
|
private val behaviourContext: BehaviourContext,
|
||||||
private val statesManager: StatesManager<T>,
|
private val statesManager: StatesManager<T>,
|
||||||
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||||
|
private val fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
private val onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
private val onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||||
) : BehaviourContext by behaviourContext, BehaviourContextWithFSM<T> {
|
) : BehaviourContext by behaviourContext, BehaviourContextWithFSM<T> {
|
||||||
private val updatesFlows = mutableMapOf<Any, DefaultBehaviourContextWithFSM<T>>()
|
private val updatesFlows = mutableMapOf<Any, DefaultBehaviourContextWithFSM<T>>()
|
||||||
private val additionalHandlers = mutableListOf<BehaviourWithFSMStateHandlerHolder<*, T>>()
|
private val additionalHandlers = mutableListOf<BehaviourWithFSMStateHandlerHolder<*, T>>()
|
||||||
private var actualHandlersList = additionalHandlers + handlers
|
private var actualHandlersList = additionalHandlers + handlers + listOfNotNull(fallbackHandler)
|
||||||
|
|
||||||
protected val statesJobs = mutableMapOf<T, Job>()
|
protected val statesJobs = mutableMapOf<T, Job>()
|
||||||
protected val statesJobsMutex = Mutex()
|
protected val statesJobsMutex = Mutex()
|
||||||
@@ -250,6 +252,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
||||||
handlers,
|
handlers,
|
||||||
statesManager,
|
statesManager,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler
|
onStateHandlingErrorHandler
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -265,6 +268,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
||||||
handlers,
|
handlers,
|
||||||
statesManager,
|
statesManager,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler
|
onStateHandlingErrorHandler
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
|
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||||
@@ -41,6 +42,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|||||||
),
|
),
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
statesManager,
|
statesManager,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler
|
onStateHandlingErrorHandler
|
||||||
).apply { block() }
|
).apply { block() }
|
||||||
|
|
||||||
@@ -59,6 +61,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
|
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
timeoutSeconds: Seconds = 30,
|
timeoutSeconds: Seconds = 30,
|
||||||
autoDisableWebhooks: Boolean = true,
|
autoDisableWebhooks: Boolean = true,
|
||||||
@@ -71,6 +74,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler,
|
onStateHandlingErrorHandler,
|
||||||
block
|
block
|
||||||
).run {
|
).run {
|
||||||
@@ -104,6 +108,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
|
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||||
@@ -114,6 +119,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|||||||
),
|
),
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
statesManager,
|
statesManager,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler
|
onStateHandlingErrorHandler
|
||||||
).apply { block() }
|
).apply { block() }
|
||||||
|
|
||||||
@@ -137,6 +143,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
|
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
timeoutSeconds: Seconds = 30,
|
timeoutSeconds: Seconds = 30,
|
||||||
autoDisableWebhooks: Boolean = true,
|
autoDisableWebhooks: Boolean = true,
|
||||||
@@ -150,6 +157,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler,
|
onStateHandlingErrorHandler,
|
||||||
block
|
block
|
||||||
).run {
|
).run {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
|||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
|
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
testServer: Boolean = false,
|
testServer: Boolean = false,
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
timeoutSeconds: Seconds = 30,
|
timeoutSeconds: Seconds = 30,
|
||||||
@@ -65,6 +66,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
|||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler,
|
onStateHandlingErrorHandler,
|
||||||
timeoutSeconds,
|
timeoutSeconds,
|
||||||
autoDisableWebhooks,
|
autoDisableWebhooks,
|
||||||
@@ -97,6 +99,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
|
fallbackHandler: BehaviourWithFSMStateHandlerHolder<T, T>? = null,
|
||||||
testServer: Boolean = false,
|
testServer: Boolean = false,
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
timeoutSeconds: Seconds = 30,
|
timeoutSeconds: Seconds = 30,
|
||||||
@@ -116,6 +119,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
fallbackHandler,
|
||||||
onStateHandlingErrorHandler,
|
onStateHandlingErrorHandler,
|
||||||
timeoutSeconds,
|
timeoutSeconds,
|
||||||
autoDisableWebhooks,
|
autoDisableWebhooks,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "org.jetbrains.kotlin.multiplatform"
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id "org.jetbrains.dokka"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.description = "Behaviour Builder DSL"
|
project.description = "Behaviour Builder DSL"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|||||||
import dev.inmo.micro_utils.coroutines.*
|
import dev.inmo.micro_utils.coroutines.*
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
||||||
|
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.tgbotapi.updateshandlers.*
|
import dev.inmo.tgbotapi.updateshandlers.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@@ -71,9 +72,17 @@ class DefaultBehaviourContext(
|
|||||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
||||||
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
||||||
if (upstreamUpdatesFlow != null) {
|
if (upstreamUpdatesFlow != null) {
|
||||||
var lastHandledUpdate = -1L
|
val handledUpdates = mutableSetOf<UpdateIdentifier>()
|
||||||
(it + upstreamUpdatesFlow).filter {
|
(it + upstreamUpdatesFlow).filter {
|
||||||
(it.updateId > lastHandledUpdate).also { passed -> if (passed) { lastHandledUpdate = it.updateId } }
|
val passed = handledUpdates.add(it.updateId)
|
||||||
|
(passed).also { passed ->
|
||||||
|
val needToDropCount = handledUpdates.size - broadcastChannelsSize
|
||||||
|
if (needToDropCount > 0) {
|
||||||
|
handledUpdates.removeAll(
|
||||||
|
handledUpdates.take(needToDropCount).ifEmpty { return@also }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
it
|
it
|
||||||
|
|||||||
@@ -20,15 +20,6 @@ suspend inline fun <reified O : MessageContent> BehaviourContext.waitContent(
|
|||||||
): Flow<O> = waitContentMessage<O>(initRequest, errorFactory).map { it.content }
|
): Flow<O> = waitContentMessage<O>(initRequest, errorFactory).map { it.content }
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(
|
|
||||||
includeMediaGroupsDeprecationMessage,
|
|
||||||
ReplaceWith("waitAnyContent(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContent")
|
|
||||||
)
|
|
||||||
suspend fun BehaviourContext.waitContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<MessageContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyContent(
|
suspend fun BehaviourContext.waitAnyContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
@@ -69,62 +60,26 @@ suspend fun BehaviourContext.waitVenue(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<VenueContent>(initRequest, errorFactory)
|
) = waitContent<VenueContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitMedia(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<MediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitMedia(
|
suspend fun BehaviourContext.waitMedia(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<MediaContent>(initRequest, errorFactory)
|
) = waitContent<MediaContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<MediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<MediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<MediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<TextedMediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContent(
|
suspend fun BehaviourContext.waitTextedMediaContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
@@ -133,32 +88,14 @@ suspend fun BehaviourContext.waitAnimation(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<AnimationContent>(initRequest, errorFactory)
|
) = waitContent<AnimationContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudio(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<AudioContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudio(
|
suspend fun BehaviourContext.waitAudio(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<AudioContent>(initRequest, errorFactory)
|
) = waitContent<AudioContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocument(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<DocumentContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocument(
|
suspend fun BehaviourContext.waitDocument(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<DocumentContent>(initRequest, errorFactory)
|
) = waitContent<DocumentContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitPhoto(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<PhotoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitPhoto(
|
suspend fun BehaviourContext.waitPhoto(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
@@ -167,12 +104,6 @@ suspend fun BehaviourContext.waitSticker(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<StickerContent>(initRequest, errorFactory)
|
) = waitContent<StickerContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVideo(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<VideoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVideo(
|
suspend fun BehaviourContext.waitVideo(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import dev.inmo.tgbotapi.utils.RiskFeature
|
|||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
const val includeMediaGroupsDeprecationMessage = "includeMediaGroups is deprecated and its usage will not lead to any changes"
|
|
||||||
typealias CommonMessageToCommonMessageMapper<T> = suspend CommonMessage<T>.() -> CommonMessage<T>?
|
typealias CommonMessageToCommonMessageMapper<T> = suspend CommonMessage<T>.() -> CommonMessage<T>?
|
||||||
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||||
@@ -47,15 +46,6 @@ internal inline fun <reified T : MessageContent> contentMessageConverter(
|
|||||||
if (content is T) this as CommonMessage<T> else null
|
if (content is T) this as CommonMessage<T> else null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(
|
|
||||||
includeMediaGroupsDeprecationMessage,
|
|
||||||
ReplaceWith("waitAnyContentMessage(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContentMessage")
|
|
||||||
)
|
|
||||||
suspend fun BehaviourContext.waitContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<MessageContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyContentMessage(
|
suspend fun BehaviourContext.waitAnyContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
@@ -96,62 +86,26 @@ suspend fun BehaviourContext.waitVenueMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<VenueContent>(initRequest, errorFactory)
|
) = waitContentMessage<VenueContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitMediaMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<MediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitMediaMessage(
|
suspend fun BehaviourContext.waitMediaMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<MediaContent>(initRequest, errorFactory)
|
) = waitContentMessage<MediaContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<MediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<MediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<MediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<TextedMediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
@@ -160,32 +114,14 @@ suspend fun BehaviourContext.waitAnimationMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<AnimationContent>(initRequest, errorFactory)
|
) = waitContentMessage<AnimationContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudioMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<AudioContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudioMessage(
|
suspend fun BehaviourContext.waitAudioMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<AudioContent>(initRequest, errorFactory)
|
) = waitContentMessage<AudioContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<DocumentContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMessage(
|
suspend fun BehaviourContext.waitDocumentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<DocumentContent>(initRequest, errorFactory)
|
) = waitContentMessage<DocumentContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitPhotoMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<PhotoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitPhotoMessage(
|
suspend fun BehaviourContext.waitPhotoMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
@@ -194,12 +130,6 @@ suspend fun BehaviourContext.waitStickerMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<StickerContent>(initRequest, errorFactory)
|
) = waitContentMessage<StickerContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVideoMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<VideoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVideoMessage(
|
suspend fun BehaviourContext.waitVideoMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -21,3 +21,17 @@ suspend fun BehaviourContext.waitDeepLinks(
|
|||||||
.flattenCommandsWithParams().mapNotNull {
|
.flattenCommandsWithParams().mapNotNull {
|
||||||
it.first to (it.second.second.singleOrNull() ?.regularTextSourceOrNull() ?.source ?.removePrefix(" ") ?: return@mapNotNull null)
|
it.first to (it.second.second.singleOrNull() ?.regularTextSourceOrNull() ?.source ?.removePrefix(" ") ?: return@mapNotNull null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitDeepLinks(
|
||||||
|
regex: Regex,
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
): Flow<Pair<CommonMessage<TextContent>, String>> = waitDeepLinks(initRequest, errorFactory).filter {
|
||||||
|
regex.matches(it.second)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitDeepLinks(
|
||||||
|
deepLink: String,
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
): Flow<Pair<CommonMessage<TextContent>, String>> = waitDeepLinks(Regex("^$deepLink$"), initRequest, errorFactory)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEvents(
|
|||||||
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEvents<LeftChatMember>(initRequest, errorFactory)
|
) = waitEvents<LeftChatMemberEvent>(initRequest, errorFactory)
|
||||||
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEventsMessages(
|
|||||||
suspend fun BehaviourContext.waitLeftChatMemberEventsMessages(
|
suspend fun BehaviourContext.waitLeftChatMemberEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEventsMessages<LeftChatMember>(initRequest, errorFactory)
|
) = waitEventsMessages<LeftChatMemberEvent>(initRequest, errorFactory)
|
||||||
suspend fun BehaviourContext.waitNewChatPhotoEventsMessages(
|
suspend fun BehaviourContext.waitNewChatPhotoEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -46,3 +46,24 @@ suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
|||||||
this@onDeepLink.launchSafelyWithoutExceptions { triggersHolder.handleableCommandsHolder.unregisterHandleable(startRegex) }
|
this@onDeepLink.launchSafelyWithoutExceptions { triggersHolder.handleableCommandsHolder.unregisterHandleable(startRegex) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||||
|
regex: Regex,
|
||||||
|
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update> = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||||
|
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||||
|
): Job {
|
||||||
|
val internalFilter = SimpleFilter<Pair<TextMessage, String>> {
|
||||||
|
regex.matches(it.second)
|
||||||
|
}
|
||||||
|
return onDeepLink(initialFilter ?.let { internalFilter * it } ?: internalFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||||
|
deepLink: String,
|
||||||
|
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update> = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||||
|
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||||
|
): Job = onDeepLink(Regex("^$deepLink$"), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|||||||
@@ -346,10 +346,10 @@ suspend fun <BC : BehaviourContext> BC.onGroupChatCreated(
|
|||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onLeftChatMember(
|
suspend fun <BC : BehaviourContext> BC.onLeftChatMember(
|
||||||
initialFilter: SimpleFilter<ChatEventMessage<LeftChatMember>>? = null,
|
initialFilter: SimpleFilter<ChatEventMessage<LeftChatMemberEvent>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<LeftChatMember>, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<LeftChatMemberEvent>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ChatEventMessage<LeftChatMember>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ChatEventMessage<LeftChatMemberEvent>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<LeftChatMember>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<LeftChatMemberEvent>>
|
||||||
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
|
||||||
|
actual var defaultCoroutineScopeProvider: () -> CoroutineScope = { CoroutineScope(Dispatchers.Default) }
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
|
||||||
|
actual var defaultCoroutineScopeProvider: () -> CoroutineScope = { CoroutineScope(Dispatchers.Default) }
|
||||||
@@ -2,6 +2,7 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.multiplatform"
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
id "com.google.devtools.ksp"
|
id "com.google.devtools.ksp"
|
||||||
|
id "org.jetbrains.dokka"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.description = "Core part of tgbotapi with all (and only) required functionality for working with Telegram Bot API"
|
project.description = "Core part of tgbotapi with all (and only) required functionality for working with Telegram Bot API"
|
||||||
@@ -25,6 +26,7 @@ kotlin {
|
|||||||
api libs.microutils.serialization.base64
|
api libs.microutils.serialization.base64
|
||||||
api libs.microutils.serialization.encapsulator
|
api libs.microutils.serialization.encapsulator
|
||||||
api libs.microutils.serialization.typedSerializer
|
api libs.microutils.serialization.typedSerializer
|
||||||
|
api libs.microutils.serialization.mapper
|
||||||
api libs.microutils.ktor.common
|
api libs.microutils.ktor.common
|
||||||
api libs.microutils.languageCodes
|
api libs.microutils.languageCodes
|
||||||
|
|
||||||
@@ -46,11 +48,23 @@ kotlin {
|
|||||||
api libs.javax.activation
|
api libs.javax.activation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linuxX64Main {
|
||||||
|
dependencies {
|
||||||
|
api libs.ktor.client.curl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mingwX64Main {
|
||||||
|
dependencies {
|
||||||
|
api libs.ktor.client.winhttp
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
add("kspJvm", project(":tgbotapi.ksp"))
|
add("kspCommonMainMetadata", project(":tgbotapi.ksp"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ksp {
|
ksp {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package dev.inmo.tgbotapi.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All inheritors of this interface have [chat] field and related to this [chat]
|
||||||
|
*/
|
||||||
|
interface WithChat {
|
||||||
|
val chat: Chat
|
||||||
|
}
|
||||||
@@ -1,134 +1,25 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor
|
package dev.inmo.tgbotapi.bot.ktor
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
|
||||||
import dev.inmo.micro_utils.coroutines.safely
|
|
||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.*
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.base.*
|
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import dev.inmo.tgbotapi.types.Response
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
import dev.inmo.tgbotapi.utils.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.plugins.*
|
|
||||||
import io.ktor.client.statement.bodyAsText
|
|
||||||
import io.ktor.client.statement.readText
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
@RiskFeature
|
/**
|
||||||
fun createTelegramBotDefaultKtorCallRequestsFactories() = listOf(
|
* Represents default [BaseRequestsExecutor] working on [Ktor](https://ktor.io) [HttpClient]
|
||||||
SimpleRequestCallFactory(),
|
*
|
||||||
MultipartRequestCallFactory(),
|
* * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor]
|
||||||
DownloadFileRequestCallFactory,
|
* * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor]
|
||||||
DownloadFileChannelRequestCallFactory
|
*/
|
||||||
)
|
expect class KtorRequestsExecutor (
|
||||||
|
|
||||||
class KtorRequestsExecutor(
|
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient(),
|
client: HttpClient = HttpClient(),
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean = false,
|
||||||
private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||||
private val jsonFormatter: Json = nonstrictJsonFormat,
|
jsonFormatter: Json = nonstrictJsonFormat,
|
||||||
private val pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
) : BaseRequestsExecutor
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
|
||||||
if (!excludeDefaultFactories) {
|
|
||||||
this + createTelegramBotDefaultKtorCallRequestsFactories()
|
|
||||||
} else {
|
|
||||||
this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val client = client.config {
|
|
||||||
if (client.pluginOrNull(HttpTimeout) == null) {
|
|
||||||
install(HttpTimeout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun <T : Any> execute(request: Request<T>): T {
|
|
||||||
return runCatchingSafely {
|
|
||||||
pipelineStepsHolder.onBeforeSearchCallFactory(request, callsFactories)
|
|
||||||
requestsLimiter.limit(request) {
|
|
||||||
var result: T? = null
|
|
||||||
lateinit var factoryHandledRequest: KtorCallFactory
|
|
||||||
for (potentialFactory in callsFactories) {
|
|
||||||
pipelineStepsHolder.onBeforeCallFactoryMakeCall(request, potentialFactory)
|
|
||||||
result = potentialFactory.makeCall(
|
|
||||||
client,
|
|
||||||
telegramAPIUrlsKeeper,
|
|
||||||
request,
|
|
||||||
jsonFormatter
|
|
||||||
)
|
|
||||||
result = pipelineStepsHolder.onAfterCallFactoryMakeCall(result, request, potentialFactory)
|
|
||||||
if (result != null) {
|
|
||||||
factoryHandledRequest = potentialFactory
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result ?.let {
|
|
||||||
pipelineStepsHolder.onRequestResultPresented(it, request, factoryHandledRequest, callsFactories)
|
|
||||||
} ?: pipelineStepsHolder.onRequestResultAbsent(request, callsFactories) ?: error("Can't execute request: $request")
|
|
||||||
}
|
|
||||||
}.let {
|
|
||||||
val result = it.exceptionOrNull() ?.let { e ->
|
|
||||||
pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it }
|
|
||||||
|
|
||||||
when (e) {
|
|
||||||
is ClientRequestException -> {
|
|
||||||
val exceptionResult = runCatchingSafely {
|
|
||||||
val content = e.response.bodyAsText()
|
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
|
||||||
newRequestException(
|
|
||||||
responseObject,
|
|
||||||
content,
|
|
||||||
"Can't get result object from $content"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
exceptionResult.exceptionOrNull() ?.let {
|
|
||||||
CommonBotException(cause = e)
|
|
||||||
} ?: exceptionResult.getOrThrow()
|
|
||||||
}
|
|
||||||
is BotException -> e
|
|
||||||
else -> CommonBotException(cause = e)
|
|
||||||
}
|
|
||||||
} ?.let { Result.failure(it) } ?: it
|
|
||||||
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun close() {
|
|
||||||
client.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class KtorRequestsExecutorBuilder(
|
|
||||||
var telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
|
||||||
) {
|
|
||||||
var client: HttpClient = HttpClient()
|
|
||||||
var callsFactories: List<KtorCallFactory> = emptyList()
|
|
||||||
var excludeDefaultFactories: Boolean = false
|
|
||||||
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter
|
|
||||||
var jsonFormatter: Json = nonstrictJsonFormat
|
|
||||||
|
|
||||||
fun build() = KtorRequestsExecutor(telegramAPIUrlsKeeper, client, callsFactories, excludeDefaultFactories, requestsLimiter, jsonFormatter)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun telegramBot(
|
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
|
||||||
): TelegramBot = KtorRequestsExecutorBuilder(telegramAPIUrlsKeeper).apply(builder).build()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shortcut for [telegramBot]
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun telegramBot(
|
|
||||||
token: String,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
testServer: Boolean = false,
|
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
|
||||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), builder)
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package dev.inmo.tgbotapi.bot.ktor
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.base.*
|
||||||
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
|
import dev.inmo.tgbotapi.utils.*
|
||||||
|
import io.ktor.client.HttpClient
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
@RiskFeature
|
||||||
|
fun createTelegramBotDefaultKtorCallRequestsFactories() = listOf(
|
||||||
|
SimpleRequestCallFactory(),
|
||||||
|
MultipartRequestCallFactory(),
|
||||||
|
DownloadFileRequestCallFactory,
|
||||||
|
DownloadFileChannelRequestCallFactory
|
||||||
|
)
|
||||||
|
|
||||||
|
class KtorRequestsExecutorBuilder(
|
||||||
|
var telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
||||||
|
) {
|
||||||
|
var client: HttpClient = HttpClient()
|
||||||
|
var callsFactories: List<KtorCallFactory> = emptyList()
|
||||||
|
var excludeDefaultFactories: Boolean = false
|
||||||
|
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter
|
||||||
|
var jsonFormatter: Json = nonstrictJsonFormat
|
||||||
|
|
||||||
|
fun build() = KtorRequestsExecutor(
|
||||||
|
telegramAPIUrlsKeeper,
|
||||||
|
client,
|
||||||
|
callsFactories,
|
||||||
|
excludeDefaultFactories,
|
||||||
|
requestsLimiter,
|
||||||
|
jsonFormatter
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun telegramBot(
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
||||||
|
): TelegramBot = KtorRequestsExecutorBuilder(telegramAPIUrlsKeeper).apply(builder).build()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for [telegramBot]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun telegramBot(
|
||||||
|
token: String,
|
||||||
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
|
testServer: Boolean = false,
|
||||||
|
builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
||||||
|
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), builder)
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.safelyWithResult
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||||
@@ -56,7 +56,7 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
val content = response.bodyAsText()
|
val content = response.bodyAsText()
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||||
|
|
||||||
return safelyWithResult {
|
return runCatchingSafely {
|
||||||
(responseObject.result?.let {
|
(responseObject.result?.let {
|
||||||
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
||||||
} ?: response.let {
|
} ?: response.let {
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
|
import dev.inmo.tgbotapi.bot.exceptions.BotException
|
||||||
|
import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
||||||
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories
|
||||||
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.types.Response
|
||||||
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
|
import io.ktor.client.*
|
||||||
|
import io.ktor.client.plugins.*
|
||||||
|
import io.ktor.client.statement.*
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
class DefaultKtorRequestsExecutor(
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
client: HttpClient = HttpClient(),
|
||||||
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
|
excludeDefaultFactories: Boolean = false,
|
||||||
|
private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||||
|
private val jsonFormatter: Json = nonstrictJsonFormat,
|
||||||
|
private val pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||||
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
|
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||||
|
if (!excludeDefaultFactories) {
|
||||||
|
this + createTelegramBotDefaultKtorCallRequestsFactories()
|
||||||
|
} else {
|
||||||
|
this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val client = client.config {
|
||||||
|
if (client.pluginOrNull(HttpTimeout) == null) {
|
||||||
|
install(HttpTimeout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun <T : Any> execute(request: Request<T>): T {
|
||||||
|
return runCatchingSafely {
|
||||||
|
pipelineStepsHolder.onBeforeSearchCallFactory(request, callsFactories)
|
||||||
|
requestsLimiter.limit(request) {
|
||||||
|
var result: T? = null
|
||||||
|
lateinit var factoryHandledRequest: KtorCallFactory
|
||||||
|
for (potentialFactory in callsFactories) {
|
||||||
|
pipelineStepsHolder.onBeforeCallFactoryMakeCall(request, potentialFactory)
|
||||||
|
result = potentialFactory.makeCall(
|
||||||
|
client,
|
||||||
|
telegramAPIUrlsKeeper,
|
||||||
|
request,
|
||||||
|
jsonFormatter
|
||||||
|
)
|
||||||
|
result = pipelineStepsHolder.onAfterCallFactoryMakeCall(result, request, potentialFactory)
|
||||||
|
if (result != null) {
|
||||||
|
factoryHandledRequest = potentialFactory
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result ?.let {
|
||||||
|
pipelineStepsHolder.onRequestResultPresented(it, request, factoryHandledRequest, callsFactories)
|
||||||
|
} ?: pipelineStepsHolder.onRequestResultAbsent(request, callsFactories) ?: error("Can't execute request: $request")
|
||||||
|
}
|
||||||
|
}.let {
|
||||||
|
val result = it.exceptionOrNull() ?.let { e ->
|
||||||
|
pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it }
|
||||||
|
|
||||||
|
when (e) {
|
||||||
|
is ClientRequestException -> {
|
||||||
|
val exceptionResult = runCatchingSafely {
|
||||||
|
val content = e.response.bodyAsText()
|
||||||
|
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||||
|
newRequestException(
|
||||||
|
responseObject,
|
||||||
|
content,
|
||||||
|
"Can't get result object from $content"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
exceptionResult.exceptionOrNull() ?.let {
|
||||||
|
CommonBotException(cause = e)
|
||||||
|
} ?: exceptionResult.getOrThrow()
|
||||||
|
}
|
||||||
|
is BotException -> e
|
||||||
|
else -> CommonBotException(cause = e)
|
||||||
|
}
|
||||||
|
} ?.let { Result.failure(it) } ?: it
|
||||||
|
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
client.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.*
|
|||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import dev.inmo.tgbotapi.utils.mapWithCommonValues
|
import dev.inmo.tgbotapi.utils.mapWithCommonValues
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.forms.MultiPartFormDataContent
|
import io.ktor.client.request.forms.*
|
||||||
import io.ktor.client.request.forms.formData
|
|
||||||
import io.ktor.http.Headers
|
import io.ktor.http.Headers
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||||
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import io.ktor.client.*
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.flow.mapNotNull
|
||||||
|
import kotlinx.coroutines.sync.Mutex
|
||||||
|
import kotlinx.coroutines.sync.withLock
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native
|
||||||
|
* platforms and MingwX64 should return [client]
|
||||||
|
*
|
||||||
|
* On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64
|
||||||
|
*/
|
||||||
|
internal expect inline fun platformClientCopy(client: HttpClient): HttpClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will use its parameters of constructor to create several [DefaultKtorRequestsExecutor] and use them in [execute]
|
||||||
|
* and [close] operations
|
||||||
|
*
|
||||||
|
* This [BaseRequestsExecutor] has been created for LinuxX64 target due to its inability of requests paralleling
|
||||||
|
*
|
||||||
|
* Under the hood on each [execute] it will take [DefaultKtorRequestsExecutor] and mark it as busy, execute
|
||||||
|
* [Request], free up taken [DefaultKtorRequestsExecutor] and return (or throw) the result of execution
|
||||||
|
*
|
||||||
|
* @param requestExecutorsCount Amount of [DefaultKtorRequestsExecutor] which will be created and used under the
|
||||||
|
* hood
|
||||||
|
*/
|
||||||
|
class MultipleClientKtorRequestsExecutor (
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
callsFactories: List<KtorCallFactory>,
|
||||||
|
excludeDefaultFactories: Boolean,
|
||||||
|
requestsLimiter: RequestLimiter,
|
||||||
|
jsonFormatter: Json,
|
||||||
|
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
|
requestExecutorsCount: Int,
|
||||||
|
clientFactory: () -> HttpClient
|
||||||
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
|
private val requestExecutors = (0 until requestExecutorsCount).map {
|
||||||
|
DefaultKtorRequestsExecutor(
|
||||||
|
telegramAPIUrlsKeeper,
|
||||||
|
clientFactory(),
|
||||||
|
callsFactories,
|
||||||
|
excludeDefaultFactories,
|
||||||
|
requestsLimiter,
|
||||||
|
jsonFormatter,
|
||||||
|
pipelineStepsHolder
|
||||||
|
)
|
||||||
|
}.toSet()
|
||||||
|
private val freeClients = MutableStateFlow<Set<DefaultKtorRequestsExecutor>>(requestExecutors)
|
||||||
|
private val clientAllocationMutex = Mutex()
|
||||||
|
private val takerFlow = freeClients.mapNotNull {
|
||||||
|
clientAllocationMutex.withLock {
|
||||||
|
freeClients.value.firstOrNull() ?.also {
|
||||||
|
freeClients.value -= it
|
||||||
|
} ?: return@mapNotNull null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
client: HttpClient,
|
||||||
|
callsFactories: List<KtorCallFactory>,
|
||||||
|
excludeDefaultFactories: Boolean,
|
||||||
|
requestsLimiter: RequestLimiter,
|
||||||
|
jsonFormatter: Json,
|
||||||
|
pipelineStepsHolder: KtorPipelineStepsHolder
|
||||||
|
) : this(
|
||||||
|
telegramAPIUrlsKeeper,
|
||||||
|
callsFactories,
|
||||||
|
excludeDefaultFactories,
|
||||||
|
requestsLimiter,
|
||||||
|
jsonFormatter,
|
||||||
|
pipelineStepsHolder,
|
||||||
|
client.engineConfig.threadsCount,
|
||||||
|
{ platformClientCopy(client) }
|
||||||
|
)
|
||||||
|
|
||||||
|
private suspend fun prepareRequestsExecutor(): DefaultKtorRequestsExecutor {
|
||||||
|
return takerFlow.first()
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun freeRequestsExecutor(client: DefaultKtorRequestsExecutor) {
|
||||||
|
clientAllocationMutex.withLock {
|
||||||
|
freeClients.value += client
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun <T> withRequestExecutor(block: suspend (DefaultKtorRequestsExecutor) -> T): T {
|
||||||
|
val requestsExecutor = prepareRequestsExecutor()
|
||||||
|
val result = runCatchingSafely {
|
||||||
|
block(requestsExecutor)
|
||||||
|
}
|
||||||
|
freeRequestsExecutor(requestsExecutor)
|
||||||
|
return result.getOrThrow()
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun <T : Any> execute(request: Request<T>): T = withRequestExecutor {
|
||||||
|
it.execute(request)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
requestExecutors.forEach {
|
||||||
|
it.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,26 @@
|
|||||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.TooMuchRequestsException
|
import dev.inmo.tgbotapi.bot.exceptions.TooMuchRequestsException
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple limiter which will lock any request when [TooMuchRequestsExceptions] is thrown and rerun request after lock time
|
* Simple limiter which will lock any request when [TooMuchRequestsException] is thrown and rerun request after lock time
|
||||||
*/
|
*/
|
||||||
object ExceptionsOnlyLimiter : RequestLimiter {
|
object ExceptionsOnlyLimiter : RequestLimiter {
|
||||||
override suspend fun <T> limit(block: suspend () -> T): T {
|
override suspend fun <T> limit(block: suspend () -> T): T {
|
||||||
return try {
|
var result: Result<T>? = null
|
||||||
block()
|
while (result == null || result.isFailure) {
|
||||||
} catch (e: TooMuchRequestsException) {
|
result = runCatchingSafely {
|
||||||
delay(e.retryAfter.leftToRetry)
|
block()
|
||||||
limit(block)
|
}.onFailure {
|
||||||
|
if (it is TooMuchRequestsException) {
|
||||||
|
delay(it.retryAfter.leftToRetry)
|
||||||
|
} else {
|
||||||
|
throw it
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return result.getOrThrow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ sealed class InputFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal const val attachPrefix = "attach://"
|
||||||
|
|
||||||
internal inline val InputFile.attachFileId
|
internal inline val InputFile.attachFileId
|
||||||
get() = "attach://$fileId"
|
get() = "$attachPrefix$fileId"
|
||||||
internal inline val InputFile.fileIdToSend
|
internal inline val InputFile.fileIdToSend
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
is FileId -> fileId
|
is FileId -> fileId
|
||||||
@@ -60,8 +62,8 @@ fun String.toInputFile() = FileId(this)
|
|||||||
@RiskFeature
|
@RiskFeature
|
||||||
object InputFileSerializer : KSerializer<InputFile> {
|
object InputFileSerializer : KSerializer<InputFile> {
|
||||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
|
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
|
||||||
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId)
|
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileIdToSend)
|
||||||
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString().removePrefix(attachPrefix))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:: add checks for files size
|
// TODO:: add checks for files size
|
||||||
|
|||||||
@@ -23,11 +23,30 @@ data class AnswerInlineQuery(
|
|||||||
val isPersonal: Boolean? = null,
|
val isPersonal: Boolean? = null,
|
||||||
@SerialName(nextOffsetField)
|
@SerialName(nextOffsetField)
|
||||||
val nextOffset: String? = null,
|
val nextOffset: String? = null,
|
||||||
@SerialName(switchPmTextField)
|
@SerialName(buttonField)
|
||||||
val switchPmText: String? = null,
|
val button: InlineQueryResultsButton? = null,
|
||||||
@SerialName(switchPmParameterField)
|
|
||||||
val switchPmParameter: String? = null
|
|
||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
|
constructor(
|
||||||
|
inlineQueryID: InlineQueryIdentifier,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
switchPmText: String?,
|
||||||
|
switchPmParameter: String?
|
||||||
|
) : this(
|
||||||
|
inlineQueryID,
|
||||||
|
results,
|
||||||
|
cachedTime,
|
||||||
|
isPersonal,
|
||||||
|
nextOffset,
|
||||||
|
switchPmText ?.let {
|
||||||
|
switchPmParameter ?.let {
|
||||||
|
InlineQueryResultsButton.Start(switchPmText, switchPmParameter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
override fun method(): String = "answerInlineQuery"
|
override fun method(): String = "answerInlineQuery"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = Boolean.serializer()
|
get() = Boolean.serializer()
|
||||||
@@ -40,8 +59,23 @@ fun InlineQuery.createAnswer(
|
|||||||
cachedTime: Int? = null,
|
cachedTime: Int? = null,
|
||||||
isPersonal: Boolean? = null,
|
isPersonal: Boolean? = null,
|
||||||
nextOffset: String? = null,
|
nextOffset: String? = null,
|
||||||
switchPmText: String? = null,
|
button: InlineQueryResultsButton? = null,
|
||||||
switchPmParameter: String? = null
|
) = AnswerInlineQuery(
|
||||||
|
id,
|
||||||
|
results,
|
||||||
|
cachedTime,
|
||||||
|
isPersonal,
|
||||||
|
nextOffset,
|
||||||
|
button
|
||||||
|
)
|
||||||
|
|
||||||
|
fun InlineQuery.createAnswer(
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
switchPmText: String?,
|
||||||
|
switchPmParameter: String?
|
||||||
) = AnswerInlineQuery(
|
) = AnswerInlineQuery(
|
||||||
id,
|
id,
|
||||||
results,
|
results,
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.answers
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.common.Warning
|
||||||
|
import dev.inmo.tgbotapi.types.StartParameter
|
||||||
|
import dev.inmo.tgbotapi.types.startParameterField
|
||||||
|
import dev.inmo.tgbotapi.types.textField
|
||||||
|
import dev.inmo.tgbotapi.types.webAppField
|
||||||
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
@Serializable(InlineQueryResultsButtonSerializer::class)
|
||||||
|
@ClassCastsIncluded
|
||||||
|
sealed interface InlineQueryResultsButton {
|
||||||
|
val text: String
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class Raw internal constructor(
|
||||||
|
@SerialName(textField)
|
||||||
|
val text: String,
|
||||||
|
@SerialName(webAppField)
|
||||||
|
val webAppInfo: WebAppInfo? = null,
|
||||||
|
@SerialName(startParameterField)
|
||||||
|
val deepLinkParameter: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable(InlineQueryResultsButtonSerializer::class)
|
||||||
|
data class WebApp(
|
||||||
|
@SerialName(textField)
|
||||||
|
override val text: String,
|
||||||
|
@SerialName(webAppField)
|
||||||
|
val webAppInfo: WebAppInfo
|
||||||
|
) : InlineQueryResultsButton
|
||||||
|
|
||||||
|
@Serializable(InlineQueryResultsButtonSerializer::class)
|
||||||
|
data class Start(
|
||||||
|
@SerialName(textField)
|
||||||
|
override val text: String,
|
||||||
|
@SerialName(startParameterField)
|
||||||
|
val deepLinkParameter: String
|
||||||
|
) : InlineQueryResultsButton
|
||||||
|
|
||||||
|
@Serializable(InlineQueryResultsButtonSerializer::class)
|
||||||
|
data class Unknown internal constructor (
|
||||||
|
@SerialName(textField)
|
||||||
|
override val text: String
|
||||||
|
) : InlineQueryResultsButton
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
operator fun invoke(
|
||||||
|
text: String,
|
||||||
|
deepLinkParameter: String
|
||||||
|
) = Start(text, deepLinkParameter)
|
||||||
|
operator fun invoke(
|
||||||
|
text: String,
|
||||||
|
webAppInfo: WebAppInfo
|
||||||
|
) = WebApp(text, webAppInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InlineQueryResultsButtonSerializer : KSerializer<InlineQueryResultsButton> {
|
||||||
|
override val descriptor: SerialDescriptor = InlineQueryResultsButton.Raw.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): InlineQueryResultsButton {
|
||||||
|
val raw = InlineQueryResultsButton.Raw.serializer().deserialize(decoder)
|
||||||
|
|
||||||
|
return when {
|
||||||
|
raw.webAppInfo != null -> InlineQueryResultsButton.WebApp(raw.text, raw.webAppInfo)
|
||||||
|
raw.deepLinkParameter != null -> InlineQueryResultsButton.Start(raw.text, raw.deepLinkParameter)
|
||||||
|
else -> InlineQueryResultsButton.Unknown(raw.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: InlineQueryResultsButton) {
|
||||||
|
InlineQueryResultsButton.Raw.serializer().serialize(
|
||||||
|
encoder,
|
||||||
|
InlineQueryResultsButton.Raw(
|
||||||
|
value.text,
|
||||||
|
(value as? InlineQueryResultsButton.WebApp)?.webAppInfo,
|
||||||
|
(value as? InlineQueryResultsButton.Start)?.deepLinkParameter,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class GetMyDescription(
|
||||||
|
@SerialName(languageCodeField)
|
||||||
|
@Serializable(IetfLanguageCodeSerializer::class)
|
||||||
|
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||||
|
) : SimpleRequest<BotDescription>, WithOptionalLanguageCode {
|
||||||
|
override fun method(): String = "getMyDescription"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<BotDescription>
|
||||||
|
get() = BotDescription.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class GetMyName(
|
||||||
|
@SerialName(languageCodeField)
|
||||||
|
@Serializable(IetfLanguageCodeSerializer::class)
|
||||||
|
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||||
|
) : SimpleRequest<BotName>, WithOptionalLanguageCode {
|
||||||
|
override fun method(): String = "getMyName"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<BotName>
|
||||||
|
get() = BotName.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class GetMyShortDescription(
|
||||||
|
@SerialName(languageCodeField)
|
||||||
|
@Serializable(IetfLanguageCodeSerializer::class)
|
||||||
|
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||||
|
) : SimpleRequest<BotShortDescription>, WithOptionalLanguageCode {
|
||||||
|
override fun method(): String = "getMyShortDescription"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<BotShortDescription>
|
||||||
|
get() = BotShortDescription.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class SetMyDescription(
|
||||||
|
@SerialName(descriptionField)
|
||||||
|
val description: String? = null,
|
||||||
|
@SerialName(languageCodeField)
|
||||||
|
@Serializable(IetfLanguageCodeSerializer::class)
|
||||||
|
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||||
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
|
override fun method(): String = "setMyDescription"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = Boolean.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class SetMyName(
|
||||||
|
@SerialName(nameField)
|
||||||
|
val name: String? = null,
|
||||||
|
@SerialName(languageCodeField)
|
||||||
|
@Serializable(IetfLanguageCodeSerializer::class)
|
||||||
|
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||||
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
|
override fun method(): String = "setMyName"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = Boolean.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class SetMyShortDescription(
|
||||||
|
@SerialName(shortDescriptionField)
|
||||||
|
val shortDescription: String? = null,
|
||||||
|
@SerialName(languageCodeField)
|
||||||
|
@Serializable(IetfLanguageCodeSerializer::class)
|
||||||
|
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||||
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
|
override fun method(): String = "setMyShortDescription"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = Boolean.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ data class GetChat(
|
|||||||
override val resultDeserializer: DeserializationStrategy<ExtendedChat> = if (chatId is ChatIdWithThreadId) {
|
override val resultDeserializer: DeserializationStrategy<ExtendedChat> = if (chatId is ChatIdWithThreadId) {
|
||||||
ExtendedChatSerializer.BasedOnForumThread(chatId.threadId)
|
ExtendedChatSerializer.BasedOnForumThread(chatId.threadId)
|
||||||
} else {
|
} else {
|
||||||
ExtendedChatSerializer
|
ExtendedChatSerializer.Companion
|
||||||
}
|
}
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.abstracts
|
package dev.inmo.tgbotapi.requests.send.abstracts
|
||||||
|
|
||||||
interface ThumbedSendMessageRequest<T: Any>: SendMessageRequest<T> {
|
interface ThumbedSendMessageRequest<T: Any>: SendMessageRequest<T> {
|
||||||
|
val thumbnail: String?
|
||||||
|
|
||||||
|
@Deprecated("Renamed in telegram bot api", ReplaceWith("thumbnail"))
|
||||||
val thumb: String?
|
val thumb: String?
|
||||||
|
get() = thumbnail
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -22,7 +23,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendAnimation(
|
fun SendAnimation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
animation: InputFile,
|
animation: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
@@ -36,15 +37,13 @@ fun SendAnimation(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AnimationContent>> {
|
): Request<ContentMessage<AnimationContent>> {
|
||||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
|
||||||
val animationAsFile = animation as? MultipartFile
|
val animationAsFile = animation as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAnimationData(
|
val data = SendAnimationData(
|
||||||
chatId,
|
chatId,
|
||||||
animationAsFileId,
|
animation,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -63,9 +62,9 @@ fun SendAnimation(
|
|||||||
return if (animationAsFile == null && thumbAsFile == null) {
|
return if (animationAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAnimationFiles(animationAsFile, thumbAsFile)
|
listOfNotNull(animationAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +72,7 @@ fun SendAnimation(
|
|||||||
fun SendAnimation(
|
fun SendAnimation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
animation: InputFile,
|
animation: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
@@ -86,15 +85,13 @@ fun SendAnimation(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AnimationContent>> {
|
): Request<ContentMessage<AnimationContent>> {
|
||||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
|
||||||
val animationAsFile = animation as? MultipartFile
|
val animationAsFile = animation as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAnimationData(
|
val data = SendAnimationData(
|
||||||
chatId,
|
chatId,
|
||||||
animationAsFileId,
|
animation,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -113,9 +110,9 @@ fun SendAnimation(
|
|||||||
return if (animationAsFile == null && thumbAsFile == null) {
|
return if (animationAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAnimationFiles(animationAsFile, thumbAsFile)
|
listOfNotNull(animationAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,9 +125,9 @@ data class SendAnimationData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(animationField)
|
@SerialName(animationField)
|
||||||
val animation: String? = null,
|
val animation: InputFile,
|
||||||
@SerialName(thumbField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
@@ -187,8 +184,8 @@ data class SendAnimationData internal constructor(
|
|||||||
|
|
||||||
data class SendAnimationFiles internal constructor(
|
data class SendAnimationFiles internal constructor(
|
||||||
val animation: MultipartFile? = null,
|
val animation: MultipartFile? = null,
|
||||||
val thumb: MultipartFile? = null
|
val thumbnail: MultipartFile? = null
|
||||||
) : Files by mapOfNotNull(
|
) : Files by mapOfNotNull(
|
||||||
animationField to animation,
|
animationField to animation,
|
||||||
thumbField to thumb
|
thumbnailField to thumbnail
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.send.media
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.Performerable
|
import dev.inmo.tgbotapi.abstracts.Performerable
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -23,7 +24,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendAudio(
|
fun SendAudio(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
audio: InputFile,
|
audio: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
@@ -36,15 +37,13 @@ fun SendAudio(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AudioContent>> {
|
): Request<ContentMessage<AudioContent>> {
|
||||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
|
||||||
val audioAsFile = audio as? MultipartFile
|
val audioAsFile = audio as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAudioData(
|
val data = SendAudioData(
|
||||||
chatId,
|
chatId,
|
||||||
audioAsFileId,
|
audio,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -62,9 +61,9 @@ fun SendAudio(
|
|||||||
return if (audioAsFile == null && thumbAsFile == null) {
|
return if (audioAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAudioFiles(audioAsFile, thumbAsFile)
|
listOfNotNull(audioAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +71,7 @@ fun SendAudio(
|
|||||||
fun SendAudio(
|
fun SendAudio(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
audio: InputFile,
|
audio: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: List<TextSource>,
|
entities: List<TextSource>,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
performer: String? = null,
|
performer: String? = null,
|
||||||
@@ -84,15 +83,13 @@ fun SendAudio(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AudioContent>> {
|
): Request<ContentMessage<AudioContent>> {
|
||||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
|
||||||
val audioAsFile = audio as? MultipartFile
|
val audioAsFile = audio as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAudioData(
|
val data = SendAudioData(
|
||||||
chatId,
|
chatId,
|
||||||
audioAsFileId,
|
audio,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -110,9 +107,9 @@ fun SendAudio(
|
|||||||
return if (audioAsFile == null && thumbAsFile == null) {
|
return if (audioAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAudioFiles(audioAsFile, thumbAsFile)
|
listOfNotNull(audioAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,9 +122,9 @@ data class SendAudioData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(audioField)
|
@SerialName(audioField)
|
||||||
val audio: String? = null,
|
val audio: InputFile,
|
||||||
@SerialName(thumbField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
@@ -182,8 +179,8 @@ data class SendAudioData internal constructor(
|
|||||||
|
|
||||||
data class SendAudioFiles internal constructor(
|
data class SendAudioFiles internal constructor(
|
||||||
val audio: MultipartFile? = null,
|
val audio: MultipartFile? = null,
|
||||||
val thumb: MultipartFile? = null
|
val thumbnail: MultipartFile? = null
|
||||||
) : Files by mapOfNotNull(
|
) : Files by mapOfNotNull(
|
||||||
audioField to audio,
|
audioField to audio,
|
||||||
thumbField to thumb
|
thumbnailField to thumbnail
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -31,7 +32,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendDocument(
|
fun SendDocument(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
document: InputFile,
|
document: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
@@ -42,15 +43,13 @@ fun SendDocument(
|
|||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
disableContentTypeDetection: Boolean? = null
|
disableContentTypeDetection: Boolean? = null
|
||||||
): Request<ContentMessage<DocumentContent>> {
|
): Request<ContentMessage<DocumentContent>> {
|
||||||
val documentAsFileId = (document as? FileId) ?.fileId
|
|
||||||
val documentAsFile = document as? MultipartFile
|
val documentAsFile = document as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendDocumentData(
|
val data = SendDocumentData(
|
||||||
chatId,
|
chatId,
|
||||||
documentAsFileId,
|
document,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -66,9 +65,9 @@ fun SendDocument(
|
|||||||
return if (documentAsFile == null && thumbAsFile == null) {
|
return if (documentAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendDocumentFiles(documentAsFile, thumbAsFile)
|
listOfNotNull(documentAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,7 +84,7 @@ fun SendDocument(
|
|||||||
fun SendDocument(
|
fun SendDocument(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
document: InputFile,
|
document: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
@@ -95,15 +94,13 @@ fun SendDocument(
|
|||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
disableContentTypeDetection: Boolean? = null
|
disableContentTypeDetection: Boolean? = null
|
||||||
): Request<ContentMessage<DocumentContent>> {
|
): Request<ContentMessage<DocumentContent>> {
|
||||||
val documentAsFileId = (document as? FileId) ?.fileId
|
|
||||||
val documentAsFile = document as? MultipartFile
|
val documentAsFile = document as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendDocumentData(
|
val data = SendDocumentData(
|
||||||
chatId,
|
chatId,
|
||||||
documentAsFileId,
|
document,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -119,9 +116,9 @@ fun SendDocument(
|
|||||||
return if (documentAsFile == null && thumbAsFile == null) {
|
return if (documentAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendDocumentFiles(documentAsFile, thumbAsFile)
|
listOfNotNull(documentAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,9 +140,9 @@ data class SendDocumentData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(documentField)
|
@SerialName(documentField)
|
||||||
val document: String? = null,
|
val document: InputFile,
|
||||||
@SerialName(thumbField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
@@ -193,8 +190,8 @@ data class SendDocumentData internal constructor(
|
|||||||
|
|
||||||
data class SendDocumentFiles internal constructor(
|
data class SendDocumentFiles internal constructor(
|
||||||
val document: MultipartFile? = null,
|
val document: MultipartFile? = null,
|
||||||
val thumb: MultipartFile? = null
|
val thumbnail: MultipartFile? = null
|
||||||
) : Files by mapOfNotNull(
|
) : Files by mapOfNotNull(
|
||||||
documentField to document,
|
documentField to document,
|
||||||
thumbField to thumb
|
thumbnailField to thumbnail
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package dev.inmo.tgbotapi.requests.send.media
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.media.*
|
import dev.inmo.tgbotapi.types.media.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
|
||||||
@@ -37,7 +39,7 @@ fun <T : MediaGroupPartContent> SendMediaGroup(
|
|||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null
|
allowSendingWithoutReply: Boolean? = null
|
||||||
): Request<PossiblySentViaBotCommonMessage<MediaGroupContent<T>>> {
|
): Request<ContentMessage<MediaGroupContent<T>>> {
|
||||||
if (media.size !in mediaCountInMediaGroup) {
|
if (media.size !in mediaCountInMediaGroup) {
|
||||||
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
||||||
}
|
}
|
||||||
@@ -66,11 +68,11 @@ fun <T : MediaGroupPartContent> SendMediaGroup(
|
|||||||
return (if (files.isEmpty()) {
|
return (if (files.isEmpty()) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendMediaGroupFiles(files)
|
files.associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}) as Request<PossiblySentViaBotCommonMessage<MediaGroupContent<T>>>
|
}) as Request<ContentMessage<MediaGroupContent<T>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -33,7 +34,7 @@ fun SendPhoto(
|
|||||||
): Request<ContentMessage<PhotoContent>> {
|
): Request<ContentMessage<PhotoContent>> {
|
||||||
val data = SendPhotoData(
|
val data = SendPhotoData(
|
||||||
chatId,
|
chatId,
|
||||||
(photo as? FileId) ?.fileId,
|
photo,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -45,12 +46,14 @@ fun SendPhoto(
|
|||||||
allowSendingWithoutReply,
|
allowSendingWithoutReply,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
return data.photo ?.let {
|
return if (photo is MultipartFile) {
|
||||||
|
CommonMultipartFileRequest(
|
||||||
|
data,
|
||||||
|
listOf(photo).associateBy { it.fileId }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
data
|
data
|
||||||
} ?: MultipartRequestImpl(
|
}
|
||||||
data,
|
|
||||||
SendPhotoFiles(photo as MultipartFile)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SendPhoto(
|
fun SendPhoto(
|
||||||
@@ -67,7 +70,7 @@ fun SendPhoto(
|
|||||||
): Request<ContentMessage<PhotoContent>> {
|
): Request<ContentMessage<PhotoContent>> {
|
||||||
val data = SendPhotoData(
|
val data = SendPhotoData(
|
||||||
chatId,
|
chatId,
|
||||||
(photo as? FileId)?.fileId,
|
photo,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -79,12 +82,15 @@ fun SendPhoto(
|
|||||||
allowSendingWithoutReply,
|
allowSendingWithoutReply,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
return data.photo ?.let {
|
|
||||||
|
return if (photo is MultipartFile) {
|
||||||
|
CommonMultipartFileRequest(
|
||||||
|
data,
|
||||||
|
listOf(photo).associateBy { it.fileId }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
data
|
data
|
||||||
} ?: MultipartRequestImpl(
|
}
|
||||||
data,
|
|
||||||
SendPhotoFiles(photo as MultipartFile)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
||||||
@@ -95,7 +101,7 @@ data class SendPhotoData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(photoField)
|
@SerialName(photoField)
|
||||||
val photo: String? = null,
|
val photo: InputFile,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -8,14 +9,19 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
||||||
|
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||||
import dev.inmo.tgbotapi.utils.toJsonWithoutNulls
|
import dev.inmo.tgbotapi.utils.toJsonWithoutNulls
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
import kotlinx.serialization.json.JsonPrimitive
|
||||||
|
import kotlinx.serialization.json.buildJsonObject
|
||||||
|
import kotlinx.serialization.json.put
|
||||||
|
|
||||||
fun SendSticker(
|
fun SendSticker(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
@@ -23,7 +29,7 @@ fun SendSticker(
|
|||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
|
): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
|
||||||
chatId,
|
chatId,
|
||||||
sticker as? FileId,
|
sticker,
|
||||||
threadId,
|
threadId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@@ -32,7 +38,10 @@ fun SendSticker(
|
|||||||
replyMarkup
|
replyMarkup
|
||||||
).let {
|
).let {
|
||||||
when (sticker) {
|
when (sticker) {
|
||||||
is MultipartFile -> SendStickerByFile(it, sticker)
|
is MultipartFile -> CommonMultipartFileRequest(
|
||||||
|
it,
|
||||||
|
listOf(sticker).associateBy { it.fileId }
|
||||||
|
)
|
||||||
is FileId -> it
|
is FileId -> it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +54,7 @@ data class SendStickerByFileId internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(stickerField)
|
@SerialName(stickerField)
|
||||||
val sticker: FileId? = null,
|
val sticker: InputFile,
|
||||||
@SerialName(messageThreadIdField)
|
@SerialName(messageThreadIdField)
|
||||||
override val threadId: MessageThreadId? = chatId.threadId,
|
override val threadId: MessageThreadId? = chatId.threadId,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
@@ -65,12 +74,3 @@ data class SendStickerByFileId internal constructor(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendStickerByFile internal constructor(
|
|
||||||
@Transient
|
|
||||||
private val sendStickerByFileId: SendStickerByFileId,
|
|
||||||
val sticker: MultipartFile
|
|
||||||
) : MultipartRequest<ContentMessage<StickerContent>>, Request<ContentMessage<StickerContent>> by sendStickerByFileId {
|
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
|
||||||
override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -22,7 +23,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendVideo(
|
fun SendVideo(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
video: InputFile,
|
video: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
@@ -37,15 +38,13 @@ fun SendVideo(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VideoContent>> {
|
): Request<ContentMessage<VideoContent>> {
|
||||||
val videoAsFileId = (video as? FileId) ?.fileId
|
|
||||||
val videoAsFile = video as? MultipartFile
|
val videoAsFile = video as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVideoData(
|
val data = SendVideoData(
|
||||||
chatId,
|
chatId,
|
||||||
videoAsFileId,
|
video,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -65,9 +64,9 @@ fun SendVideo(
|
|||||||
return if (videoAsFile == null && thumbAsFile == null) {
|
return if (videoAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVideoFiles(videoAsFile, thumbAsFile)
|
listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +74,7 @@ fun SendVideo(
|
|||||||
fun SendVideo(
|
fun SendVideo(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
video: InputFile,
|
video: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
@@ -89,15 +88,13 @@ fun SendVideo(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VideoContent>> {
|
): Request<ContentMessage<VideoContent>> {
|
||||||
val videoAsFileId = (video as? FileId) ?.fileId
|
|
||||||
val videoAsFile = video as? MultipartFile
|
val videoAsFile = video as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVideoData(
|
val data = SendVideoData(
|
||||||
chatId,
|
chatId,
|
||||||
videoAsFileId,
|
video,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -117,9 +114,9 @@ fun SendVideo(
|
|||||||
return if (videoAsFile == null && thumbAsFile == null) {
|
return if (videoAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVideoFiles(videoAsFile, thumbAsFile)
|
listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,9 +129,9 @@ data class SendVideoData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(videoField)
|
@SerialName(videoField)
|
||||||
val video: String? = null,
|
val video: InputFile,
|
||||||
@SerialName(thumbField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
@@ -193,8 +190,8 @@ data class SendVideoData internal constructor(
|
|||||||
|
|
||||||
data class SendVideoFiles internal constructor(
|
data class SendVideoFiles internal constructor(
|
||||||
val video: MultipartFile? = null,
|
val video: MultipartFile? = null,
|
||||||
val thumb: MultipartFile? = null
|
val thumbnail: MultipartFile? = null
|
||||||
) : Files by mapOfNotNull(
|
) : Files by mapOfNotNull(
|
||||||
videoField to video,
|
videoField to video,
|
||||||
thumbField to thumb
|
thumbnailField to thumbnail
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -14,7 +15,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendVideoNote(
|
fun SendVideoNote(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
videoNote: InputFile,
|
videoNote: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
size: Int? = null, // in documentation - length (size of video side)
|
size: Int? = null, // in documentation - length (size of video side)
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
@@ -24,15 +25,13 @@ fun SendVideoNote(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VideoNoteContent>> {
|
): Request<ContentMessage<VideoNoteContent>> {
|
||||||
val videoNoteAsFileId = (videoNote as? FileId) ?.fileId
|
|
||||||
val videoNoteAsFile = videoNote as? MultipartFile
|
val videoNoteAsFile = videoNote as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVideoNoteData(
|
val data = SendVideoNoteData(
|
||||||
chatId,
|
chatId,
|
||||||
videoNoteAsFileId,
|
videoNote,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
duration,
|
duration,
|
||||||
size,
|
size,
|
||||||
threadId,
|
threadId,
|
||||||
@@ -46,9 +45,9 @@ fun SendVideoNote(
|
|||||||
return if (videoNoteAsFile == null && thumbAsFile == null) {
|
return if (videoNoteAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVideoNoteFiles(videoNoteAsFile, thumbAsFile)
|
listOfNotNull(videoNoteAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,9 +60,9 @@ data class SendVideoNoteData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(videoNoteField)
|
@SerialName(videoNoteField)
|
||||||
val videoNote: String? = null,
|
val videoNote: InputFile,
|
||||||
@SerialName(thumbField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(durationField)
|
@SerialName(durationField)
|
||||||
override val duration: Long? = null,
|
override val duration: Long? = null,
|
||||||
@SerialName(lengthField)
|
@SerialName(lengthField)
|
||||||
@@ -99,8 +98,8 @@ data class SendVideoNoteData internal constructor(
|
|||||||
|
|
||||||
data class SendVideoNoteFiles internal constructor(
|
data class SendVideoNoteFiles internal constructor(
|
||||||
val videoNote: MultipartFile? = null,
|
val videoNote: MultipartFile? = null,
|
||||||
val thumb: MultipartFile? = null
|
val thumbnail: MultipartFile? = null
|
||||||
) : Files by mapOfNotNull(
|
) : Files by mapOfNotNull(
|
||||||
videoNoteField to videoNote,
|
videoNoteField to videoNote,
|
||||||
thumbField to thumb
|
thumbnailField to thumbnail
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -32,12 +33,11 @@ fun SendVoice(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VoiceContent>> {
|
): Request<ContentMessage<VoiceContent>> {
|
||||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
|
||||||
val voiceAsFile = voice as? MultipartFile
|
val voiceAsFile = voice as? MultipartFile
|
||||||
|
|
||||||
val data = SendVoiceData(
|
val data = SendVoiceData(
|
||||||
chatId,
|
chatId,
|
||||||
voiceAsFileId,
|
voice,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -53,9 +53,9 @@ fun SendVoice(
|
|||||||
return if (voiceAsFile == null) {
|
return if (voiceAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVoiceFiles(voiceAsFile)
|
listOfNotNull(voiceAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,12 +72,11 @@ fun SendVoice(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VoiceContent>> {
|
): Request<ContentMessage<VoiceContent>> {
|
||||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
|
||||||
val voiceAsFile = voice as? MultipartFile
|
val voiceAsFile = voice as? MultipartFile
|
||||||
|
|
||||||
val data = SendVoiceData(
|
val data = SendVoiceData(
|
||||||
chatId,
|
chatId,
|
||||||
voiceAsFileId,
|
voice,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -93,9 +92,9 @@ fun SendVoice(
|
|||||||
return if (voiceAsFile == null) {
|
return if (voiceAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVoiceFiles(voiceAsFile)
|
listOfNotNull(voiceAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +107,7 @@ data class SendVoiceData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(voiceField)
|
@SerialName(voiceField)
|
||||||
val voice: String? = null,
|
val voice: InputFile,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
@@ -156,8 +155,8 @@ data class SendVoiceData internal constructor(
|
|||||||
|
|
||||||
data class SendVoiceFiles internal constructor(
|
data class SendVoiceFiles internal constructor(
|
||||||
val voice: MultipartFile? = null,
|
val voice: MultipartFile? = null,
|
||||||
val thumb: MultipartFile? = null
|
val thumbnail: MultipartFile? = null
|
||||||
) : Files by mapOfNotNull(
|
) : Files by mapOfNotNull(
|
||||||
voiceField to voice,
|
voiceField to voice,
|
||||||
thumbField to thumb
|
thumbnailField to thumbnail
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun AddAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
|
||||||
val data = AddAnimatedStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
|
||||||
return when (sticker) {
|
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
|
||||||
data,
|
|
||||||
mapOf(tgsStickerField to sticker)
|
|
||||||
)
|
|
||||||
is FileId -> data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AddAnimatedStickerToSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(tgsStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : StandardStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "addStickerToSet"
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun AddStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
|
||||||
val data = AddStaticStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
|
||||||
return when (sticker) {
|
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
|
||||||
data,
|
|
||||||
mapOf(pngStickerField to sticker)
|
|
||||||
)
|
|
||||||
is FileId -> data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AddStaticStickerToSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(pngStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : StandardStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "addStickerToSet"
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user