mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 12:00:18 +00:00
Compare commits
101 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7477625380 | |||
| 970abf8cde | |||
| 5a7741faf6 | |||
| 8aa29e56d3 | |||
| dab5e072d0 | |||
| 94078939d1 | |||
| 824d3862e3 | |||
| 44f92e8d6c | |||
| ddb79c0d8d | |||
| a9562cc8f9 | |||
| 8a351d5be0 | |||
| 8cd5659b7b | |||
| 1474a07b9e | |||
| c13a0d3193 | |||
| 172f49fa6b | |||
| 4d42972a7e | |||
| c0883d0180 | |||
| e7367da3cb | |||
| effd12711f | |||
| ef1d2e8242 | |||
| 881763f3af | |||
| d36b11c002 | |||
| d2395e836c | |||
| c8c008edd3 | |||
| 3b4fa06924 | |||
| 5d428a5e54 | |||
| 8964e08ce6 | |||
| 745168d181 | |||
| a408c6c7c7 | |||
| e0f5e9b640 | |||
| 0331ff2f42 | |||
| a21d0b56db | |||
|
|
6ea8afee8f | ||
|
|
8799aeca26 | ||
| c610f4eab2 | |||
| 92cd2a3def | |||
| 03d158b03b | |||
|
|
608fde4139 | ||
| 9e56a6cc1a | |||
| c0e3c1d02f | |||
| 341a527d27 | |||
|
|
8d6d70a06a | ||
|
|
67fb552d01 | ||
|
|
93e937aa6a | ||
|
|
09dee188d2 | ||
|
|
29c6bb5dac | ||
| c266ab0120 | |||
|
|
b407fc5c86 | ||
|
|
1bde43ceaf | ||
|
|
389a508fa7 | ||
|
|
69c2586b50 | ||
|
|
7e80f4edac | ||
|
|
99987c3f51 | ||
|
|
713130fd13 | ||
| deb8d7b43a | |||
| b604444f7d | |||
|
|
cb6127bf91 | ||
|
|
d40919f099 | ||
|
|
7cb576e6b1 | ||
|
|
b53fb8da36 | ||
|
|
03ea8dfe7f | ||
|
|
314c8d9ad1 | ||
|
|
6fceee4199 | ||
|
|
e720da708c | ||
|
|
d65706631f | ||
|
|
3312b64564 | ||
|
|
1bfe431393 | ||
|
|
6485353704 | ||
|
|
46a1ed27b7 | ||
|
|
9f3024476c | ||
|
|
93d0e009bb | ||
|
|
ef60549e1c | ||
|
|
2ac83156f6 | ||
|
|
4c9d888668 | ||
|
|
cd3ba8f480 | ||
|
|
99559f477e | ||
|
|
a3949c752d | ||
| fd48a52266 | |||
| 3e0036f7df | |||
| 2978932c87 | |||
| c773736fb8 | |||
| 8a3a05ef12 | |||
| 0afbe8ef2d | |||
| 3f4018f969 | |||
| 097d82b4b4 | |||
| 7c2a379161 | |||
| ba5f76e8cd | |||
| 8aec920a15 | |||
| c92bd33ba1 | |||
| 51927974f5 | |||
| 9350f87e19 | |||
| 6cb9950b36 | |||
| 974c2e883f | |||
| af6f98fd56 | |||
| 75a2b2c282 | |||
| d66d4b4209 | |||
| 9d54820fd7 | |||
| 1876df2c2d | |||
| d818592cd3 | |||
| c29737b6b3 | |||
| 46243a21eb |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1,3 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
custom: ['https://www.tinkoff.ru/rm/ovsyannikov.aleksey113/ObMJ712472', 'https://boosty.to/insanusmokrassar']
|
||||
custom: ['https://tonscan.org/address/UQAtuSLJ76Zehc3qP-eRYMR98fPIu_oOp_atcpVX55zxHwTU']
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ out/
|
||||
local.properties
|
||||
kotlin-js-store/
|
||||
secret.gradle
|
||||
.aider*
|
||||
|
||||
46
CHANGELOG.md
46
CHANGELOG.md
@@ -1,7 +1,53 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 25.0.0
|
||||
|
||||
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.0](https://core.telegram.org/bots/api-changelog#april-11-2025)**
|
||||
|
||||
* `Core`:
|
||||
* Previously named `Gift` now presented by `Gift.Regular`
|
||||
* Fixes in `MultipartRequestCallFactory` for correct handling of all `MultipartRequest.Common` inheritors
|
||||
* `Username` now can be safely created with `Username.prepare`
|
||||
* Add extensions `String.splitFor(Text|Caption|StoryCaption)` for preparing several texts for several
|
||||
messages/captions/story captions
|
||||
|
||||
## 24.0.2
|
||||
|
||||
* `Version`:
|
||||
* `Kotlin`: `2.1.10` -> `2.1.20`
|
||||
* `Ktor`: `3.1.0` -> `3.1.1`
|
||||
* `MicroUtils`: `0.24.7` -> `0.25.3`
|
||||
* `DefaultKTgBotAPIKSLog` will drop `CancellationException`s by default
|
||||
* You may configure `DefaultKTgBotAPIKSLog` in simple way with `SetDefaultKTgBotAPIKSLog`
|
||||
* `BehaviourBuilder`:
|
||||
* `FSM`:
|
||||
* Fix chains cancelling on their ends
|
||||
|
||||
## 24.0.1
|
||||
|
||||
* `Core`:
|
||||
* Now you may upload photos with `EditChatMessageMedia`
|
||||
|
||||
## 24.0.0
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES IN `subcontextUpdatesFilter` WORK. TAKE CARE IN MIGRATION**
|
||||
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.24.6` -> `0.24.7`
|
||||
* `Core`:
|
||||
* `ForumContentMessage` got property `threadCreatingInfo` which represents information about topic where message has been sent
|
||||
* `BehaviourBuilder`:
|
||||
* Fix of overall `subcontextUpdatesFilter` behaviour. In fact, this update will fix its affection on scenaries
|
||||
|
||||
## 23.2.1
|
||||
|
||||
* `Core`:
|
||||
* Fix of `year` field in `Birthdate`
|
||||
|
||||
## 23.2.0
|
||||
|
||||
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 8.3](https://core.telegram.org/bots/api-changelog#february-12-2025)**
|
||||
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.24.5` -> `0.24.6`
|
||||
* `Ktor`: `3.0.3` -> `3.1.0`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#january-1-2025)
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-11-2025)
|
||||
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
|
||||
14
build.gradle
14
build.gradle
@@ -48,12 +48,20 @@ private String getCurrentVersionChangelog() {
|
||||
return changelogDataOS.toString().trim()
|
||||
}
|
||||
|
||||
if (new File(projectDir, "secret.gradle").exists()) {
|
||||
apply from: './secret.gradle'
|
||||
|
||||
def githubTokenVariableName = "GITHUB_RELEASE_TOKEN"
|
||||
def githubTokenVariableFromEnv = System.getenv(githubTokenVariableName)
|
||||
|
||||
def secretFile = new File(projectDir, "secret.gradle")
|
||||
if (secretFile.exists() || project.hasProperty(githubTokenVariableName) || (githubTokenVariableFromEnv != "" && githubTokenVariableFromEnv != null)) {
|
||||
if (secretFile.exists()) {
|
||||
apply from: './secret.gradle'
|
||||
}
|
||||
apply plugin: "com.github.breadmoirai.github-release"
|
||||
def githubReleaseToken = project.hasProperty(githubTokenVariableName) ? project.property(githubTokenVariableName).toString() : githubTokenVariableFromEnv
|
||||
|
||||
githubRelease {
|
||||
token "${project.property('GITHUB_RELEASE_TOKEN')}"
|
||||
token githubReleaseToken
|
||||
|
||||
owner = "InsanusMokrassar"
|
||||
repo = "TelegramBotAPI"
|
||||
|
||||
@@ -15,3 +15,13 @@ allprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("getPublishableModules") {
|
||||
doLast {
|
||||
rootProject.subprojects.each { project ->
|
||||
if (project.plugins.hasPlugin('maven-publish')) {
|
||||
println(":${project.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=23.2.0
|
||||
library_version=25.0.0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "2.1.10"
|
||||
kotlin = "2.1.20"
|
||||
kotlin-serialization = "1.8.0"
|
||||
kotlin-coroutines = "1.10.1"
|
||||
|
||||
@@ -8,12 +8,12 @@ javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "5.4.0"
|
||||
uuid = "0.8.4"
|
||||
ktor = "3.1.0"
|
||||
ktor = "3.1.1"
|
||||
|
||||
ksp = "2.1.10-1.0.29"
|
||||
ksp = "2.1.20-1.0.31"
|
||||
kotlin-poet = "1.18.1"
|
||||
|
||||
microutils = "0.24.6"
|
||||
microutils = "0.25.3"
|
||||
kslog = "1.4.1"
|
||||
|
||||
versions = "0.51.0"
|
||||
@@ -57,6 +57,7 @@ microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization
|
||||
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
|
||||
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
||||
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
||||
microutils-ksp-generator = { module = "dev.inmo:micro_utils.ksp.generator", version.ref = "microutils" }
|
||||
microutils-ksp-sealed = { module = "dev.inmo:micro_utils.ksp.sealed", version.ref = "microutils" }
|
||||
microutils-ksp-sealed-generator = { module = "dev.inmo:micro_utils.ksp.sealed.generator", version.ref = "microutils" }
|
||||
microutils-ksp-variations = { module = "dev.inmo:micro_utils.ksp.variations", version.ref = "microutils" }
|
||||
|
||||
@@ -1,4 +1,54 @@
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.net.http.HttpClient
|
||||
import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse
|
||||
|
||||
apply plugin: 'maven-publish'
|
||||
// This script work based on https://ossrh-staging-api.central.sonatype.com/swagger-ui/#/default/manual_upload_repository
|
||||
// and getting available open repos and just uploading them
|
||||
def uploadTaskName = "uploadSonatypePublication"
|
||||
String getBearer() {
|
||||
def username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||
def password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||
return Base64.getEncoder().encodeToString("$username:$password".getBytes(StandardCharsets.UTF_8))
|
||||
}
|
||||
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||
if (rootProject.tasks.names.contains(uploadTaskName) == false) {
|
||||
rootProject.tasks.register(uploadTaskName) {
|
||||
doLast {
|
||||
def bearer = getBearer()
|
||||
|
||||
def client = HttpClient.newHttpClient()
|
||||
def request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?state=open"))
|
||||
.GET()
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", "Bearer $bearer")
|
||||
.build()
|
||||
|
||||
def response = client.send(request, HttpResponse.BodyHandlers.ofString())
|
||||
def keys = new ArrayList<String>()
|
||||
response.body().findAll("\"key\"[\\s]*:[\\s]*\"[^\"]+\"").forEach {
|
||||
def key = it.find("[^\"]+\"\$").find("[^\"]+")
|
||||
keys.add(key)
|
||||
}
|
||||
keys.forEach {
|
||||
println("Start uploading $it")
|
||||
def uploadRequest = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://ossrh-staging-api.central.sonatype.com/manual/upload/repository/$it?publishing_type=user_managed"))
|
||||
.POST(HttpRequest.BodyPublishers.ofString(""))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", "Bearer $bearer")
|
||||
.build()
|
||||
def uploadResponse = client.send(uploadRequest, HttpResponse.BodyHandlers.ofString())
|
||||
if (uploadResponse.statusCode() != 200) {
|
||||
println("Faced error of uploading for repo with key $it. Response: $uploadResponse. Check https://central.sonatype.com/publishing/deployments for info or repo with key $it. Response: $uploadResponse")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task javadocsJar(type: Jar) {
|
||||
archiveClassifier = 'javadoc'
|
||||
@@ -19,59 +69,52 @@ publishing {
|
||||
}
|
||||
|
||||
developers {
|
||||
|
||||
developer {
|
||||
id = "InsanusMokrassar"
|
||||
name = "Ovsiannikov Aleksei"
|
||||
email = "ovsyannikov.alexey95@gmail.com"
|
||||
}
|
||||
|
||||
developer {
|
||||
id = "InsanusMokrassar"
|
||||
name = "Ovsiannikov Aleksei"
|
||||
email = "ovsyannikov.alexey95@gmail.com"
|
||||
}
|
||||
}
|
||||
|
||||
licenses {
|
||||
|
||||
license {
|
||||
name = "Apache Software License 2.0"
|
||||
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||
}
|
||||
|
||||
license {
|
||||
name = "Apache Software License 2.0"
|
||||
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
if ((project.hasProperty('GITHUB_USER') || System.getenv('GITHUB_USER') != null) && (project.hasProperty('GITHUB_TOKEN') || System.getenv('GITHUB_TOKEN') != null)) {
|
||||
maven {
|
||||
name = "GithubPackages"
|
||||
url = uri("https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi")
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('GITHUB_USER') ? project.property('GITHUB_USER') : System.getenv('GITHUB_USER')
|
||||
password = project.hasProperty('GITHUB_TOKEN') ? project.property('GITHUB_TOKEN') : System.getenv('GITHUB_TOKEN')
|
||||
}
|
||||
|
||||
}
|
||||
repositories {
|
||||
if ((project.hasProperty('GITHUB_USER') || System.getenv('GITHUB_USER') != null) && (project.hasProperty('GITHUB_TOKEN') || System.getenv('GITHUB_TOKEN') != null)) {
|
||||
maven {
|
||||
name = "GithubPackages"
|
||||
url = uri("https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi")
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('GITHUB_USER') ? project.property('GITHUB_USER') : System.getenv('GITHUB_USER')
|
||||
password = project.hasProperty('GITHUB_TOKEN') ? project.property('GITHUB_TOKEN') : System.getenv('GITHUB_TOKEN')
|
||||
}
|
||||
}
|
||||
if ((project.hasProperty('INMONEXUS_USER') || System.getenv('INMONEXUS_USER') != null) && (project.hasProperty('INMONEXUS_PASSWORD') || System.getenv('INMONEXUS_PASSWORD') != null)) {
|
||||
maven {
|
||||
name = "InmoNexus"
|
||||
url = uri("https://nexus.inmo.dev/repository/maven-releases/")
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('INMONEXUS_USER') ? project.property('INMONEXUS_USER') : System.getenv('INMONEXUS_USER')
|
||||
password = project.hasProperty('INMONEXUS_PASSWORD') ? project.property('INMONEXUS_PASSWORD') : System.getenv('INMONEXUS_PASSWORD')
|
||||
}
|
||||
|
||||
}
|
||||
if ((project.hasProperty('INMONEXUS_USER') || System.getenv('INMONEXUS_USER') != null) && (project.hasProperty('INMONEXUS_PASSWORD') || System.getenv('INMONEXUS_PASSWORD') != null)) {
|
||||
maven {
|
||||
name = "InmoNexus"
|
||||
url = uri("https://nexus.inmo.dev/repository/maven-releases/")
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('INMONEXUS_USER') ? project.property('INMONEXUS_USER') : System.getenv('INMONEXUS_USER')
|
||||
password = project.hasProperty('INMONEXUS_PASSWORD') ? project.property('INMONEXUS_PASSWORD') : System.getenv('INMONEXUS_PASSWORD')
|
||||
}
|
||||
}
|
||||
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||
}
|
||||
|
||||
}
|
||||
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = uri("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/")
|
||||
|
||||
credentials {
|
||||
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,13 +123,13 @@ publishing {
|
||||
|
||||
if (project.hasProperty("signing.gnupg.keyName")) {
|
||||
apply plugin: 'signing'
|
||||
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
|
||||
|
||||
sign publishing.publications
|
||||
}
|
||||
|
||||
|
||||
task signAll {
|
||||
tasks.withType(Sign).forEach {
|
||||
dependsOn(it)
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"${project.description}","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.UsernameAndPassword","usernameProperty":"GITHUB_USER","passwordProperty":"GITHUB_TOKEN"}},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}
|
||||
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"${project.description}","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.UsernameAndPassword","usernameProperty":"GITHUB_USER","passwordProperty":"GITHUB_TOKEN"}},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"},"includeCentralSonatypeUploadingScript":true}}
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
|
||||
25
publish_all_script
Executable file
25
publish_all_script
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
function send_notification() {
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
function assert_success() {
|
||||
"${@}"
|
||||
local status=${?}
|
||||
if [ ${status} -ne 0 ]; then
|
||||
send_notification "### Error ${status} at: ${BASH_LINENO[*]} ###"
|
||||
exit ${status}
|
||||
fi
|
||||
}
|
||||
|
||||
readarray -t projects <<< "`./gradlew getPublishableModules --quiet`"
|
||||
for project in "${projects[@]}"; do
|
||||
echo "Start publishing of $project"
|
||||
assert_success ./gradlew "$project:publishAllPublicationsToSonatypeRepository" --no-parallel --quiet
|
||||
echo "Complete publishing of $project"
|
||||
echo "Start uploading of $project"
|
||||
assert_success ./gradlew uploadSonatypePublication --quiet
|
||||
echo "Complete uploading of $project"
|
||||
done
|
||||
|
||||
@@ -330,6 +330,89 @@ public final class dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescriptionKt
|
||||
public static synthetic fun setMyShortDescription$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/micro_utils/language_codes/IetfLang;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/ConvertGiftToStarsKt {
|
||||
public static final fun convertGiftToStars-D7eidZo (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun convertGiftToStars-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/DeleteBusinessMessagesGeneratedVariationKt {
|
||||
public static final fun deleteBusinessMessages-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/DeleteBusinessMessagesKt {
|
||||
public static final fun deleteBusinessMessages-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/GetBusinessAccountGiftsKt {
|
||||
public static final fun getBusinessAccountGifts-LATcL_E (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ZZZZZZLjava/lang/String;Ljava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun getBusinessAccountGifts-LATcL_E$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ZZZZZZLjava/lang/String;Ljava/lang/Integer;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun getBusinessAccountGiftsFlow-LATcL_E (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ZZZZZZLjava/lang/String;Ljava/lang/Integer;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
|
||||
public static synthetic fun getBusinessAccountGiftsFlow-LATcL_E$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ZZZZZZLjava/lang/String;Ljava/lang/Integer;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/GetBusinessAccountStarBalanceKt {
|
||||
public static final fun getBusinessAccountStarBalance-spp27rg (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/ReadBusinessMessageGeneratedVariationKt {
|
||||
public static final fun readBusinessMessage-1MWLODE (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/Chat;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/ReadBusinessMessageKt {
|
||||
public static final fun readBusinessMessage-kYJnN-U (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JJLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun readBusinessMessage-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/RemoveBusinessAccountProfilePhotoKt {
|
||||
public static final fun removeBusinessAccountProfilePhoto-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun removeBusinessAccountProfilePhoto-wC12z2M$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountBioKt {
|
||||
public static final fun setBusinessAccountBio-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountGiftSettingsKt {
|
||||
public static final fun setBusinessAccountGiftSettings (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage;ZLdev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun setBusinessAccountGiftSettings-XzFA9qU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ZLdev/inmo/tgbotapi/types/gifts/AcceptedGiftTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountNameKt {
|
||||
public static final fun setBusinessAccountName-XzFA9qU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun setBusinessAccountName-XzFA9qU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountProfilePhotoKt {
|
||||
public static final fun setBusinessAccountProfilePhoto-XzFA9qU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/requests/business_connection/InputProfilePhoto;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun setBusinessAccountProfilePhoto-XzFA9qU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/requests/business_connection/InputProfilePhoto;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountUsernameGeneratedVariationKt {
|
||||
public static final fun setBusinessAccountUsername-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountUsernameKt {
|
||||
public static final fun setBusinessAccountUsername-_dB6Ko0 (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/TransferBusinessAccountStarBalanceKt {
|
||||
public static final fun transferBusinessAccountStars-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/TransferGiftKt {
|
||||
public static final fun transferGift-cB4Rf94 (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;JLjava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun transferGift-cB4Rf94$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;JLjava/lang/Integer;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun transferGift-gMFmPss (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;JLjava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun transferGift-gMFmPss$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;JLjava/lang/Integer;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/business/UpgradeGiftKt {
|
||||
public static final fun convertGiftToStars-XzFA9qU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun convertGiftToStars-XzFA9qU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun convertGiftToStars-fJJ4zuA (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun convertGiftToStars-fJJ4zuA$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/Integer;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/chat/ExportChatInviteLinkKt {
|
||||
public static final fun exportChatInviteLink (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun exportChatInviteLink (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
@@ -1088,13 +1171,22 @@ public final class dev/inmo/tgbotapi/extensions/api/gifts/GetAvailableGiftsKt {
|
||||
public static final fun getAvailableGifts (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/gifts/GiftPremiumSubscriptionKt {
|
||||
public static final fun giftPremiumSubscription-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JIILdev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun giftPremiumSubscription-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JIILjava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun giftPremiumSubscription-VjR9mJc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JIILdev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static synthetic fun giftPremiumSubscription-VjR9mJc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JIILjava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun giftPremiumSubscription-ySMgKnk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JIILjava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun giftPremiumSubscription-ySMgKnk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JIILjava/util/List;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftGeneratedVariationKt {
|
||||
public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift-0SDnvgk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift-ySMgKnk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGift-ySMgKnk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftKt {
|
||||
@@ -1109,10 +1201,10 @@ public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftKt {
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftToChatGeneratedVariationKt {
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat-0SDnvgk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun sendGiftToChat-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
@@ -2307,6 +2399,35 @@ public final class dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFileKt
|
||||
public static final fun uploadStickerFile-4iNBclM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/requests/abstracts/MultipartFile;Ldev/inmo/tgbotapi/types/StickerFormat;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/stories/DeleteStoryKt {
|
||||
public static final fun deleteStory (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage;Ldev/inmo/tgbotapi/types/stories/Story;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun deleteStory-8HGAsC4 (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun deleteStory-CF6AVbg (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun deleteStory-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/Story;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/stories/EditStoryKt {
|
||||
public static final fun editStory--jptdio (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/util/List;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun editStory--jptdio$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/util/List;Ljava/util/List;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun editStory-51PWt9w (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun editStory-51PWt9w (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/util/List;Ldev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun editStory-51PWt9w$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static synthetic fun editStory-51PWt9w$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/util/List;Ldev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun editStory-RIEWIQk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun editStory-RIEWIQk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JLdev/inmo/tgbotapi/types/stories/InputStoryContent;Ljava/util/List;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/stories/PostStoryKt {
|
||||
public static final fun postStory-5wJhEVU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/util/List;ZZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun postStory-5wJhEVU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/util/List;ZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun postStory-TVoEmL0 (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/util/List;Ljava/util/List;ZZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun postStory-TVoEmL0$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/util/List;Ljava/util/List;ZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun postStory-rseRIdU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ZZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun postStory-rseRIdU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/util/List;ZZLdev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun postStory-rseRIdU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static synthetic fun postStory-rseRIdU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/stories/InputStoryContent;ILjava/util/List;ZZLdev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/extensions/api/thumbs/SetCustomEmojiStickerSetThumbKt {
|
||||
public static final fun setCustomEmojiStickerSetThumbnail-FMh0B1w (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/stickers/StickerSet;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun setCustomEmojiStickerSetThumbnail-KofBPHw (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.ConvertGiftToStars
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.GiftId
|
||||
import dev.inmo.tgbotapi.types.gifts.Gift
|
||||
|
||||
public suspend fun TelegramBot.convertGiftToStars(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
ownedGiftId: GiftId
|
||||
): Boolean = execute(
|
||||
ConvertGiftToStars(businessConnectionId, ownedGiftId)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.convertGiftToStars(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
gift: Gift.Regular
|
||||
): Boolean = convertGiftToStars(
|
||||
businessConnectionId = businessConnectionId,
|
||||
ownedGiftId = with(gift) {id}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.DeleteBusinessMessages
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
|
||||
@GenerateVariations
|
||||
public suspend fun TelegramBot.deleteBusinessMessages(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
@GenerationVariant(List::class, "messages.map { it.messageId }", "messages", AccessibleMessage::class)
|
||||
messageIds: List<MessageId>
|
||||
): Boolean = execute(
|
||||
DeleteBusinessMessages(businessConnectionId, messageIds)
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||
// TO REGENERATE IT JUST DELETE FILE
|
||||
// ORIGINAL FILE: DeleteBusinessMessages.kt
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import kotlin.Boolean
|
||||
import kotlin.collections.List
|
||||
|
||||
public suspend fun TelegramBot.deleteBusinessMessages(businessConnectionId: BusinessConnectionId,
|
||||
messages: List<AccessibleMessage>): Boolean = deleteBusinessMessages(
|
||||
businessConnectionId = businessConnectionId, messageIds = with(messages) {messages.map {
|
||||
it.messageId }}
|
||||
)
|
||||
@@ -0,0 +1,94 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.GetBusinessAccountGifts
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.OwnedGifts
|
||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlin.runCatching
|
||||
|
||||
public suspend fun TelegramBot.getBusinessAccountGifts(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
excludeUnsaved: Boolean = false,
|
||||
excludeSaved: Boolean = false,
|
||||
excludeUnlimited: Boolean = false,
|
||||
excludeLimited: Boolean = false,
|
||||
excludeUnique: Boolean = false,
|
||||
sortByPrice: Boolean = false,
|
||||
offset: String? = null,
|
||||
limit: Int? = null
|
||||
): OwnedGifts<GiftSentOrReceived.ReceivedInBusinessAccount> = execute(
|
||||
GetBusinessAccountGifts(
|
||||
businessConnectionId,
|
||||
excludeUnsaved,
|
||||
excludeSaved,
|
||||
excludeUnlimited,
|
||||
excludeLimited,
|
||||
excludeUnique,
|
||||
sortByPrice,
|
||||
offset,
|
||||
limit
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Creates a flow that emits business account gifts in a paginated manner.
|
||||
*
|
||||
* This function will automatically handle pagination by using the `nextOffset` from each response
|
||||
* to fetch the next page of gifts until there are no more gifts to fetch.
|
||||
*
|
||||
* @param businessConnectionId The ID of the business connection
|
||||
* @param excludeUnsaved Whether to exclude unsaved gifts
|
||||
* @param excludeSaved Whether to exclude saved gifts
|
||||
* @param excludeUnlimited Whether to exclude unlimited gifts
|
||||
* @param excludeLimited Whether to exclude limited gifts
|
||||
* @param excludeUnique Whether to exclude unique gifts
|
||||
* @param sortByPrice Whether to sort gifts by price
|
||||
* @param initialOffset The initial offset to start fetching from. If null, starts from the beginning
|
||||
* @param limit The maximum number of gifts to fetch per request
|
||||
* @param onErrorContinueChecker A function that determines whether to continue fetching on error.
|
||||
* Returns true to continue, false to stop. Default is to stop on any error.
|
||||
* @return A flow that emits [OwnedGifts] containing the fetched gifts
|
||||
*/
|
||||
public fun TelegramBot.getBusinessAccountGiftsFlow(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
excludeUnsaved: Boolean = false,
|
||||
excludeSaved: Boolean = false,
|
||||
excludeUnlimited: Boolean = false,
|
||||
excludeLimited: Boolean = false,
|
||||
excludeUnique: Boolean = false,
|
||||
sortByPrice: Boolean = false,
|
||||
initialOffset: String? = null,
|
||||
limit: Int? = null,
|
||||
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
|
||||
): Flow<OwnedGifts<GiftSentOrReceived.ReceivedInBusinessAccount>> = flow {
|
||||
var currentOffset = initialOffset
|
||||
do {
|
||||
val response = runCatching {
|
||||
getBusinessAccountGifts(
|
||||
businessConnectionId,
|
||||
excludeUnsaved,
|
||||
excludeSaved,
|
||||
excludeUnlimited,
|
||||
excludeLimited,
|
||||
excludeUnique,
|
||||
sortByPrice,
|
||||
currentOffset,
|
||||
limit
|
||||
)
|
||||
}
|
||||
if (response.isSuccess) {
|
||||
val result = response.getOrThrow()
|
||||
emit(result)
|
||||
currentOffset = result.nextOffset
|
||||
} else {
|
||||
if (onErrorContinueChecker(response.exceptionOrNull())) {
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
} while (currentOffset != null)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.GetBusinessAccountStarBalance
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.payments.stars.StarAmount
|
||||
|
||||
public suspend fun TelegramBot.getBusinessAccountStarBalance(
|
||||
businessConnectionId: BusinessConnectionId
|
||||
): StarAmount = execute(
|
||||
GetBusinessAccountStarBalance(businessConnectionId)
|
||||
)
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.ReadBusinessMessage
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.toChatId
|
||||
|
||||
@GenerateVariations
|
||||
public suspend fun TelegramBot.readBusinessMessage(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
@GenerationVariant(Chat::class, "chat.id.toChatId()", "chat")
|
||||
chatId: ChatId,
|
||||
messageId: MessageId
|
||||
): Boolean = execute(
|
||||
ReadBusinessMessage(businessConnectionId, chatId, messageId)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.readBusinessMessage(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
message: AccessibleMessage
|
||||
): Boolean = readBusinessMessage(businessConnectionId, message.chat.id.toChatId(), message.messageId)
|
||||
@@ -0,0 +1,20 @@
|
||||
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||
// TO REGENERATE IT JUST DELETE FILE
|
||||
// ORIGINAL FILE: ReadBusinessMessage.kt
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.toChatId
|
||||
import kotlin.Boolean
|
||||
|
||||
public suspend fun TelegramBot.readBusinessMessage(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
): Boolean = readBusinessMessage(
|
||||
businessConnectionId = businessConnectionId, chatId = with(chat) {chat.id.toChatId()}, messageId
|
||||
= messageId
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.RemoveBusinessAccountProfilePhoto
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
|
||||
public suspend fun TelegramBot.removeBusinessAccountProfilePhoto(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
isPublic: Boolean = false
|
||||
): Boolean = execute(
|
||||
RemoveBusinessAccountProfilePhoto(businessConnectionId = businessConnectionId, isPublic = isPublic)
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountBio
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
|
||||
public suspend fun TelegramBot.setBusinessAccountBio(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
bio: String
|
||||
): Boolean = execute(
|
||||
SetBusinessAccountBio(businessConnectionId, bio)
|
||||
)
|
||||
@@ -0,0 +1,35 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountGiftSettings
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.BusinessContentMessage
|
||||
|
||||
/**
|
||||
* Sets the gift settings for a business account
|
||||
*/
|
||||
public suspend fun TelegramBot.setBusinessAccountGiftSettings(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
showGiftButton: Boolean,
|
||||
acceptedGiftTypes: AcceptedGiftTypes
|
||||
): Boolean = execute(
|
||||
SetBusinessAccountGiftSettings(
|
||||
businessConnectionId = businessConnectionId,
|
||||
showGiftButton = showGiftButton,
|
||||
acceptedGiftTypes = acceptedGiftTypes
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Sets the gift settings for a business account using business message context
|
||||
*/
|
||||
public suspend fun TelegramBot.setBusinessAccountGiftSettings(
|
||||
message: BusinessContentMessage<*>,
|
||||
showGiftButton: Boolean,
|
||||
acceptedGiftTypes: AcceptedGiftTypes
|
||||
): Boolean = setBusinessAccountGiftSettings(
|
||||
businessConnectionId = message.businessConnectionId,
|
||||
showGiftButton = showGiftButton,
|
||||
acceptedGiftTypes = acceptedGiftTypes
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountName
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
|
||||
public suspend fun TelegramBot.setBusinessAccountName(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
firstName: String,
|
||||
lastName: String? = null
|
||||
): Boolean = execute(
|
||||
SetBusinessAccountName(businessConnectionId, firstName, lastName)
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.InputProfilePhoto
|
||||
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountProfilePhoto
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
|
||||
public suspend fun TelegramBot.setBusinessAccountProfilePhoto(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
photo: InputProfilePhoto,
|
||||
isPublic: Boolean = false
|
||||
): Boolean = execute(
|
||||
SetBusinessAccountProfilePhoto(businessConnectionId, photo, isPublic)
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountUsername
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
|
||||
@GenerateVariations
|
||||
public suspend fun TelegramBot.setBusinessAccountUsername(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
@GenerationVariant(String::class, "Username(username)", "username")
|
||||
username: Username
|
||||
): Boolean = execute(
|
||||
SetBusinessAccountUsername(businessConnectionId, username)
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||
// TO REGENERATE IT JUST DELETE FILE
|
||||
// ORIGINAL FILE: SetBusinessAccountUsername.kt
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import kotlin.Boolean
|
||||
import kotlin.String
|
||||
|
||||
public suspend
|
||||
fun TelegramBot.setBusinessAccountUsername(businessConnectionId: BusinessConnectionId,
|
||||
username: String): Boolean = setBusinessAccountUsername(
|
||||
businessConnectionId = businessConnectionId, username = with(username) { Username.prepare(username) }
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.TransferBusinessAccountStars
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
|
||||
public suspend fun TelegramBot.transferBusinessAccountStars(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
amount: Int
|
||||
): Boolean = execute(
|
||||
TransferBusinessAccountStars(businessConnectionId, amount)
|
||||
)
|
||||
@@ -0,0 +1,43 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.ConvertGiftToStars
|
||||
import dev.inmo.tgbotapi.requests.business_connection.TransferGift
|
||||
import dev.inmo.tgbotapi.requests.business_connection.UpgradeGift
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.GiftId
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.gifts.Gift
|
||||
import dev.inmo.tgbotapi.types.keepOriginalDetailsField
|
||||
import dev.inmo.tgbotapi.types.ownedGiftIdField
|
||||
import dev.inmo.tgbotapi.types.starCountField
|
||||
import kotlinx.serialization.SerialName
|
||||
|
||||
public suspend fun TelegramBot.transferGift(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
ownedGiftId: GiftId,
|
||||
newOwnerChatId: ChatId,
|
||||
transferPaymentStarCount: Int? = null,
|
||||
): Boolean = execute(
|
||||
TransferGift(
|
||||
businessConnectionId = businessConnectionId,
|
||||
ownedGiftId = ownedGiftId,
|
||||
newOwnerChatId = newOwnerChatId,
|
||||
transferPaymentStarCount = transferPaymentStarCount
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.transferGift(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
gift: Gift.Regular,
|
||||
newOwnerChatId: ChatId,
|
||||
transferPaymentStarCount: Int? = null,
|
||||
): Boolean = transferGift(
|
||||
businessConnectionId = businessConnectionId,
|
||||
ownedGiftId = gift.id,
|
||||
newOwnerChatId = newOwnerChatId,
|
||||
transferPaymentStarCount = transferPaymentStarCount
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.business
|
||||
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
|
||||
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.business_connection.ConvertGiftToStars
|
||||
import dev.inmo.tgbotapi.requests.business_connection.UpgradeGift
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.GiftId
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.gifts.Gift
|
||||
import dev.inmo.tgbotapi.types.keepOriginalDetailsField
|
||||
import dev.inmo.tgbotapi.types.ownedGiftIdField
|
||||
import dev.inmo.tgbotapi.types.starCountField
|
||||
import kotlinx.serialization.SerialName
|
||||
|
||||
public suspend fun TelegramBot.convertGiftToStars(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
ownedGiftId: GiftId,
|
||||
keepOriginalDetails: Boolean = false,
|
||||
starCount: Int? = null
|
||||
): Boolean = execute(
|
||||
UpgradeGift(
|
||||
businessConnectionId = businessConnectionId,
|
||||
ownedGiftId = ownedGiftId,
|
||||
keepOriginalDetails = keepOriginalDetails,
|
||||
starCount = starCount
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.convertGiftToStars(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
gift: Gift.Regular,
|
||||
keepOriginalDetails: Boolean = false,
|
||||
): Boolean = execute(
|
||||
UpgradeGift(
|
||||
businessConnectionId = businessConnectionId,
|
||||
ownedGiftId = gift.id,
|
||||
keepOriginalDetails = keepOriginalDetails,
|
||||
starCount = gift.upgradeStarCount
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,55 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.gifts
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.gifts.GiftPremiumSubscription
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
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
|
||||
|
||||
public suspend fun TelegramBot.giftPremiumSubscription(
|
||||
userId: UserId,
|
||||
monthCount: Int,
|
||||
starCount: Int,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null
|
||||
): Boolean = execute(
|
||||
GiftPremiumSubscription(
|
||||
userId = userId,
|
||||
monthCount = monthCount,
|
||||
starCount = starCount,
|
||||
text = text,
|
||||
parseMode = parseMode
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.giftPremiumSubscription(
|
||||
userId: UserId,
|
||||
monthCount: Int,
|
||||
starCount: Int,
|
||||
textSources: TextSourcesList? = null,
|
||||
): Boolean = execute(
|
||||
GiftPremiumSubscription(
|
||||
userId = userId,
|
||||
monthCount = monthCount,
|
||||
starCount = starCount,
|
||||
textSources = textSources
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.giftPremiumSubscription(
|
||||
userId: UserId,
|
||||
monthCount: Int,
|
||||
starCount: Int,
|
||||
separator: TextSource? = null,
|
||||
textBuilder: EntitiesBuilderBody
|
||||
): Boolean = execute(
|
||||
GiftPremiumSubscription(
|
||||
userId = userId,
|
||||
monthCount = monthCount,
|
||||
starCount = starCount,
|
||||
textSources = buildEntities(separator, textBuilder),
|
||||
)
|
||||
)
|
||||
@@ -22,7 +22,7 @@ public suspend fun TelegramBot.sendGift(
|
||||
)
|
||||
userId: UserId,
|
||||
@GenerationVariant(
|
||||
Gift::class,
|
||||
Gift.Regular::class,
|
||||
"id",
|
||||
"gift"
|
||||
)
|
||||
@@ -49,7 +49,7 @@ public suspend fun TelegramBot.sendGiftToChat(
|
||||
)
|
||||
chatId: ChatIdentifier,
|
||||
@GenerationVariant(
|
||||
Gift::class,
|
||||
Gift.Regular::class,
|
||||
"id",
|
||||
"gift"
|
||||
)
|
||||
@@ -76,7 +76,7 @@ public suspend fun TelegramBot.sendGift(
|
||||
)
|
||||
userId: UserId,
|
||||
@GenerationVariant(
|
||||
Gift::class,
|
||||
Gift.Regular::class,
|
||||
"id",
|
||||
"gift"
|
||||
)
|
||||
@@ -101,7 +101,7 @@ public suspend fun TelegramBot.sendGiftToChat(
|
||||
)
|
||||
chatId: ChatIdentifier,
|
||||
@GenerationVariant(
|
||||
Gift::class,
|
||||
Gift.Regular::class,
|
||||
"id",
|
||||
"gift"
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ public suspend fun TelegramBot.sendGift(
|
||||
|
||||
public suspend fun TelegramBot.sendGift(
|
||||
userId: UserId,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
): Boolean = sendGift(
|
||||
@@ -43,7 +43,7 @@ public suspend fun TelegramBot.sendGift(
|
||||
|
||||
public suspend fun TelegramBot.sendGift(
|
||||
userId: UserId,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
upgradableToUnique: Boolean,
|
||||
@@ -54,7 +54,7 @@ public suspend fun TelegramBot.sendGift(
|
||||
|
||||
public suspend fun TelegramBot.sendGift(
|
||||
user: User,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
): Boolean = sendGift(
|
||||
@@ -63,7 +63,7 @@ public suspend fun TelegramBot.sendGift(
|
||||
|
||||
public suspend fun TelegramBot.sendGift(
|
||||
user: User,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
upgradableToUnique: Boolean,
|
||||
|
||||
@@ -34,7 +34,7 @@ public suspend fun TelegramBot.sendGiftToChat(
|
||||
|
||||
public suspend fun TelegramBot.sendGiftToChat(
|
||||
chatId: ChatIdentifier,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
): Boolean = sendGiftToChat(
|
||||
@@ -43,7 +43,7 @@ public suspend fun TelegramBot.sendGiftToChat(
|
||||
|
||||
public suspend fun TelegramBot.sendGiftToChat(
|
||||
chatId: ChatIdentifier,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
upgradableToUnique: Boolean,
|
||||
@@ -54,7 +54,7 @@ public suspend fun TelegramBot.sendGiftToChat(
|
||||
|
||||
public suspend fun TelegramBot.sendGiftToChat(
|
||||
chat: PublicChat,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
): Boolean = sendGiftToChat(
|
||||
@@ -63,7 +63,7 @@ public suspend fun TelegramBot.sendGiftToChat(
|
||||
|
||||
public suspend fun TelegramBot.sendGiftToChat(
|
||||
chat: PublicChat,
|
||||
gift: Gift,
|
||||
gift: Gift.Regular,
|
||||
text: String,
|
||||
parseMode: ParseMode?,
|
||||
upgradableToUnique: Boolean,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stories
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.stories.DeleteStory
|
||||
import dev.inmo.tgbotapi.types.StoryId
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.BusinessContentMessage
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
|
||||
/**
|
||||
* Deletes a story from a business account
|
||||
*/
|
||||
public suspend fun TelegramBot.deleteStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId
|
||||
): Boolean = execute(
|
||||
DeleteStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.deleteStory(
|
||||
message: BusinessContentMessage<*>,
|
||||
storyId: StoryId
|
||||
): Boolean = deleteStory(
|
||||
businessConnectionId = with(message) {message.businessConnectionId}, storyId = storyId
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.deleteStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
story: Story
|
||||
): Boolean = deleteStory(
|
||||
businessConnectionId = businessConnectionId, storyId = with(story) {story.id}
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.deleteStory(
|
||||
message: BusinessContentMessage<*>,
|
||||
story: Story
|
||||
): Boolean = deleteStory(
|
||||
message = message, storyId = with(story) {story.id}
|
||||
)
|
||||
@@ -0,0 +1,79 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stories
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.stories.EditStory
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.StoryId
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.stories.InputStoryContent
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import dev.inmo.tgbotapi.types.stories.StoryArea
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||
import dev.inmo.tgbotapi.utils.buildEntities
|
||||
|
||||
public suspend fun TelegramBot.editStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId,
|
||||
content: InputStoryContent,
|
||||
textSources: List<TextSource>,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
): Story = execute(
|
||||
EditStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId,
|
||||
content = content,
|
||||
textSources = textSources,
|
||||
areas = areas,
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.editStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId,
|
||||
content: InputStoryContent,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
separator: TextSource? = null,
|
||||
textBuilder: EntitiesBuilderBody
|
||||
): Story = execute(
|
||||
EditStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId,
|
||||
content = content,
|
||||
textSources = buildEntities(separator, textBuilder),
|
||||
areas = areas,
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.editStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId,
|
||||
content: InputStoryContent,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
): Story = execute(
|
||||
EditStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId,
|
||||
content = content,
|
||||
text = text,
|
||||
parseMode = parseMode,
|
||||
areas = areas,
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.editStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId,
|
||||
content: InputStoryContent,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
): Story = execute(
|
||||
EditStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId,
|
||||
content = content,
|
||||
areas = areas,
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,94 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stories
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.stories.PostStory
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.stories.InputStoryContent
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import dev.inmo.tgbotapi.types.stories.StoryArea
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||
import dev.inmo.tgbotapi.utils.buildEntities
|
||||
|
||||
public suspend fun TelegramBot.postStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
content: InputStoryContent,
|
||||
activePeriod: Seconds,
|
||||
textSources: List<TextSource>,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
postToChatPage: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
): Story = execute(
|
||||
PostStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
content = content,
|
||||
activePeriod = activePeriod,
|
||||
textSources = textSources,
|
||||
areas = areas,
|
||||
postToChatPage = postToChatPage,
|
||||
protectContent = protectContent
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.postStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
content: InputStoryContent,
|
||||
activePeriod: Seconds,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
postToChatPage: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
separator: TextSource? = null,
|
||||
textBuilder: EntitiesBuilderBody
|
||||
): Story = execute(
|
||||
PostStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
content = content,
|
||||
activePeriod = activePeriod,
|
||||
textSources = buildEntities(separator, textBuilder),
|
||||
areas = areas,
|
||||
postToChatPage = postToChatPage,
|
||||
protectContent = protectContent
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.postStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
content: InputStoryContent,
|
||||
activePeriod: Seconds,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
postToChatPage: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
): Story = execute(
|
||||
PostStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
content = content,
|
||||
activePeriod = activePeriod,
|
||||
text = text,
|
||||
parseMode = parseMode,
|
||||
areas = areas,
|
||||
postToChatPage = postToChatPage,
|
||||
protectContent = protectContent
|
||||
)
|
||||
)
|
||||
|
||||
public suspend fun TelegramBot.postStory(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
content: InputStoryContent,
|
||||
activePeriod: Seconds,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
postToChatPage: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
): Story = execute(
|
||||
PostStory(
|
||||
businessConnectionId = businessConnectionId,
|
||||
content = content,
|
||||
activePeriod = activePeriod,
|
||||
areas = areas,
|
||||
postToChatPage = postToChatPage,
|
||||
protectContent = protectContent
|
||||
)
|
||||
)
|
||||
@@ -144,10 +144,12 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
state.context
|
||||
).apply {
|
||||
stateInitialAction(state)
|
||||
}.launchStateHandling(
|
||||
state,
|
||||
actualHandlersList
|
||||
)
|
||||
}.run {
|
||||
launchStateHandling(
|
||||
state,
|
||||
actualHandlersList
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <I : T> add(kClass: KClass<I>, strict: Boolean, handler: BehaviourWithFSMStateHandler<I, T>) {
|
||||
@@ -188,7 +190,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
statesJobsMutex.withLock {
|
||||
runCatchingSafely { statesJobs.remove(it) ?.cancel() }
|
||||
}
|
||||
updatesFlows.remove(it.context)
|
||||
updatesFlows.remove(it.context) ?.cancel()
|
||||
}
|
||||
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) ->
|
||||
statesJobsMutex.withLock {
|
||||
@@ -197,7 +199,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
||||
statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(new) }
|
||||
}
|
||||
if (old.context != new.context) {
|
||||
updatesFlows.remove(old.context)
|
||||
updatesFlows.remove(old.context) ?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -654,6 +654,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
|
||||
public static synthetic fun waitNewChatPhotoEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitNewChatTitleEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitNewChatTitleEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitPaidMessagePriceChanged (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitPaidMessagePriceChanged$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitPinnedMessageEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitPinnedMessageEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitPrivateEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
@@ -664,12 +666,16 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
|
||||
public static synthetic fun waitPublicChatEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitRefundedPaymentEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitRefundedPaymentEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitRegularGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitRegularGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitSuccessfulPaymentEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitSuccessfulPaymentEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitSupergroupChatCreatedEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitSupergroupChatCreatedEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitSupergroupEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitSupergroupEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitUniqueGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitUniqueGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitUserLoggedInEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitUserLoggedInEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitUserShared (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
@@ -743,6 +749,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
|
||||
public static synthetic fun waitNewChatPhotoEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitNewChatTitleEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitNewChatTitleEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitPaidMessagePriceChangedMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitPaidMessagePriceChangedMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitPinnedMessageEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitPinnedMessageEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitPrivateEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
@@ -753,12 +761,16 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
|
||||
public static synthetic fun waitPublicChatEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitRefundedPaymentEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitRefundedPaymentEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitRegularGiftSentOrReceivedMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitRegularGiftSentOrReceivedMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitSuccessfulPaymentEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitSuccessfulPaymentEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitSupergroupChatCreatedEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitSupergroupChatCreatedEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitSupergroupEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitSupergroupEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitUniqueGiftSentOrReceivedMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitUniqueGiftSentOrReceivedMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitUserLoggedInEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun waitUserLoggedInEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun waitUserSharedEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
@@ -1348,6 +1360,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handl
|
||||
public static synthetic fun onNewChatPhoto$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onNewChatTitle (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onNewChatTitle$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onPaidMessagePriceChanged (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onPaidMessagePriceChanged$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onPinnedMessage (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onPinnedMessage$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onPrivateEvent (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
@@ -1358,12 +1372,16 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handl
|
||||
public static synthetic fun onPublicChatEvent$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onRefundedPayment (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onRefundedPayment$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onRegularGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onRegularGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onSuccessfulPayment (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onSuccessfulPayment$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onSupergroupChatCreated (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onSupergroupChatCreated$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onSupergroupEvent (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onSupergroupEvent$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onUniqueGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onUniqueGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onUserLoggedIn (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun onUserLoggedIn$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun onUserShared (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
|
||||
@@ -5,10 +5,11 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.PaidMessagePriceChanged
|
||||
import dev.inmo.tgbotapi.types.chat.ChatBackground
|
||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
|
||||
@@ -248,3 +249,18 @@ suspend fun BehaviourContext.waitGiveawayCompletedWithPrivateWinners(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitGiveawayCompleted(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitPaidMessagePriceChanged(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<PaidMessagePriceChanged>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitRegularGiftSentOrReceived(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<GiftSentOrReceived.Regular>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitUniqueGiftSentOrReceived(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<GiftSentOrReceived.Unique>(initRequest, errorFactory)
|
||||
|
||||
@@ -5,7 +5,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.PaidMessagePriceChanged
|
||||
import dev.inmo.tgbotapi.types.chat.ChatBackground
|
||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
|
||||
@@ -224,3 +226,18 @@ suspend fun BehaviourContext.waitChatBackgroundSetEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatBackground>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitPaidMessagePriceChangedMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<PaidMessagePriceChanged>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitRegularGiftSentOrReceivedMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<GiftSentOrReceived.Regular>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitUniqueGiftSentOrReceivedMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<GiftSentOrReceived.Unique>(initRequest, errorFactory)
|
||||
|
||||
@@ -10,10 +10,11 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.Mar
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
||||
import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatEventMessageOrNull
|
||||
import dev.inmo.tgbotapi.types.PaidMessagePriceChanged
|
||||
import dev.inmo.tgbotapi.types.chat.ChatBackground
|
||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
|
||||
@@ -1045,3 +1046,69 @@ suspend fun <BC : BehaviourContext> BC.onGiveawayCompletedWithPrivateWinners(
|
||||
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<GiveawayPrivateResults>>? = null,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<GiveawayPrivateResults>>
|
||||
) = onGiveawayCompleted(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
|
||||
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
|
||||
* "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onPaidMessagePriceChanged(
|
||||
initialFilter: SimpleFilter<ChatEventMessage<PaidMessagePriceChanged>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<PaidMessagePriceChanged>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<PaidMessagePriceChanged>, Any>? = ByChatMessageMarkerFactory,
|
||||
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<PaidMessagePriceChanged>>? = null,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<PaidMessagePriceChanged>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
|
||||
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
|
||||
* "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onRegularGiftSentOrReceived(
|
||||
initialFilter: SimpleFilter<ChatEventMessage<GiftSentOrReceived.Regular>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<GiftSentOrReceived.Regular>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<GiftSentOrReceived.Regular>, Any>? = ByChatMessageMarkerFactory,
|
||||
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<GiftSentOrReceived.Regular>>? = null,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<GiftSentOrReceived.Regular>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
|
||||
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
|
||||
* "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onUniqueGiftSentOrReceived(
|
||||
initialFilter: SimpleFilter<ChatEventMessage<GiftSentOrReceived.Unique>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<GiftSentOrReceived.Unique>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<GiftSentOrReceived.Unique>, Any>? = ByChatMessageMarkerFactory,
|
||||
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<GiftSentOrReceived.Unique>>? = null,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<GiftSentOrReceived.Unique>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.SpecialMutableStateFlow
|
||||
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.flatMap
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
|
||||
internal suspend fun <BC : BehaviourContext, T> BC.on(
|
||||
markerFactory: MarkerFactory<in T, Any>?,
|
||||
@@ -40,11 +47,21 @@ internal suspend fun <BC : BehaviourContext, T> BC.on(
|
||||
}
|
||||
val handler: suspend (Pair<Update, T>) -> Unit = subcontextUpdatesFilter ?.let {
|
||||
{ (update, triggerData) ->
|
||||
createSubContextAndDoSynchronouslyWithUpdatesFilter {
|
||||
if (subcontextUpdatesFilter(this, triggerData, update)) {
|
||||
localSubcontextInitialAction(update, triggerData)
|
||||
scenarioReceiver(triggerData)
|
||||
val contextStateFlow = SpecialMutableStateFlow<BC?>(null)
|
||||
createSubContextAndDoSynchronouslyWithUpdatesFilter(
|
||||
updatesUpstreamFlow = contextStateFlow.flatMapLatest { context ->
|
||||
if (context == null) {
|
||||
emptyFlow()
|
||||
} else {
|
||||
allUpdatesFlow.filter {
|
||||
context.subcontextUpdatesFilter(triggerData, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
contextStateFlow.value = this
|
||||
localSubcontextInitialAction(update, triggerData)
|
||||
scenarioReceiver(triggerData)
|
||||
}
|
||||
}
|
||||
} ?: { (update, triggerData) ->
|
||||
@@ -57,8 +74,8 @@ internal suspend fun <BC : BehaviourContext, T> BC.on(
|
||||
{ markerFactory(it.second) },
|
||||
block = handler
|
||||
)
|
||||
} ?: subscribeSafelyWithoutExceptions(scope) {
|
||||
scope.launchSafelyWithoutExceptions {
|
||||
} ?: subscribeLoggingDropExceptions(scope) {
|
||||
scope.launchLoggingDropExceptions {
|
||||
handler(it)
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,6 @@ dependencies {
|
||||
|
||||
ksp {
|
||||
arg("cctargetPackage", "dev.inmo.tgbotapi.extensions.utils")
|
||||
arg("ccoutputFileName", "ClassCastsNew")
|
||||
arg("ccoutputFolder", project(":tgbotapi.utils").file("src/commonMain/kotlin").absolutePath)
|
||||
arg("ccoutputFileName", "ClassCastsNew.kt")
|
||||
arg("ccoutputFolder", project(":tgbotapi.utils").file("src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils").absolutePath)
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import kotlinx.serialization.json.Json
|
||||
|
||||
@RiskFeature
|
||||
fun createTelegramBotDefaultKtorCallRequestsFactories(logger: KSLog? = null) = listOf(
|
||||
SimpleRequestCallFactory(logger),
|
||||
MultipartRequestCallFactory(logger),
|
||||
SimpleRequestCallFactory(logger),
|
||||
DownloadFileRequestCallFactory,
|
||||
DownloadFileChannelRequestCallFactory
|
||||
)
|
||||
|
||||
@@ -9,8 +9,27 @@ import io.ktor.client.HttpClient
|
||||
import io.ktor.client.request.forms.*
|
||||
import io.ktor.http.Headers
|
||||
import io.ktor.http.HttpHeaders
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
class MultipartRequestCallFactory(logger: KSLog? = null) : AbstractRequestCallFactory(logger ?: DefaultKTgBotAPIKSLog) {
|
||||
private val localSimpleRequestCallFactory = SimpleRequestCallFactory(logger)
|
||||
override suspend fun <T : Any> makeCall(
|
||||
client: HttpClient,
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
request: Request<T>,
|
||||
jsonFormatter: Json
|
||||
): T? {
|
||||
return when (request) {
|
||||
!is MultipartRequest -> null
|
||||
is MultipartRequest.Common -> if (request.mediaMap.isEmpty()) {
|
||||
localSimpleRequestCallFactory.makeCall(client, urlsKeeper, request.data, jsonFormatter)
|
||||
} else {
|
||||
super.makeCall(client, urlsKeeper, request, jsonFormatter)
|
||||
}
|
||||
else -> super.makeCall(client, urlsKeeper, request, jsonFormatter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : Any> prepareCallBody(
|
||||
client: HttpClient,
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithBusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
interface BusinessRequest<T: Any> : Request<T>, WithBusinessConnectionId {
|
||||
interface Simple<T : Any> : BusinessRequest<T>, SimpleRequest<T>
|
||||
interface Multipart<T : Any> : BusinessRequest<T>, MultipartRequest.Common<T>, SimpleRequest<T> {
|
||||
override val data: SimpleRequest<T>
|
||||
get() = this
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.GiftId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.bioField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.ownedGiftIdField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class ConvertGiftToStars(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(ownedGiftIdField)
|
||||
val ownedGiftId: GiftId
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "convertGiftToStars"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class DeleteBusinessMessages(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(messageIdsField)
|
||||
val messagesIds: List<MessageId>
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "deleteBusinessMessages"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.types.OwnedGifts
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.excludeUnsavedField
|
||||
import dev.inmo.tgbotapi.types.excludeSavedField
|
||||
import dev.inmo.tgbotapi.types.excludeUnlimitedField
|
||||
import dev.inmo.tgbotapi.types.excludeLimitedField
|
||||
import dev.inmo.tgbotapi.types.excludeUniqueField
|
||||
import dev.inmo.tgbotapi.types.sortByPriceField
|
||||
import dev.inmo.tgbotapi.types.offsetField
|
||||
import dev.inmo.tgbotapi.types.limitField
|
||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
@Serializable
|
||||
data class GetBusinessAccountGifts(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(excludeUnsavedField)
|
||||
val excludeUnsaved: Boolean = false,
|
||||
@SerialName(excludeSavedField)
|
||||
val excludeSaved: Boolean = false,
|
||||
@SerialName(excludeUnlimitedField)
|
||||
val excludeUnlimited: Boolean = false,
|
||||
@SerialName(excludeLimitedField)
|
||||
val excludeLimited: Boolean = false,
|
||||
@SerialName(excludeUniqueField)
|
||||
val excludeUnique: Boolean = false,
|
||||
@SerialName(sortByPriceField)
|
||||
val sortByPrice: Boolean = false,
|
||||
@SerialName(offsetField)
|
||||
val offset: String? = null,
|
||||
@SerialName(limitField)
|
||||
val limit: Int? = null,
|
||||
) : BusinessRequest.Simple<OwnedGifts<GiftSentOrReceived.ReceivedInBusinessAccount>> {
|
||||
override fun method(): String = "getBusinessAccountGifts"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<OwnedGifts<GiftSentOrReceived.ReceivedInBusinessAccount>>
|
||||
get() = Companion.resultSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
companion object {
|
||||
@Warning("This API can be changed without any warranties of backward compatibility")
|
||||
val resultSerializer = OwnedGifts.serializer(GiftSentOrReceived.ReceivedInBusinessAccount.serializer())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.bioField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.payments.stars.StarAmount
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class GetBusinessAccountStarBalance(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
) : BusinessRequest.Simple<StarAmount> {
|
||||
override fun method(): String = "getBusinessAccountStarBalance"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<StarAmount>
|
||||
get() = StarAmount.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.types.DoubleSeconds
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.StickerFormat
|
||||
import dev.inmo.tgbotapi.types.animationField
|
||||
import dev.inmo.tgbotapi.types.mainFrameTimestampField
|
||||
import dev.inmo.tgbotapi.types.photoField
|
||||
import dev.inmo.tgbotapi.utils.deserializeWithRaw
|
||||
import kotlinx.serialization.EncodeDefault
|
||||
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
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@Serializable(InputProfilePhoto.Companion::class)
|
||||
sealed interface InputProfilePhoto {
|
||||
val type: String
|
||||
val mediaPair: Pair<String, MultipartFile>
|
||||
@Serializable
|
||||
data class Static(
|
||||
@SerialName(photoField)
|
||||
val photo: MultipartFile
|
||||
) : InputProfilePhoto {
|
||||
override val mediaPair: Pair<String, MultipartFile>
|
||||
get() = photo.fileId to photo
|
||||
@EncodeDefault
|
||||
override val type: String = "static"
|
||||
}
|
||||
@Serializable
|
||||
data class Animated(
|
||||
@SerialName(animationField)
|
||||
val animation: MultipartFile,
|
||||
@SerialName(mainFrameTimestampField)
|
||||
val mainFrameTimestamp: DoubleSeconds? = null
|
||||
) : InputProfilePhoto {
|
||||
override val mediaPair: Pair<String, MultipartFile>
|
||||
get() = animation.fileId to animation
|
||||
@EncodeDefault
|
||||
override val type: String = "animated"
|
||||
}
|
||||
|
||||
companion object : KSerializer<InputProfilePhoto> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = JsonObject.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): InputProfilePhoto {
|
||||
error("Deserialization is not supported yet")
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: InputProfilePhoto) {
|
||||
when (value) {
|
||||
is Animated -> Animated.serializer().serialize(encoder, value)
|
||||
is Static -> Static.serializer().serialize(encoder, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class ReadBusinessMessage(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(chatIdField)
|
||||
val chatId: ChatId,
|
||||
@SerialName(messageIdField)
|
||||
val messageId: MessageId
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "readBusinessMessage"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.isPublicField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.photoField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class RemoveBusinessAccountProfilePhoto(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(isPublicField)
|
||||
val isPublic: Boolean = false
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "removeBusinessAccountProfilePhoto"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.bioField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetBusinessAccountBio(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(bioField)
|
||||
val bio: String
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "setBusinessAccountBio"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.acceptedGiftTypesField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.showGiftButtonField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetBusinessAccountGiftSettings(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(showGiftButtonField)
|
||||
val showGiftButton: Boolean,
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
val acceptedGiftTypes: AcceptedGiftTypes
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "setBusinessAccountGiftSettings"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetBusinessAccountName(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(firstNameField)
|
||||
val firstName: String,
|
||||
@SerialName(lastNameField)
|
||||
val lastName: String? = null
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "setBusinessAccountName"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.isPublicField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.photoField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetBusinessAccountProfilePhoto(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(photoField)
|
||||
val photo: InputProfilePhoto,
|
||||
@SerialName(isPublicField)
|
||||
val isPublic: Boolean = false
|
||||
) : BusinessRequest.Multipart<Boolean> {
|
||||
override fun method(): String = "setBusinessAccountProfilePhoto"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(
|
||||
photo.mediaPair
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetBusinessAccountUsername(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(usernameField)
|
||||
@Serializable(Username.Companion.WithoutAtSerializer::class)
|
||||
val username: Username
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "setBusinessAccountUsername"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.starCountField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class TransferBusinessAccountStars(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(starCountField)
|
||||
val starCount: Int
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "transferBusinessAccountStars"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.GiftId
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.newOwnerChatIdField
|
||||
import dev.inmo.tgbotapi.types.ownedGiftIdField
|
||||
import dev.inmo.tgbotapi.types.starCountField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class TransferGift(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(ownedGiftIdField)
|
||||
val ownedGiftId: GiftId,
|
||||
@SerialName(newOwnerChatIdField)
|
||||
val newOwnerChatId: ChatId,
|
||||
@SerialName(starCountField)
|
||||
val transferPaymentStarCount: Int? = null,
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "transferGift"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.GiftId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.bioField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.keepOriginalDetailsField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.ownedGiftIdField
|
||||
import dev.inmo.tgbotapi.types.starCountField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class UpgradeGift(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(ownedGiftIdField)
|
||||
val ownedGiftId: GiftId,
|
||||
@SerialName(keepOriginalDetailsField)
|
||||
val keepOriginalDetails: Boolean = false,
|
||||
@SerialName(starCountField)
|
||||
val starCount: Int? = null,
|
||||
) : BusinessRequest.Simple<Boolean> {
|
||||
override fun method(): String = "upgradeGift"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.edit.media
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
@@ -27,14 +29,21 @@ data class EditChatMessageMedia(
|
||||
override val businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage<MediaContent>, EditReplyMessage, EditMediaMessage {
|
||||
|
||||
init {
|
||||
if (media.file is MultipartFile) {
|
||||
throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)")
|
||||
}
|
||||
) : EditChatMessage<MediaContent>, EditReplyMessage, EditMediaMessage, MultipartRequest.Common<ContentMessage<MediaContent>> {
|
||||
override val data: SimpleRequest<ContentMessage<MediaContent>>
|
||||
get() = this
|
||||
override val mediaMap: Map<String, MultipartFile> by lazy {
|
||||
(media.file as? MultipartFile) ?.let {
|
||||
mapOf(it.fileId to it)
|
||||
} ?: emptyMap()
|
||||
}
|
||||
|
||||
// init {
|
||||
// if (media.file is MultipartFile) {
|
||||
// throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)")
|
||||
// }
|
||||
// }
|
||||
|
||||
override fun method(): String = editMessageMediaMethod
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
|
||||
get() = MediaContentMessageResultDeserializer
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package dev.inmo.tgbotapi.requests.gifts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.monthCountField
|
||||
import dev.inmo.tgbotapi.types.starCountField
|
||||
import dev.inmo.tgbotapi.types.textEntitiesField
|
||||
import dev.inmo.tgbotapi.types.textField
|
||||
import dev.inmo.tgbotapi.types.textParseModeField
|
||||
import dev.inmo.tgbotapi.types.userIdField
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeSourceString
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class GiftPremiumSubscription internal constructor(
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@SerialName(monthCountField)
|
||||
val monthCount: Int,
|
||||
@SerialName(starCountField)
|
||||
val starCount: Int,
|
||||
@SerialName(textField)
|
||||
override val text: String? = null,
|
||||
@SerialName(textParseModeField)
|
||||
override val parseMode: ParseMode? = null,
|
||||
@SerialName(textEntitiesField)
|
||||
private val rawEntities: RawMessageEntities? = null,
|
||||
) : SimpleRequest<Boolean>, TextedOutput {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities?.let {
|
||||
text?.let { _ ->
|
||||
it.asTextSources(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "giftPremiumSubscription"
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
|
||||
constructor(
|
||||
userId: UserId,
|
||||
monthCount: Int,
|
||||
starCount: Int,
|
||||
text: String,
|
||||
parseMode: ParseMode?
|
||||
) : this(
|
||||
userId = userId,
|
||||
monthCount = monthCount,
|
||||
starCount = starCount,
|
||||
text = text,
|
||||
parseMode = parseMode,
|
||||
rawEntities = null,
|
||||
)
|
||||
|
||||
constructor(
|
||||
userId: UserId,
|
||||
monthCount: Int,
|
||||
starCount: Int,
|
||||
textSources: TextSourcesList? = null
|
||||
) : this(
|
||||
userId = userId,
|
||||
monthCount = monthCount,
|
||||
starCount = starCount,
|
||||
text = textSources?.makeSourceString(),
|
||||
parseMode = null,
|
||||
rawEntities = textSources?.toRawMessageEntities()
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dev.inmo.tgbotapi.requests.stories
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithBusinessConnectionId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.StoryId
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.storyIdField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class DeleteStory(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(storyIdField)
|
||||
val storyId: StoryId,
|
||||
) : SimpleRequest<Boolean>, WithBusinessConnectionId {
|
||||
override fun method(): String = "deleteStory"
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package dev.inmo.tgbotapi.requests.stories
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stories.PostStory
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.StoryId
|
||||
import dev.inmo.tgbotapi.types.activePeriodField
|
||||
import dev.inmo.tgbotapi.types.areasField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.captionEntitiesField
|
||||
import dev.inmo.tgbotapi.types.captionField
|
||||
import dev.inmo.tgbotapi.types.contentField
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||
import dev.inmo.tgbotapi.types.message.parseModeField
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.postToChatPageField
|
||||
import dev.inmo.tgbotapi.types.protectContentField
|
||||
import dev.inmo.tgbotapi.types.stories.InputStoryContent
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import dev.inmo.tgbotapi.types.stories.StoryArea
|
||||
import dev.inmo.tgbotapi.types.storyIdField
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
@Serializable
|
||||
data class EditStory private constructor(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(storyIdField)
|
||||
val storyId: StoryId,
|
||||
@SerialName(contentField)
|
||||
val content: InputStoryContent,
|
||||
@SerialName(captionField)
|
||||
override val text: String? = null,
|
||||
@SerialName(parseModeField)
|
||||
override val parseMode: ParseMode? = null,
|
||||
@SerialName(captionEntitiesField)
|
||||
private val textEntities: List<RawMessageEntity>? = null,
|
||||
@SerialName(areasField)
|
||||
val areas: List<StoryArea> = emptyList(),
|
||||
) : BusinessRequest.Multipart<Story>, TextedOutput {
|
||||
override val textSources: List<TextSource>? by lazy {
|
||||
textEntities ?.asTextSources(text ?: return@lazy null)
|
||||
}
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Story>
|
||||
get() = Story.serializer()
|
||||
override val mediaMap: Map<String, MultipartFile>
|
||||
get() = mapOf(content.media)
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
constructor(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId,
|
||||
content: InputStoryContent,
|
||||
textSources: List<TextSource>,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
) : this(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId,
|
||||
content = content,
|
||||
text = textSources.makeString(),
|
||||
parseMode = null,
|
||||
textEntities = textSources.toRawMessageEntities(),
|
||||
areas = areas,
|
||||
)
|
||||
constructor(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId,
|
||||
content: InputStoryContent,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
) : this(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId,
|
||||
content = content,
|
||||
text = text,
|
||||
parseMode = parseMode,
|
||||
textEntities = null,
|
||||
areas = areas,
|
||||
)
|
||||
constructor(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
storyId: StoryId,
|
||||
content: InputStoryContent,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
) : this(
|
||||
businessConnectionId = businessConnectionId,
|
||||
storyId = storyId,
|
||||
content = content,
|
||||
text = null,
|
||||
parseMode = null,
|
||||
textEntities = null,
|
||||
areas = areas,
|
||||
)
|
||||
override fun method(): String = "editStory"
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package dev.inmo.tgbotapi.requests.stories
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.activePeriodField
|
||||
import dev.inmo.tgbotapi.types.areasField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.captionEntitiesField
|
||||
import dev.inmo.tgbotapi.types.captionField
|
||||
import dev.inmo.tgbotapi.types.contentField
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||
import dev.inmo.tgbotapi.types.message.parseModeField
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.postToChatPageField
|
||||
import dev.inmo.tgbotapi.types.protectContentField
|
||||
import dev.inmo.tgbotapi.types.stories.InputStoryContent
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import dev.inmo.tgbotapi.types.stories.StoryArea
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
@Serializable
|
||||
data class PostStory private constructor(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(contentField)
|
||||
val content: InputStoryContent,
|
||||
@SerialName(activePeriodField)
|
||||
val activePeriod: Seconds,
|
||||
@SerialName(captionField)
|
||||
override val text: String? = null,
|
||||
@SerialName(parseModeField)
|
||||
override val parseMode: ParseMode? = null,
|
||||
@SerialName(captionEntitiesField)
|
||||
private val textEntities: List<RawMessageEntity>? = null,
|
||||
@SerialName(areasField)
|
||||
val areas: List<StoryArea> = emptyList(),
|
||||
@SerialName(postToChatPageField)
|
||||
val postToChatPage: Boolean = false,
|
||||
@SerialName(protectContentField)
|
||||
val protectContent: Boolean = false,
|
||||
) : BusinessRequest.Multipart<Story>, TextedOutput {
|
||||
override val textSources: List<TextSource>? by lazy {
|
||||
textEntities ?.asTextSources(text ?: return@lazy null)
|
||||
}
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Story>
|
||||
get() = Story.serializer()
|
||||
override val mediaMap: Map<String, MultipartFile>
|
||||
get() = mapOf(content.media)
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
constructor(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
content: InputStoryContent,
|
||||
activePeriod: Seconds,
|
||||
textSources: List<TextSource>,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
postToChatPage: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
) : this(
|
||||
businessConnectionId = businessConnectionId,
|
||||
content = content,
|
||||
activePeriod = activePeriod,
|
||||
text = textSources.makeString(),
|
||||
parseMode = null,
|
||||
textEntities = textSources.toRawMessageEntities(),
|
||||
areas = areas,
|
||||
postToChatPage = postToChatPage,
|
||||
protectContent = protectContent
|
||||
)
|
||||
constructor(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
content: InputStoryContent,
|
||||
activePeriod: Seconds,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
postToChatPage: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
) : this(
|
||||
businessConnectionId = businessConnectionId,
|
||||
content = content,
|
||||
activePeriod = activePeriod,
|
||||
text = text,
|
||||
parseMode = parseMode,
|
||||
textEntities = null,
|
||||
areas = areas,
|
||||
postToChatPage = postToChatPage,
|
||||
protectContent = protectContent
|
||||
)
|
||||
constructor(
|
||||
businessConnectionId: BusinessConnectionId,
|
||||
content: InputStoryContent,
|
||||
activePeriod: Seconds,
|
||||
areas: List<StoryArea> = emptyList(),
|
||||
postToChatPage: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
) : this(
|
||||
businessConnectionId = businessConnectionId,
|
||||
content = content,
|
||||
activePeriod = activePeriod,
|
||||
text = null,
|
||||
parseMode = null,
|
||||
textEntities = null,
|
||||
areas = areas,
|
||||
postToChatPage = postToChatPage,
|
||||
protectContent = protectContent
|
||||
)
|
||||
|
||||
override fun method(): String = "postStory"
|
||||
|
||||
companion object {
|
||||
const val ACTIVE_PERIOD_6_HOURS: Seconds = 6 * 3600
|
||||
const val ACTIVE_PERIOD_12_HOURS: Seconds = 12 * 3600
|
||||
const val ACTIVE_PERIOD_24_HOURS: Seconds = 24 * 3600 // 86400
|
||||
const val ACTIVE_PERIOD_48_HOURS: Seconds = 48 * 3600 // 2 * 86400
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import korlibs.time.Date
|
||||
import korlibs.time.DateTime
|
||||
import korlibs.time.Year
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -11,9 +13,12 @@ data class Birthdate(
|
||||
@SerialName(monthField)
|
||||
val month: Int,
|
||||
@SerialName(yearField)
|
||||
val year: Int
|
||||
val year: Int? = null
|
||||
) {
|
||||
/**
|
||||
* Represents this birthday as korlibs [Date]. Will use this year in case if [year] has not been retrieved
|
||||
*/
|
||||
val date: Date by lazy {
|
||||
Date(year, month, day)
|
||||
Date(year ?: DateTime.now().year.year, month, day)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
@@ -106,13 +107,34 @@ fun Long.toChatId(): ChatId = ChatId(RawChatId(this))
|
||||
fun Int.toChatId(): IdChatIdentifier = RawChatId(toLong()).toChatId()
|
||||
fun Byte.toChatId(): IdChatIdentifier = RawChatId(toLong()).toChatId()
|
||||
|
||||
/**
|
||||
* A value class representing a username that always starts with the "@" symbol.
|
||||
*
|
||||
* This class is used to encapsulate the concept of a username, enforce its format,
|
||||
* and ensure consistency when dealing with usernames throughout the application.
|
||||
*
|
||||
* @property full The full username string, guaranteed to start with "@".
|
||||
* @throws IllegalArgumentException if the provided [full] value doesn't start with "@" during initialization.
|
||||
*/
|
||||
@Serializable(ChatIdentifierSerializer::class)
|
||||
@JvmInline
|
||||
value class Username(
|
||||
value class Username (
|
||||
val full: String
|
||||
) : ChatIdentifier {
|
||||
/**
|
||||
* Retrieves the full username as a string.
|
||||
*
|
||||
* This property provides the complete username, which is guaranteed to start with the "@" symbol.
|
||||
* It represents the raw value of the username, ensuring consistency and adherence to the required format.
|
||||
*/
|
||||
val username: String
|
||||
get() = full
|
||||
/**
|
||||
* A property that returns the username string without the leading "@" symbol.
|
||||
*
|
||||
* This property removes any consecutive "@" symbols at the beginning of the `full` property
|
||||
* and provides the rest of the username as a plain string.
|
||||
*/
|
||||
val withoutAt
|
||||
get() = full.dropWhile { it == '@' }
|
||||
|
||||
@@ -125,9 +147,29 @@ value class Username(
|
||||
override fun toString(): String {
|
||||
return full
|
||||
}
|
||||
|
||||
companion object {
|
||||
object WithoutAtSerializer : KSerializer<Username> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
override fun deserialize(decoder: Decoder): Username = Username.prepare(decoder.decodeString())
|
||||
override fun serialize(encoder: Encoder, value: Username) = encoder.encodeString(value.withoutAt)
|
||||
}
|
||||
/**
|
||||
* Prepares a valid instance of [Username] by ensuring the given string starts with "@".
|
||||
*
|
||||
* @param full The input string representing the username. If the string does not start with "@",
|
||||
* it will be prefixed with "@".
|
||||
* @return A [Username] instance constructed using the provided or modified input string.
|
||||
*/
|
||||
fun prepare(full: String): Username = if (full.startsWith("@")) {
|
||||
Username(full)
|
||||
} else {
|
||||
Username("@$full")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.toUsername(): Username = Username(this)
|
||||
fun String.toUsername(): Username = Username.prepare(this)
|
||||
|
||||
@RiskFeature
|
||||
object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
@@ -139,11 +181,7 @@ object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
return id.longOrNull ?.let {
|
||||
ChatId(RawChatId(it))
|
||||
} ?: id.content.let {
|
||||
if (!it.startsWith("@")) {
|
||||
Username("@$it")
|
||||
} else {
|
||||
Username(it)
|
||||
}
|
||||
Username.prepare(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,11 +222,7 @@ object FullChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
else -> null
|
||||
}
|
||||
} ?: id.content.let {
|
||||
if (!it.startsWith("@")) {
|
||||
Username("@$it")
|
||||
} else {
|
||||
Username(it)
|
||||
}
|
||||
Username.prepare(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.utils.BuiltinMimeTypes
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
|
||||
typealias ForwardSignature = String
|
||||
typealias ForwardSenderName = String
|
||||
typealias AuthorSignature = ForwardSignature
|
||||
@@ -19,6 +20,7 @@ typealias GooglePlaceType = String
|
||||
typealias MembersLimit = Int
|
||||
|
||||
typealias Seconds = Int
|
||||
typealias DoubleSeconds = Double
|
||||
typealias MilliSeconds = Long
|
||||
typealias LongSeconds = Long
|
||||
typealias UnixTimeStamp = LongSeconds
|
||||
@@ -54,6 +56,7 @@ val horizontalAccuracyLimit = 0F .. 1500F
|
||||
val getUpdatesLimit = 1 .. 100
|
||||
val callbackQueryAnswerLength = 0 until 200
|
||||
val captionLength = 0 .. 1024
|
||||
val storyCaptionLength = 0 .. 2048
|
||||
val textLength = 1 .. 4096
|
||||
val userProfilePhotosRequestLimit = 0 .. 100
|
||||
val chatTitleLength = 1 until 255
|
||||
@@ -186,6 +189,19 @@ const val hasMainWebAppField = "has_main_web_app"
|
||||
const val canJoinGroupsField = "can_join_groups"
|
||||
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
||||
const val canReplyField = "can_reply"
|
||||
const val canReadMessagesField = "can_read_messages"
|
||||
const val canDeleteOutgoingMessagesField = "can_delete_outgoing_messages"
|
||||
const val canDeleteAllMessagesField = "can_delete_all_messages"
|
||||
const val canEditNameField = "can_edit_name"
|
||||
const val canEditBioField = "can_edit_bio"
|
||||
const val canEditProfilePhotoField = "can_edit_profile_photo"
|
||||
const val canEditUsernameField = "can_edit_username"
|
||||
const val canChangeGiftSettingsField = "can_change_gift_settings"
|
||||
const val canViewGiftsAndStarsField = "can_view_gifts_and_stars"
|
||||
const val canConvertGiftsToStarsField = "can_convert_gifts_to_stars"
|
||||
const val canTransferAndUpgradeGiftsField = "can_transfer_and_upgrade_gifts"
|
||||
const val canTransferStarsField = "can_transfer_stars"
|
||||
const val canManageStoriesField = "can_manage_stories"
|
||||
const val supportInlineQueriesField = "supports_inline_queries"
|
||||
const val canConnectToBusinessField = "can_connect_to_business"
|
||||
const val textEntitiesField = "text_entities"
|
||||
@@ -262,7 +278,9 @@ const val switchInlineQueryCurrentChatField = "switch_inline_query_current_chat"
|
||||
const val switchInlineQueryChosenChatField = "switch_inline_query_chosen_chat"
|
||||
const val switchInlineQueryField = "switch_inline_query"
|
||||
const val isAnimatedField = "is_animated"
|
||||
const val isAnimationField = "is_animation"
|
||||
const val isVideoField = "is_video"
|
||||
const val coverFrameTimeStampField = "cover_frame_timestamp"
|
||||
const val inviteLinkField = "invite_link"
|
||||
const val viaChatFolderInviteLinkField = "via_chat_folder_invite_link"
|
||||
const val viaJoinRequestField = "via_join_request"
|
||||
@@ -486,20 +504,40 @@ const val questionParseModeField = "question_parse_mode"
|
||||
const val optionsField = "options"
|
||||
const val payField = "pay"
|
||||
const val permissionsField = "permissions"
|
||||
const val premiumSubscriptionDurationField = "premium_subscription_duration"
|
||||
const val transactionTypeField = "transaction_type"
|
||||
const val typeField = "type"
|
||||
const val valueField = "value"
|
||||
const val creatorField = "creator"
|
||||
const val subscriptionPeriodField = "subscription_period"
|
||||
const val subscriptionPriceField = "subscription_price"
|
||||
const val copyTextField = "copy_text"
|
||||
|
||||
const val isPublicField = "is_public"
|
||||
|
||||
const val giftField = "gift"
|
||||
const val giftsField = "gifts"
|
||||
const val rarityPerMilleField = "rarity_per_mille"
|
||||
const val acceptedGiftTypesField = "accepted_gift_types"
|
||||
const val ownedGiftIdField = "owned_gift_id"
|
||||
const val convertStarCountField = "convert_star_count"
|
||||
const val prepaidUpgradeStarCountField = "prepaid_upgrade_star_count"
|
||||
const val canBeUpgradedField = "can_be_upgraded"
|
||||
const val isPrivateField = "is_private"
|
||||
const val transferStarCountField = "transfer_star_count"
|
||||
const val newOwnerChatIdField = "new_owner_chat_id"
|
||||
|
||||
const val pointField = "point"
|
||||
const val xShiftField = "x_shift"
|
||||
const val yShiftField = "y_shift"
|
||||
const val scaleField = "scale"
|
||||
|
||||
const val xPercentageField = "x_percentage"
|
||||
const val yPercentageField = "y_percentage"
|
||||
const val widthPercentageField = "width_percentage"
|
||||
const val heightPercentageField = "height_percentage"
|
||||
const val cornerRadiusPercentageField = "corner_radius_percentage"
|
||||
|
||||
const val maxTipAmountField = "max_tip_amount"
|
||||
const val suggestedTipAmountsField = "suggested_tip_amounts"
|
||||
const val chatTypeField = "chat_type"
|
||||
@@ -542,6 +580,7 @@ const val totalCountField = "total_count"
|
||||
const val remainingCountField = "remaining_count"
|
||||
const val stateField = "state"
|
||||
const val cityField = "city"
|
||||
const val streetField = "street"
|
||||
const val firstStreetLineField = "street_line1"
|
||||
const val secondStreetLineField = "street_line2"
|
||||
const val postCodeField = "post_code"
|
||||
@@ -587,6 +626,11 @@ const val voiceField = "voice"
|
||||
const val videoNoteField = "video_note"
|
||||
const val mediaField = "media"
|
||||
|
||||
const val mainFrameTimestampField = "main_frame_timestamp"
|
||||
|
||||
const val paidMessageStarCountField = "paid_message_star_count"
|
||||
const val paidStarCountField = "paid_star_count"
|
||||
|
||||
const val disableEditMessageField = "disable_edit_message"
|
||||
const val scoreField = "score"
|
||||
const val forceField = "force"
|
||||
@@ -652,6 +696,7 @@ const val onlyNewMembersField = "only_new_members"
|
||||
const val hasPublicWinnersField = "has_public_winners"
|
||||
const val prizeDescriptionField = "prize_description"
|
||||
const val premiumSubscriptionMonthCountField = "premium_subscription_month_count"
|
||||
const val monthCountField = "month_count"
|
||||
const val winnersField = "winners"
|
||||
const val additionalChatCountField = "additional_chat_count"
|
||||
const val unclaimedPrizeCountField = "unclaimed_prize_count"
|
||||
@@ -664,16 +709,46 @@ const val upgradeStarCountField = "upgrade_star_count"
|
||||
const val payToUpgradeField = "pay_for_upgrade"
|
||||
const val paidMediaField = "paid_media"
|
||||
|
||||
const val centerColorField = "center_color"
|
||||
const val edgeColorField = "edge_color"
|
||||
const val symbolColorField = "symbol_color"
|
||||
const val textColorField = "text_color"
|
||||
|
||||
const val baseNameField = "base_name"
|
||||
const val numberField = "number"
|
||||
const val modelField = "model"
|
||||
const val symbolField = "symbol"
|
||||
const val backdropField = "backdrop"
|
||||
|
||||
const val unlimitedGiftsField = "unlimited_gifts"
|
||||
const val limitedGiftsField = "limited_gifts"
|
||||
const val uniqueGiftsField = "unique_gifts"
|
||||
const val premiumSubscriptionField = "premium_subscription"
|
||||
|
||||
const val excludeUnsavedField = "exclude_unsaved"
|
||||
const val excludeSavedField = "exclude_saved"
|
||||
const val excludeUnlimitedField = "exclude_unlimited"
|
||||
const val excludeLimitedField = "exclude_limited"
|
||||
const val excludeUniqueField = "exclude_unique"
|
||||
const val sortByPriceField = "sort_by_price"
|
||||
|
||||
const val businessConnectionIdField = "business_connection_id"
|
||||
const val businessIntroField = "business_intro"
|
||||
const val businessLocationField = "business_location"
|
||||
const val businessOpeningHoursField = "business_opening_hours"
|
||||
|
||||
const val storyIdField = "story_id"
|
||||
const val showGiftButtonField = "show_gift_button"
|
||||
|
||||
const val colorField = "color"
|
||||
const val colorsField = "colors"
|
||||
const val topColorField = "top_color"
|
||||
const val bottomColorField = "bottom_color"
|
||||
const val rotationAngleField = "rotation_angle"
|
||||
const val contentField = "content"
|
||||
const val activePeriodField = "active_period"
|
||||
const val areasField = "areas"
|
||||
const val postToChatPageField = "post_to_chat_page"
|
||||
|
||||
const val fillField = "fill"
|
||||
const val darkThemeDimmingField = "dark_theme_dimming"
|
||||
@@ -686,3 +761,13 @@ const val themeNameField = "theme_name"
|
||||
const val dayField = "day"
|
||||
const val monthField = "month"
|
||||
const val yearField = "year"
|
||||
|
||||
const val rawField = "raw"
|
||||
|
||||
const val reactionTypeField = "reaction_type"
|
||||
|
||||
const val isDarkField = "is_dark"
|
||||
const val isFlippedField = "is_flipped"
|
||||
const val temperatureField = "temperature"
|
||||
const val backgroundColorField = "background_color"
|
||||
const val keepOriginalDetailsField = "keep_original_details"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class OwnedGifts<GiftType: GiftSentOrReceived>(
|
||||
@SerialName(totalCountField)
|
||||
val totalCount: Int,
|
||||
@SerialName(giftsField)
|
||||
val gifts: List<GiftType>,
|
||||
@SerialName(nextOffsetField)
|
||||
val nextOffset: String? = null
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PaidMessagePriceChanged(
|
||||
@SerialName(paidMessageStarCountField)
|
||||
val cost: Int
|
||||
) : CommonEvent
|
||||
@@ -0,0 +1,50 @@
|
||||
package dev.inmo.tgbotapi.types.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.types.canChangeGiftSettingsField
|
||||
import dev.inmo.tgbotapi.types.canConvertGiftsToStarsField
|
||||
import dev.inmo.tgbotapi.types.canDeleteAllMessagesField
|
||||
import dev.inmo.tgbotapi.types.canDeleteOutgoingMessagesField
|
||||
import dev.inmo.tgbotapi.types.canEditBioField
|
||||
import dev.inmo.tgbotapi.types.canEditNameField
|
||||
import dev.inmo.tgbotapi.types.canEditProfilePhotoField
|
||||
import dev.inmo.tgbotapi.types.canEditUsernameField
|
||||
import dev.inmo.tgbotapi.types.canManageStoriesField
|
||||
import dev.inmo.tgbotapi.types.canReadMessagesField
|
||||
import dev.inmo.tgbotapi.types.canReplyField
|
||||
import dev.inmo.tgbotapi.types.canTransferAndUpgradeGiftsField
|
||||
import dev.inmo.tgbotapi.types.canTransferStarsField
|
||||
import dev.inmo.tgbotapi.types.canViewGiftsAndStarsField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class BusinessBotRights(
|
||||
@SerialName(canReplyField)
|
||||
val canReply: Boolean = false,
|
||||
@SerialName(canReadMessagesField)
|
||||
val canMarkMessagesAsRead: Boolean = false,
|
||||
@SerialName(canDeleteOutgoingMessagesField)
|
||||
val canDeleteOutgoingMessages: Boolean = false,
|
||||
@SerialName(canDeleteAllMessagesField)
|
||||
val canDeleteAllMessages: Boolean = false,
|
||||
@SerialName(canEditNameField)
|
||||
val canEditName: Boolean = false,
|
||||
@SerialName(canEditBioField)
|
||||
val canEditBio: Boolean = false,
|
||||
@SerialName(canEditProfilePhotoField)
|
||||
val canEditProfilePhoto: Boolean = false,
|
||||
@SerialName(canEditUsernameField)
|
||||
val canEditUsername: Boolean = false,
|
||||
@SerialName(canChangeGiftSettingsField)
|
||||
val canChangeGiftSettings: Boolean = false,
|
||||
@SerialName(canViewGiftsAndStarsField)
|
||||
val canViewGiftsAndStars: Boolean = false,
|
||||
@SerialName(canConvertGiftsToStarsField)
|
||||
val canConvertGiftsToStars: Boolean = false,
|
||||
@SerialName(canTransferAndUpgradeGiftsField)
|
||||
val canTransferAndUpgradeGifts: Boolean = false,
|
||||
@SerialName(canTransferStarsField)
|
||||
val canTransferStars: Boolean = false,
|
||||
@SerialName(canManageStoriesField)
|
||||
val canManageStories: Boolean = false,
|
||||
)
|
||||
@@ -16,7 +16,9 @@ sealed interface BusinessConnection : WithBusinessConnectionId {
|
||||
val user: PreviewUser
|
||||
val userChatId: ChatId
|
||||
val date: TelegramDate
|
||||
val rights: BusinessBotRights
|
||||
val canReply: Boolean
|
||||
get() = rights.canReply
|
||||
val isEnabled: Boolean
|
||||
|
||||
override val businessConnectionId: BusinessConnectionId
|
||||
@@ -32,8 +34,8 @@ sealed interface BusinessConnection : WithBusinessConnectionId {
|
||||
override val userChatId: ChatId,
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate,
|
||||
@SerialName(canReplyField)
|
||||
override val canReply: Boolean,
|
||||
@SerialName(rightsField)
|
||||
override val rights: BusinessBotRights = BusinessBotRights(),
|
||||
) : BusinessConnection {
|
||||
@EncodeDefault
|
||||
override val isEnabled: Boolean = true
|
||||
@@ -49,8 +51,8 @@ sealed interface BusinessConnection : WithBusinessConnectionId {
|
||||
override val userChatId: ChatId,
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate,
|
||||
@SerialName(canReplyField)
|
||||
override val canReply: Boolean,
|
||||
@SerialName(rightsField)
|
||||
override val rights: BusinessBotRights = BusinessBotRights(),
|
||||
) : BusinessConnection {
|
||||
@EncodeDefault
|
||||
override val isEnabled: Boolean = false
|
||||
|
||||
@@ -15,8 +15,8 @@ internal data class RawBusinessConnection(
|
||||
val userChatId: ChatId,
|
||||
@SerialName(dateField)
|
||||
val date: TelegramDate,
|
||||
@SerialName(canReplyField)
|
||||
val canReply: Boolean,
|
||||
@SerialName(rightsField)
|
||||
val rights: BusinessBotRights = BusinessBotRights(),
|
||||
@SerialName(isEnabledField)
|
||||
val isEnabled: Boolean
|
||||
) {
|
||||
@@ -27,14 +27,14 @@ internal data class RawBusinessConnection(
|
||||
user = user,
|
||||
userChatId = userChatId,
|
||||
date = date,
|
||||
canReply = canReply
|
||||
rights = rights
|
||||
)
|
||||
false -> BusinessConnection.Disabled(
|
||||
id = id,
|
||||
user = user,
|
||||
userChatId = userChatId,
|
||||
date = date,
|
||||
canReply = canReply
|
||||
rights = rights
|
||||
)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ internal data class RawBusinessConnection(
|
||||
user = businessConnection.user,
|
||||
userChatId = businessConnection.userChatId,
|
||||
date = businessConnection.date,
|
||||
canReply = businessConnection.canReply,
|
||||
rights = businessConnection.rights,
|
||||
isEnabled = businessConnection.isEnabled,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessLocation
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours
|
||||
import dev.inmo.tgbotapi.types.colors.ColorId
|
||||
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import korlibs.time.DateTime
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
@@ -21,6 +21,8 @@ data class ExtendedChannelChatImpl(
|
||||
override val id: ChatId,
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
override val acceptedGiftTypes: AcceptedGiftTypes,
|
||||
@SerialName(usernameField)
|
||||
override val username: Username? = null,
|
||||
@SerialName(activeUsernamesField)
|
||||
@@ -57,9 +59,7 @@ data class ExtendedChannelChatImpl(
|
||||
@SerialName(hasVisibleHistoryField)
|
||||
override val newMembersSeeHistory: Boolean = false,
|
||||
@SerialName(maxReactionCountField)
|
||||
override val maxReactionsCount: Int = 3,
|
||||
@SerialName(canSendGiftsField)
|
||||
override val canReceiveGifts: Boolean = false,
|
||||
override val maxReactionsCount: Int = 3
|
||||
) : ExtendedChannelChat
|
||||
|
||||
@Serializable
|
||||
@@ -100,8 +100,8 @@ data class ExtendedGroupChatImpl(
|
||||
override val newMembersSeeHistory: Boolean = false,
|
||||
@SerialName(maxReactionCountField)
|
||||
override val maxReactionsCount: Int = 3,
|
||||
@SerialName(canSendGiftsField)
|
||||
override val canReceiveGifts: Boolean = false,
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
|
||||
) : ExtendedGroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -150,8 +150,8 @@ data class ExtendedPrivateChatImpl(
|
||||
override val personalChat: PreviewChannelChat? = null,
|
||||
@SerialName(maxReactionCountField)
|
||||
override val maxReactionsCount: Int = 3,
|
||||
@SerialName(canSendGiftsField)
|
||||
override val canReceiveGifts: Boolean = false,
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
|
||||
) : ExtendedPrivateChat
|
||||
|
||||
typealias ExtendedUser = ExtendedPrivateChatImpl
|
||||
@@ -218,8 +218,8 @@ data class ExtendedSupergroupChatImpl(
|
||||
override val customEmojiStickerSetName: StickerSetName? = null,
|
||||
@SerialName(maxReactionCountField)
|
||||
override val maxReactionsCount: Int = 3,
|
||||
@SerialName(canSendGiftsField)
|
||||
override val canReceiveGifts: Boolean = false,
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
|
||||
) : ExtendedSupergroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -284,8 +284,8 @@ data class ExtendedForumChatImpl(
|
||||
override val customEmojiStickerSetName: StickerSetName? = null,
|
||||
@SerialName(maxReactionCountField)
|
||||
override val maxReactionsCount: Int = 3,
|
||||
@SerialName(canSendGiftsField)
|
||||
override val canReceiveGifts: Boolean = false,
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
|
||||
) : ExtendedForumChat
|
||||
|
||||
@Serializable
|
||||
@@ -320,8 +320,8 @@ data class ExtendedBot(
|
||||
override val maxReactionsCount: Int = 3,
|
||||
@SerialName(hasMainWebAppField)
|
||||
val hasMainWebApp: Boolean = false,
|
||||
@SerialName(canSendGiftsField)
|
||||
override val canReceiveGifts: Boolean = false,
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
|
||||
) : Bot(), ExtendedChat {
|
||||
@SerialName(isBotField)
|
||||
private val isBot = true
|
||||
@@ -351,6 +351,6 @@ data class UnknownExtendedChat(
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null
|
||||
@SerialName(maxReactionCountField)
|
||||
override val maxReactionsCount: Int = 3
|
||||
@SerialName(canSendGiftsField)
|
||||
override val canReceiveGifts: Boolean = false
|
||||
@SerialName(acceptedGiftTypesField)
|
||||
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessLocation
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours
|
||||
import dev.inmo.tgbotapi.types.colors.ColorId
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
@@ -20,10 +20,18 @@ sealed interface ExtendedChat : Chat {
|
||||
val profileBackgroundCustomEmojiId: CustomEmojiId?
|
||||
val maxReactionsCount: Int
|
||||
|
||||
/**
|
||||
* Represent `can_send_gifts` field
|
||||
*/
|
||||
val acceptedGiftTypes: AcceptedGiftTypes
|
||||
|
||||
@Deprecated(
|
||||
message = "Telegram Bot API v9.0 introduced the new field, `acceptedGiftTypes`, to allow granular" +
|
||||
" control over which types of gifts user, bot, or chat can accept.",
|
||||
replaceWith = ReplaceWith("acceptedGiftTypes.uniqueGifts || acceptedGiftTypes.unlimitedGifts || acceptedGiftTypes.limitedGifts || acceptedGiftTypes.premiumSubscription")
|
||||
)
|
||||
val canReceiveGifts: Boolean
|
||||
get() = acceptedGiftTypes.uniqueGifts ||
|
||||
acceptedGiftTypes.unlimitedGifts ||
|
||||
acceptedGiftTypes.limitedGifts ||
|
||||
acceptedGiftTypes.premiumSubscription
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
@@ -63,6 +71,7 @@ sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername, Ex
|
||||
sealed interface ExtendedPublicChat : ExtendedChat, PublicChat, ExtendedNonBotChat {
|
||||
val description: String
|
||||
val inviteLink: String?
|
||||
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
val pinnedMessage: Message?
|
||||
val membersHidden: Boolean
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.inmo.tgbotapi.types.gifts
|
||||
|
||||
import dev.inmo.tgbotapi.types.limitedGiftsField
|
||||
import dev.inmo.tgbotapi.types.premiumSubscriptionField
|
||||
import dev.inmo.tgbotapi.types.uniqueGiftsField
|
||||
import dev.inmo.tgbotapi.types.unlimitedGiftsField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class AcceptedGiftTypes(
|
||||
@SerialName(unlimitedGiftsField)
|
||||
val unlimitedGifts: Boolean = false,
|
||||
@SerialName(limitedGiftsField)
|
||||
val limitedGifts: Boolean = false,
|
||||
@SerialName(uniqueGiftsField)
|
||||
val uniqueGifts: Boolean = false,
|
||||
@SerialName(premiumSubscriptionField)
|
||||
val premiumSubscription: Boolean = false
|
||||
)
|
||||
@@ -2,6 +2,9 @@ package dev.inmo.tgbotapi.types.gifts
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftBackdrop
|
||||
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftModel
|
||||
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftSymbol
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -11,55 +14,133 @@ import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(Gift.Companion::class)
|
||||
sealed interface Gift {
|
||||
val id: GiftId
|
||||
val sticker: Sticker
|
||||
val starCount: Int
|
||||
val totalCount: Int?
|
||||
val upgradeStarCount: Int?
|
||||
val remainingCount: Int?
|
||||
@Serializable(Regular.Companion::class)
|
||||
sealed interface Regular : Gift {
|
||||
val id: GiftId
|
||||
val sticker: Sticker
|
||||
val starCount: Int
|
||||
val totalCount: Int?
|
||||
val upgradeStarCount: Int?
|
||||
val remainingCount: Int?
|
||||
|
||||
@Serializable
|
||||
data class Unlimited(
|
||||
@SerialName(idField)
|
||||
override val id: GiftId,
|
||||
@SerialName(stickerField)
|
||||
override val sticker: Sticker,
|
||||
@SerialName(starCountField)
|
||||
override val starCount: Int,
|
||||
@SerialName(upgradeStarCountField)
|
||||
override val upgradeStarCount: Int? = null
|
||||
) : Gift {
|
||||
override val totalCount: Int?
|
||||
get() = null
|
||||
override val remainingCount: Int?
|
||||
get() = null
|
||||
@Serializable
|
||||
data class Unlimited(
|
||||
@SerialName(idField)
|
||||
override val id: GiftId,
|
||||
@SerialName(stickerField)
|
||||
override val sticker: Sticker,
|
||||
@SerialName(starCountField)
|
||||
override val starCount: Int,
|
||||
@SerialName(upgradeStarCountField)
|
||||
override val upgradeStarCount: Int? = null
|
||||
) : Regular {
|
||||
override val totalCount: Int?
|
||||
get() = null
|
||||
override val remainingCount: Int?
|
||||
get() = null
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Limited(
|
||||
@SerialName(idField)
|
||||
override val id: GiftId,
|
||||
@SerialName(stickerField)
|
||||
override val sticker: Sticker,
|
||||
@SerialName(starCountField)
|
||||
override val starCount: Int,
|
||||
@SerialName(totalCountField)
|
||||
override val totalCount: Int,
|
||||
@SerialName(remainingCountField)
|
||||
override val remainingCount: Int,
|
||||
@SerialName(upgradeStarCountField)
|
||||
override val upgradeStarCount: Int? = null,
|
||||
) : Regular
|
||||
|
||||
companion object : KSerializer<Regular> {
|
||||
@Serializable
|
||||
@Suppress("propertyName")
|
||||
private data class RegularGiftSurrogate(
|
||||
val id: GiftId,
|
||||
val sticker: Sticker,
|
||||
val star_count: Int,
|
||||
val total_count: Int? = null,
|
||||
val remaining_count: Int? = null,
|
||||
val upgrade_star_count: Int? = null,
|
||||
)
|
||||
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = RegularGiftSurrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): Regular {
|
||||
val surrogate = RegularGiftSurrogate.serializer().deserialize(decoder)
|
||||
|
||||
return if (surrogate.total_count != null && surrogate.remaining_count != null) {
|
||||
Limited(
|
||||
id = surrogate.id,
|
||||
sticker = surrogate.sticker,
|
||||
starCount = surrogate.star_count,
|
||||
totalCount = surrogate.total_count,
|
||||
remainingCount = surrogate.remaining_count,
|
||||
upgradeStarCount = surrogate.upgrade_star_count,
|
||||
)
|
||||
} else {
|
||||
Unlimited(
|
||||
id = surrogate.id,
|
||||
sticker = surrogate.sticker,
|
||||
starCount = surrogate.star_count,
|
||||
upgradeStarCount = surrogate.upgrade_star_count,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Regular) {
|
||||
val surrogate = RegularGiftSurrogate(
|
||||
id = value.id,
|
||||
sticker = value.sticker,
|
||||
star_count = value.starCount,
|
||||
total_count = value.totalCount,
|
||||
remaining_count = value.remainingCount,
|
||||
upgrade_star_count = value.upgradeStarCount
|
||||
)
|
||||
RegularGiftSurrogate.serializer().serialize(encoder, surrogate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Limited(
|
||||
@SerialName(idField)
|
||||
override val id: GiftId,
|
||||
@SerialName(stickerField)
|
||||
override val sticker: Sticker,
|
||||
@SerialName(starCountField)
|
||||
override val starCount: Int,
|
||||
@SerialName(totalCountField)
|
||||
override val totalCount: Int,
|
||||
@SerialName(remainingCountField)
|
||||
override val remainingCount: Int,
|
||||
@SerialName(upgradeStarCountField)
|
||||
override val upgradeStarCount: Int? = null,
|
||||
data class Unique(
|
||||
@SerialName(baseNameField)
|
||||
val baseName: String,
|
||||
@SerialName(nameField)
|
||||
val name: String,
|
||||
@SerialName(numberField)
|
||||
val number: Int,
|
||||
@SerialName(modelField)
|
||||
val model: UniqueGiftModel,
|
||||
@SerialName(symbolField)
|
||||
val symbol: UniqueGiftSymbol,
|
||||
@SerialName(backdropField)
|
||||
val backdrop: UniqueGiftBackdrop
|
||||
) : Gift
|
||||
|
||||
companion object : KSerializer<Gift> {
|
||||
@Serializable
|
||||
private data class GiftSurrogate(
|
||||
val id: GiftId,
|
||||
val sticker: Sticker,
|
||||
val star_count: Int,
|
||||
@Suppress("unused", "propertyName")
|
||||
private class GiftSurrogate(
|
||||
// regular gift fields
|
||||
val id: GiftId?,
|
||||
val sticker: Sticker?,
|
||||
val star_count: Int?,
|
||||
val total_count: Int? = null,
|
||||
val remaining_count: Int? = null,
|
||||
val upgrade_star_count: Int? = null,
|
||||
// unique gift fields
|
||||
val base_name: String? = null,
|
||||
val name: String? = null,
|
||||
val number: Int? = null,
|
||||
val model: UniqueGiftModel? = null,
|
||||
val symbol: UniqueGiftSymbol? = null,
|
||||
val backdrop: UniqueGiftBackdrop? = null,
|
||||
)
|
||||
|
||||
override val descriptor: SerialDescriptor
|
||||
@@ -68,33 +149,37 @@ sealed interface Gift {
|
||||
override fun deserialize(decoder: Decoder): Gift {
|
||||
val surrogate = GiftSurrogate.serializer().deserialize(decoder)
|
||||
|
||||
return if (surrogate.total_count != null && surrogate.remaining_count != null) {
|
||||
Limited(
|
||||
id = surrogate.id,
|
||||
sticker = surrogate.sticker,
|
||||
starCount = surrogate.star_count,
|
||||
totalCount = surrogate.total_count,
|
||||
remainingCount = surrogate.remaining_count,
|
||||
upgradeStarCount = surrogate.upgrade_star_count,
|
||||
return if (surrogate.base_name != null && surrogate.name != null && surrogate.number != null && surrogate.model != null && surrogate.symbol != null && surrogate.backdrop != null) {
|
||||
Unique(
|
||||
baseName = surrogate.base_name,
|
||||
name = surrogate.name,
|
||||
number = surrogate.number,
|
||||
model = surrogate.model,
|
||||
symbol = surrogate.symbol,
|
||||
backdrop = surrogate.backdrop,
|
||||
)
|
||||
} else {
|
||||
Unlimited(
|
||||
id = surrogate.id,
|
||||
sticker = surrogate.sticker,
|
||||
starCount = surrogate.star_count,
|
||||
upgradeStarCount = surrogate.upgrade_star_count,
|
||||
)
|
||||
decoder.decodeSerializableValue(Regular.serializer())
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Gift) {
|
||||
override fun serialize(
|
||||
encoder: Encoder,
|
||||
value: Gift
|
||||
) {
|
||||
val surrogate = GiftSurrogate(
|
||||
id = value.id,
|
||||
sticker = value.sticker,
|
||||
star_count = value.starCount,
|
||||
total_count = value.totalCount,
|
||||
remaining_count = value.remainingCount,
|
||||
upgrade_star_count = value.upgradeStarCount
|
||||
id = (value as? Regular)?.id,
|
||||
sticker = (value as? Regular)?.sticker,
|
||||
star_count = (value as? Regular)?.starCount,
|
||||
total_count = (value as? Regular.Limited)?.totalCount,
|
||||
remaining_count = (value as? Regular.Limited)?.remainingCount,
|
||||
upgrade_star_count = (value as? Regular)?.upgradeStarCount,
|
||||
base_name = (value as? Unique)?.baseName,
|
||||
name = (value as? Unique)?.name,
|
||||
number = (value as? Unique)?.number,
|
||||
model = (value as? Unique)?.model,
|
||||
symbol = (value as? Unique)?.symbol,
|
||||
backdrop = (value as? Unique)?.backdrop,
|
||||
)
|
||||
GiftSurrogate.serializer().serialize(encoder, surrogate)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
package dev.inmo.tgbotapi.types.gifts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
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
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
|
||||
/**
|
||||
* Represent Telegram Bots API abstraction [GiftInfo](https://core.telegram.org/bots/api#giftinfo) and
|
||||
* [UniqueGiftInfo](https://core.telegram.org/bots/api#uniquegiftinfo)
|
||||
*
|
||||
* @see ReceivedInBusinessAccount
|
||||
* @see Regular.Common
|
||||
* @see Regular.ReceivedInBusinessAccount
|
||||
* @see Unique.Common
|
||||
* @see Unique.ReceivedInBusinessAccount
|
||||
*/
|
||||
@Serializable
|
||||
sealed interface GiftSentOrReceived : CommonEvent {
|
||||
val ownedGiftId: GiftId?
|
||||
val gift: Gift
|
||||
|
||||
@Serializable
|
||||
sealed interface ReceivedInBusinessAccount : GiftSentOrReceived {
|
||||
override val ownedGiftId: GiftId
|
||||
}
|
||||
|
||||
@Serializable(Regular.Companion::class)
|
||||
sealed interface Regular : GiftSentOrReceived, TextedInput {
|
||||
override val gift: Gift.Regular
|
||||
val convertStarCount: Int?
|
||||
val prepaidUpgradeStarCount: Int?
|
||||
val canBeUpgraded: Boolean
|
||||
val isPrivate: Boolean
|
||||
|
||||
@Serializable
|
||||
data class Common(
|
||||
@SerialName(giftField)
|
||||
override val gift: Gift.Regular,
|
||||
@SerialName(convertStarCountField)
|
||||
override val convertStarCount: Int? = null,
|
||||
@SerialName(prepaidUpgradeStarCountField)
|
||||
override val prepaidUpgradeStarCount: Int? = null,
|
||||
@SerialName(canBeUpgradedField)
|
||||
override val canBeUpgraded: Boolean = false,
|
||||
@SerialName(textField)
|
||||
override val text: String? = null,
|
||||
@SerialName(entitiesField)
|
||||
private val entities: RawMessageEntities? = null,
|
||||
@SerialName(isPrivateField)
|
||||
override val isPrivate: Boolean = false
|
||||
) : Regular {
|
||||
override val textSources: List<TextSource> by lazy {
|
||||
entities ?.asTextSources(text ?: return@lazy emptyList()) ?: emptyList()
|
||||
}
|
||||
override val ownedGiftId: GiftId?
|
||||
get() = null
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ReceivedInBusinessAccount(
|
||||
@SerialName(giftField)
|
||||
override val gift: Gift.Regular,
|
||||
@SerialName(ownedGiftIdField)
|
||||
override val ownedGiftId: GiftId,
|
||||
@SerialName(convertStarCountField)
|
||||
override val convertStarCount: Int? = null,
|
||||
@SerialName(prepaidUpgradeStarCountField)
|
||||
override val prepaidUpgradeStarCount: Int? = null,
|
||||
@SerialName(canBeUpgradedField)
|
||||
override val canBeUpgraded: Boolean = false,
|
||||
@SerialName(textField)
|
||||
override val text: String? = null,
|
||||
@SerialName(entitiesField)
|
||||
private val entities: RawMessageEntities? = null,
|
||||
@SerialName(isPrivateField)
|
||||
override val isPrivate: Boolean = false
|
||||
) : Regular, GiftSentOrReceived.ReceivedInBusinessAccount {
|
||||
override val textSources: List<TextSource> by lazy {
|
||||
entities ?.asTextSources(text ?: return@lazy emptyList()) ?: emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
companion object : KSerializer<GiftSentOrReceived.Regular> {
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
@SerialName(giftField)
|
||||
val gift: Gift.Regular,
|
||||
@SerialName(ownedGiftIdField)
|
||||
val ownedGiftId: GiftId? = null,
|
||||
@SerialName(convertStarCountField)
|
||||
val convertStarCount: Int? = null,
|
||||
@SerialName(prepaidUpgradeStarCountField)
|
||||
val prepaidUpgradeStarCount: Int? = null,
|
||||
@SerialName(canBeUpgradedField)
|
||||
val canBeUpgraded: Boolean = false,
|
||||
@SerialName(textField)
|
||||
val text: String? = null,
|
||||
@SerialName(entitiesField)
|
||||
val entities: RawMessageEntities? = null,
|
||||
@SerialName(isPrivateField)
|
||||
val isPrivate: Boolean = false
|
||||
)
|
||||
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Regular) {
|
||||
when (value) {
|
||||
is Common -> Common.serializer().serialize(encoder, value)
|
||||
is ReceivedInBusinessAccount -> ReceivedInBusinessAccount.serializer().serialize(encoder, value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): Regular {
|
||||
val surrogate = Surrogate.serializer().deserialize(decoder)
|
||||
|
||||
return when {
|
||||
surrogate.ownedGiftId == null -> {
|
||||
Common(
|
||||
gift = surrogate.gift,
|
||||
convertStarCount = surrogate.convertStarCount,
|
||||
prepaidUpgradeStarCount = surrogate.prepaidUpgradeStarCount,
|
||||
canBeUpgraded = surrogate.canBeUpgraded,
|
||||
text = surrogate.text,
|
||||
entities = surrogate.entities,
|
||||
isPrivate = surrogate.isPrivate
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
ReceivedInBusinessAccount(
|
||||
gift = surrogate.gift,
|
||||
ownedGiftId = surrogate.ownedGiftId,
|
||||
convertStarCount = surrogate.convertStarCount,
|
||||
prepaidUpgradeStarCount = surrogate.prepaidUpgradeStarCount,
|
||||
canBeUpgraded = surrogate.canBeUpgraded,
|
||||
text = surrogate.text,
|
||||
entities = surrogate.entities,
|
||||
isPrivate = surrogate.isPrivate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@JvmName("PublicConstructor")
|
||||
operator fun invoke(
|
||||
gift: Gift.Regular,
|
||||
ownedGiftId: GiftId? = null,
|
||||
convertStarCount: Int? = null,
|
||||
prepaidUpgradeStarCount: Int? = null,
|
||||
canBeUpgraded: Boolean = false,
|
||||
text: String? = null,
|
||||
textSources: TextSourcesList = emptyList(),
|
||||
position: Int,
|
||||
isPrivate: Boolean = false
|
||||
) = ownedGiftId ?.let {
|
||||
ReceivedInBusinessAccount(
|
||||
gift,
|
||||
ownedGiftId,
|
||||
convertStarCount,
|
||||
prepaidUpgradeStarCount,
|
||||
canBeUpgraded,
|
||||
text,
|
||||
textSources.toRawMessageEntities(position),
|
||||
isPrivate
|
||||
)
|
||||
} ?: Common(
|
||||
gift,
|
||||
convertStarCount,
|
||||
prepaidUpgradeStarCount,
|
||||
canBeUpgraded,
|
||||
text,
|
||||
textSources.toRawMessageEntities(position),
|
||||
isPrivate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(Unique.Companion::class)
|
||||
sealed interface Unique : GiftSentOrReceived {
|
||||
override val gift: Gift.Unique
|
||||
val origin: String?
|
||||
val transferStarCount: Int?
|
||||
|
||||
@Serializable
|
||||
data class Common(
|
||||
@SerialName(giftField)
|
||||
override val gift: Gift.Unique,
|
||||
@SerialName(originField)
|
||||
override val origin: String? = null,
|
||||
@SerialName(transferStarCountField)
|
||||
override val transferStarCount: Int? = null
|
||||
) : Unique {
|
||||
override val ownedGiftId: GiftId?
|
||||
get() = null
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ReceivedInBusinessAccount(
|
||||
@SerialName(giftField)
|
||||
override val gift: Gift.Unique,
|
||||
@SerialName(ownedGiftIdField)
|
||||
override val ownedGiftId: GiftId,
|
||||
@SerialName(originField)
|
||||
override val origin: String? = null,
|
||||
@SerialName(transferStarCountField)
|
||||
override val transferStarCount: Int? = null
|
||||
) : Unique, GiftSentOrReceived.ReceivedInBusinessAccount
|
||||
|
||||
companion object : KSerializer<GiftSentOrReceived.Unique> {
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
@SerialName(giftField)
|
||||
val gift: Gift.Unique,
|
||||
@SerialName(ownedGiftIdField)
|
||||
val ownedGiftId: GiftId? = null,
|
||||
@SerialName(originField)
|
||||
val origin: String? = null,
|
||||
@SerialName(transferStarCountField)
|
||||
val transferStarCount: Int? = null
|
||||
)
|
||||
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Unique) {
|
||||
when (value) {
|
||||
is Common -> Common.serializer().serialize(encoder, value)
|
||||
is ReceivedInBusinessAccount -> ReceivedInBusinessAccount.serializer().serialize(encoder, value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): Unique {
|
||||
val surrogate = Surrogate.serializer().deserialize(decoder)
|
||||
|
||||
return when {
|
||||
surrogate.ownedGiftId == null -> {
|
||||
Common(
|
||||
gift = surrogate.gift,
|
||||
origin = surrogate.origin,
|
||||
transferStarCount = surrogate.transferStarCount
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
ReceivedInBusinessAccount(
|
||||
gift = surrogate.gift,
|
||||
ownedGiftId = surrogate.ownedGiftId,
|
||||
origin = surrogate.origin,
|
||||
transferStarCount = surrogate.transferStarCount
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@JvmName("PublicConstructor")
|
||||
operator fun invoke(
|
||||
gift: Gift.Unique,
|
||||
origin: String? = null,
|
||||
ownedGiftId: GiftId? = null,
|
||||
transferStarCount: Int? = null
|
||||
) = ownedGiftId ?.let {
|
||||
ReceivedInBusinessAccount(
|
||||
gift,
|
||||
ownedGiftId,
|
||||
origin,
|
||||
transferStarCount,
|
||||
)
|
||||
} ?: Common(
|
||||
gift,
|
||||
origin,
|
||||
transferStarCount,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,5 +7,5 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class Gifts(
|
||||
@SerialName(giftsField)
|
||||
val gifts: List<Gift>
|
||||
val gifts: List<Gift.Regular>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package dev.inmo.tgbotapi.types.gifts.unique
|
||||
|
||||
import dev.inmo.tgbotapi.types.colorsField
|
||||
import dev.inmo.tgbotapi.types.nameField
|
||||
import dev.inmo.tgbotapi.types.rarityPerMilleField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class UniqueGiftBackdrop(
|
||||
@SerialName(nameField)
|
||||
val name: String,
|
||||
@SerialName(colorsField)
|
||||
val colors: UniqueGiftBackdropColors,
|
||||
@SerialName(rarityPerMilleField)
|
||||
val rarityPerMille: Int
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.types.gifts.unique
|
||||
|
||||
import dev.inmo.tgbotapi.types.centerColorField
|
||||
import dev.inmo.tgbotapi.types.edgeColorField
|
||||
import dev.inmo.tgbotapi.types.symbolColorField
|
||||
import dev.inmo.tgbotapi.types.textColorField
|
||||
import dev.inmo.tgbotapi.utils.RGBColor
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class UniqueGiftBackdropColors(
|
||||
@SerialName(centerColorField)
|
||||
val centerColor: RGBColor,
|
||||
@SerialName(edgeColorField)
|
||||
val edgeColor: RGBColor,
|
||||
@SerialName(symbolColorField)
|
||||
val symbolColor: RGBColor,
|
||||
@SerialName(textColorField)
|
||||
val textColor: RGBColor
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.types.gifts.unique
|
||||
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.nameField
|
||||
import dev.inmo.tgbotapi.types.rarityPerMilleField
|
||||
import dev.inmo.tgbotapi.types.stickerField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class UniqueGiftModel(
|
||||
@SerialName(nameField)
|
||||
val name: String,
|
||||
@SerialName(stickerField)
|
||||
val sticker: Sticker,
|
||||
@SerialName(rarityPerMilleField)
|
||||
val rarityPerMille: Int
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.types.gifts.unique
|
||||
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.nameField
|
||||
import dev.inmo.tgbotapi.types.rarityPerMilleField
|
||||
import dev.inmo.tgbotapi.types.stickerField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class UniqueGiftSymbol(
|
||||
@SerialName(nameField)
|
||||
val name: String,
|
||||
@SerialName(stickerField)
|
||||
val sticker: Sticker,
|
||||
@SerialName(rarityPerMilleField)
|
||||
val rarityPerMille: Int
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.location
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class LocationAddress(
|
||||
@SerialName(countryCodeField)
|
||||
val countryCode: String,
|
||||
@SerialName(stateField)
|
||||
val state: String,
|
||||
@SerialName(cityField)
|
||||
val city: String,
|
||||
@SerialName(streetField)
|
||||
val street: String,
|
||||
)
|
||||
@@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.BusinessContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import kotlinx.serialization.SerialName
|
||||
|
||||
data class BusinessContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageId,
|
||||
@@ -28,6 +29,8 @@ data class BusinessContentMessageImpl<T: MessageContent>(
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val senderBusinessBot: PreviewBot?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : BusinessContentMessage<T> {
|
||||
constructor(
|
||||
messageId: MessageId,
|
||||
|
||||
@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import kotlinx.serialization.SerialName
|
||||
|
||||
data class ChannelContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageId,
|
||||
@@ -25,6 +26,8 @@ data class ChannelContentMessageImpl<T: MessageContent>(
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : ChannelContentMessage<T> {
|
||||
constructor(
|
||||
messageId: MessageId,
|
||||
|
||||
@@ -20,6 +20,7 @@ sealed interface ForwardInfo {
|
||||
override val from: User
|
||||
) : ForwardInfo, FromUser
|
||||
|
||||
@ClassCastsIncluded.ExcludeSubName
|
||||
sealed interface PublicChat : ForwardInfo {
|
||||
val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.types.chat.CommonBot
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import kotlinx.serialization.SerialName
|
||||
|
||||
data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
|
||||
override val chat: PreviewGroupChat,
|
||||
@@ -24,6 +25,8 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : ConnectedFromChannelGroupContentMessage<T> {
|
||||
|
||||
constructor(
|
||||
@@ -41,8 +44,23 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupId?,
|
||||
fromOffline: Boolean,
|
||||
cost: Int? = null,
|
||||
) : this(
|
||||
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
|
||||
chat = chat,
|
||||
channel = channel,
|
||||
messageId = messageId,
|
||||
date = date,
|
||||
forwardOrigin = forwardInfo.messageOrigin(),
|
||||
editDate = editDate,
|
||||
hasProtectedContent = hasProtectedContent,
|
||||
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
|
||||
replyMarkup = replyMarkup,
|
||||
content = content,
|
||||
senderBot = senderBot,
|
||||
authorSignature = authorSignature,
|
||||
mediaGroupId = mediaGroupId,
|
||||
fromOffline = fromOffline,
|
||||
cost = cost,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -61,6 +79,8 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : UnconnectedFromChannelGroupContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
@@ -77,8 +97,23 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupId?,
|
||||
fromOffline: Boolean,
|
||||
cost: Int? = null,
|
||||
) : this(
|
||||
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
|
||||
chat = chat,
|
||||
channel = channel,
|
||||
messageId = messageId,
|
||||
date = date,
|
||||
forwardOrigin = forwardInfo.messageOrigin(),
|
||||
editDate = editDate,
|
||||
hasProtectedContent = hasProtectedContent,
|
||||
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
|
||||
replyMarkup = replyMarkup,
|
||||
content = content,
|
||||
senderBot = senderBot,
|
||||
authorSignature = authorSignature,
|
||||
mediaGroupId = mediaGroupId,
|
||||
fromOffline = fromOffline,
|
||||
cost = cost,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -96,6 +131,8 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : AnonymousGroupContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
@@ -111,8 +148,22 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupId?,
|
||||
fromOffline: Boolean,
|
||||
cost: Int? = null,
|
||||
) : this(
|
||||
chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
|
||||
chat = chat,
|
||||
messageId = messageId,
|
||||
date = date,
|
||||
forwardOrigin = forwardInfo.messageOrigin(),
|
||||
editDate = editDate,
|
||||
hasProtectedContent = hasProtectedContent,
|
||||
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
|
||||
replyMarkup = replyMarkup,
|
||||
content = content,
|
||||
senderBot = senderBot,
|
||||
authorSignature = authorSignature,
|
||||
mediaGroupId = mediaGroupId,
|
||||
fromOffline = fromOffline,
|
||||
cost = cost,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -131,6 +182,8 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val senderBoostsCount: Int?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : CommonGroupContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
@@ -147,8 +200,23 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
mediaGroupId: MediaGroupId?,
|
||||
senderBoostsCount: Int?,
|
||||
fromOffline: Boolean,
|
||||
cost: Int? = null,
|
||||
) : this(
|
||||
chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount, fromOffline
|
||||
chat = chat,
|
||||
messageId = messageId,
|
||||
from = from,
|
||||
date = date,
|
||||
forwardOrigin = forwardInfo.messageOrigin(),
|
||||
editDate = editDate,
|
||||
hasProtectedContent = hasProtectedContent,
|
||||
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
|
||||
replyMarkup = replyMarkup,
|
||||
content = content,
|
||||
senderBot = senderBot,
|
||||
mediaGroupId = mediaGroupId,
|
||||
senderBoostsCount = senderBoostsCount,
|
||||
fromOffline = fromOffline,
|
||||
cost = cost,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -168,6 +236,8 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : FromChannelForumContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewForumChat,
|
||||
@@ -185,8 +255,24 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupId?,
|
||||
fromOffline: Boolean,
|
||||
cost: Int? = null,
|
||||
) : this(
|
||||
chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
|
||||
chat = chat,
|
||||
channel = channel,
|
||||
messageId = messageId,
|
||||
threadId = threadId,
|
||||
date = date,
|
||||
forwardOrigin = forwardInfo.messageOrigin(),
|
||||
editDate = editDate,
|
||||
hasProtectedContent = hasProtectedContent,
|
||||
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
|
||||
replyMarkup = replyMarkup,
|
||||
content = content,
|
||||
senderBot = senderBot,
|
||||
authorSignature = authorSignature,
|
||||
mediaGroupId = mediaGroupId,
|
||||
fromOffline = fromOffline,
|
||||
cost = cost,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -205,6 +291,8 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : AnonymousForumContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewForumChat,
|
||||
@@ -221,8 +309,23 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupId?,
|
||||
fromOffline: Boolean,
|
||||
cost: Int? = null,
|
||||
) : this(
|
||||
chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
|
||||
chat = chat,
|
||||
messageId = messageId,
|
||||
threadId = threadId,
|
||||
date = date,
|
||||
forwardOrigin = forwardInfo.messageOrigin(),
|
||||
editDate = editDate,
|
||||
hasProtectedContent = hasProtectedContent,
|
||||
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
|
||||
replyMarkup = replyMarkup,
|
||||
content = content,
|
||||
senderBot = senderBot,
|
||||
authorSignature = authorSignature,
|
||||
mediaGroupId = mediaGroupId,
|
||||
fromOffline = fromOffline,
|
||||
cost = cost,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -242,6 +345,8 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val senderBoostsCount: Int?,
|
||||
override val fromOffline: Boolean,
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val cost: Int? = null,
|
||||
) : CommonForumContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewForumChat,
|
||||
@@ -259,7 +364,23 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
mediaGroupId: MediaGroupId?,
|
||||
senderBoostsCount: Int?,
|
||||
fromOffline: Boolean,
|
||||
cost: Int? = null,
|
||||
) : this(
|
||||
chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount, fromOffline
|
||||
chat = chat,
|
||||
messageId = messageId,
|
||||
threadId = threadId,
|
||||
from = from,
|
||||
date = date,
|
||||
forwardOrigin = forwardInfo.messageOrigin(),
|
||||
editDate = editDate,
|
||||
hasProtectedContent = hasProtectedContent,
|
||||
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
|
||||
replyMarkup = replyMarkup,
|
||||
content = content,
|
||||
senderBot = senderBot,
|
||||
mediaGroupId = mediaGroupId,
|
||||
senderBoostsCount = senderBoostsCount,
|
||||
fromOffline = fromOffline,
|
||||
cost = cost,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import kotlinx.serialization.SerialName
|
||||
|
||||
data class PrivateContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageId,
|
||||
@@ -24,7 +25,9 @@ data class PrivateContentMessageImpl<T: MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
override val mediaGroupId: MediaGroupId?,
|
||||
override val fromOffline: Boolean,
|
||||
override val effectId: EffectId?
|
||||
override val effectId: EffectId?,
|
||||
@SerialName(paidStarCountField)
|
||||
override val cost: Int? = null
|
||||
) : PrivateContentMessage<T> {
|
||||
constructor(
|
||||
messageId: MessageId,
|
||||
|
||||
@@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.dice.Dice
|
||||
import dev.inmo.tgbotapi.types.files.*
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.games.RawGame
|
||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
|
||||
import dev.inmo.tgbotapi.types.giveaway.*
|
||||
import dev.inmo.tgbotapi.types.message.content.GiveawayContent
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
@@ -109,6 +110,9 @@ internal data class RawMessage(
|
||||
|
||||
private val is_from_offline: Boolean = false,
|
||||
|
||||
private val paid_star_count: Int? = null,
|
||||
private val paid_message_price_changed: PaidMessagePriceChanged? = null,
|
||||
|
||||
// Voice Chat Service Messages
|
||||
private val video_chat_scheduled: VideoChatScheduled? = null,
|
||||
private val video_chat_started: VideoChatStarted? = null,
|
||||
@@ -160,6 +164,10 @@ internal data class RawMessage(
|
||||
private val giveaway: Giveaway? = null,
|
||||
private val giveaway_winners: GiveawayPublicResults? = null,
|
||||
private val giveaway_completed: GiveawayPrivateResults? = null,
|
||||
|
||||
// Gifts
|
||||
private val gift: GiftSentOrReceived.Regular? = null,
|
||||
private val unique_gift: GiftSentOrReceived.Unique? = null,
|
||||
) {
|
||||
private val checkedFrom = from ?.takeIf { !it.isFakeTelegramUser() }
|
||||
private val content: MessageContent? by lazy {
|
||||
@@ -282,6 +290,9 @@ internal data class RawMessage(
|
||||
giveaway_completed != null -> giveaway_completed
|
||||
boost_added != null -> boost_added
|
||||
chat_background_set != null -> chat_background_set
|
||||
paid_message_price_changed != null -> paid_message_price_changed
|
||||
gift != null -> gift
|
||||
unique_gift != null -> unique_gift
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -295,7 +306,7 @@ internal data class RawMessage(
|
||||
}
|
||||
|
||||
try {
|
||||
chatEvent?.let { chatEvent ->
|
||||
chatEvent ?.let { chatEvent ->
|
||||
when (chat) {
|
||||
is PreviewSupergroupChat -> CommonSupergroupEventMessage(
|
||||
messageId,
|
||||
@@ -350,7 +361,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
is PreviewForumChat -> if (messageThreadId != null) {
|
||||
val chatId = ChatIdWithThreadId(
|
||||
@@ -376,7 +388,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
is PreviewGroupChat -> AnonymousForumContentMessageImpl(
|
||||
chat = actualForumChat,
|
||||
@@ -392,7 +405,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
null -> CommonForumContentMessageImpl(
|
||||
chat = actualForumChat,
|
||||
@@ -409,7 +423,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBoostsCount = sender_boost_count,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -429,7 +444,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
} else {
|
||||
UnconnectedFromChannelGroupContentMessageImpl(
|
||||
@@ -446,7 +462,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
is GroupChat -> AnonymousGroupContentMessageImpl(
|
||||
@@ -462,7 +479,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
null -> CommonGroupContentMessageImpl(
|
||||
chat = chat,
|
||||
@@ -478,7 +496,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBoostsCount = sender_boost_count,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -498,7 +517,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
} else {
|
||||
UnconnectedFromChannelGroupContentMessageImpl(
|
||||
@@ -515,7 +535,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
is PreviewGroupChat -> AnonymousGroupContentMessageImpl(
|
||||
@@ -531,7 +552,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
null -> CommonGroupContentMessageImpl(
|
||||
chat = chat,
|
||||
@@ -547,7 +569,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBoostsCount = sender_boost_count,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -566,7 +589,8 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline,
|
||||
effectId = effect_id
|
||||
effectId = effect_id,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
} else {
|
||||
BusinessContentMessageImpl(
|
||||
@@ -587,18 +611,19 @@ internal data class RawMessage(
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBusinessBot = sender_business_bot,
|
||||
fromOffline = is_from_offline
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
else -> error("Unknown type of chat: $chat")
|
||||
}
|
||||
} ?: passport_data ?.let{
|
||||
PassportMessage(
|
||||
messageId,
|
||||
chat,
|
||||
checkedFrom ?: from ?: error("For passport must be provided user, but got null"),
|
||||
date.asDate,
|
||||
passport_data
|
||||
messageId = messageId,
|
||||
chat = chat,
|
||||
from = checkedFrom ?: from ?: error("For passport must be provided user, but got null"),
|
||||
date = date.asDate,
|
||||
passportData = passport_data,
|
||||
)
|
||||
} ?: error("Was not found supported type of data")
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -10,4 +10,5 @@ sealed interface CommonMessage<out T: MessageContent> : AccessibleMessage,
|
||||
PossiblyBusinessMessage,
|
||||
PossiblyOfflineMessage,
|
||||
PossiblyMediaGroupMessage<T>,
|
||||
PossiblyPaidMessage,
|
||||
ContentMessage<T>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
|
||||
sealed interface GroupContentMessage<T : MessageContent> : PublicContentMessage<T> {
|
||||
@@ -15,6 +17,9 @@ sealed interface PotentiallyFromUserGroupContentMessage<T : MessageContent> : Gr
|
||||
sealed interface ForumContentMessage<T : MessageContent> : GroupContentMessage<T>, PossiblyTopicMessage {
|
||||
override val chat: PreviewForumChat
|
||||
override val threadId: MessageThreadId
|
||||
|
||||
override val threadCreatingInfo: ForumTopicCreated?
|
||||
get() = (replyTo as? ChatEventMessage<*>) ?.chatEvent as? ForumTopicCreated
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
interface PossiblyPaidMessage : Message {
|
||||
val cost: Int?
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
||||
|
||||
interface PossiblyTopicMessage : AccessibleMessage {
|
||||
val threadId: MessageThreadId?
|
||||
val threadCreatingInfo: ForumTopicCreated?
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
|
||||
CommandRegex.find(source) ?.value ?.substring(1) ?: source.substring(1)// skip first symbol like "/" or "!"
|
||||
}
|
||||
val username: Username? by lazy {
|
||||
Username(usernameRegex.find(source) ?.value ?: return@lazy null)
|
||||
Username.prepare(usernameRegex.find(source) ?.value ?: return@lazy null)
|
||||
}
|
||||
|
||||
override val markdown: String by lazy { source.commandMarkdown() }
|
||||
|
||||
@@ -18,7 +18,7 @@ data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
|
||||
val potentialUsername = source.dropWhile { it != '@' }
|
||||
if (potentialUsername.isEmpty()) return@lazy null
|
||||
|
||||
Username(potentialUsername)
|
||||
Username.prepare(potentialUsername)
|
||||
}
|
||||
override val markdown: String by lazy { source.cashTagMarkdown() }
|
||||
override val markdownV2: String by lazy { cashTagMarkdownV2() }
|
||||
|
||||
@@ -18,7 +18,7 @@ data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
|
||||
val potentialUsername = source.dropWhile { it != '@' }
|
||||
if (potentialUsername.isEmpty()) return@lazy null
|
||||
|
||||
Username(potentialUsername)
|
||||
Username.prepare(potentialUsername)
|
||||
}
|
||||
|
||||
override val markdown: String by lazy { source.hashTagMarkdown() }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user