mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-27 08:29:19 +00:00
Compare commits
80 Commits
9.2.2
...
fc183bfd2f
| Author | SHA1 | Date | |
|---|---|---|---|
| fc183bfd2f | |||
| c025a027c6 | |||
| db2101d85c | |||
| a01a9910b5 | |||
| 4e1ecc0e34 | |||
| 90225a9380 | |||
| 3026c8708d | |||
| 63975cc88e | |||
| a622c4d6fa | |||
| e124bb18df | |||
| 152728afca | |||
| 38d672b665 | |||
| d2c299301a | |||
| 25fb6b2b46 | |||
| 5b5de5253c | |||
| 9a7dd6ec9a | |||
| 4085f721be | |||
| ffc915cae1 | |||
| a6c90b3df5 | |||
| a6d9fa6ce3 | |||
| 7fd2442f8b | |||
| 8b37ecea9e | |||
| 35fc9f60df | |||
| 68e89dc1ad | |||
| 129fb31b74 | |||
| a2c353ca41 | |||
| cb74abfce5 | |||
| ca7314923e | |||
| 74f625a53a | |||
| 3a5fed3dd9 | |||
| 6158143220 | |||
| f8182ddb85 | |||
| b7c3f9f607 | |||
| 8763ea23fa | |||
| b412e7b3b7 | |||
| 98e5d182bb | |||
| ffc0f5abb7 | |||
| 816cf00dac | |||
| e34bc7453e | |||
| 3b2ccbf33b | |||
| 6ecfbdf56d | |||
| b49e1c50f5 | |||
| d7389dfcfe | |||
| cf5cee3e53 | |||
| 8593263506 | |||
| 4422a4d09b | |||
| 9ecb50e377 | |||
| 8a4b40c6ec | |||
| bba667db30 | |||
| ca0d256bbb | |||
| dc2fd07632 | |||
| 32fe008eef | |||
| 2b938903b6 | |||
| 080db09d2c | |||
| 0efa52fe00 | |||
| c4214798e3 | |||
| fdf510153d | |||
| edb16d7107 | |||
| c49f400201 | |||
| db7de6edf8 | |||
| a0b14233e0 | |||
| 1a479706e2 | |||
| 2719e166a8 | |||
| 051684db23 | |||
| 805cec76ce | |||
| 899c195fd5 | |||
| f5937fc4d6 | |||
| 8cf7b349df | |||
| bf8f8b9e6f | |||
| edc0b1c492 | |||
| a85d58aac1 | |||
| 10860e1bb2 | |||
| 826c27874d | |||
| 4e917e8cf8 | |||
| 96ffae2062 | |||
| 4180721aed | |||
| 4ab0845333 | |||
| 3f9a4e95a3 | |||
| 834d60ff16 | |||
| 650d96974f |
3
.github/workflows/greetings.yml
vendored
3
.github/workflows/greetings.yml
vendored
@@ -5,6 +5,9 @@ on: [pull_request, issues]
|
|||||||
jobs:
|
jobs:
|
||||||
greeting:
|
greeting:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/first-interaction@v1
|
- uses: actions/first-interaction@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
2
.github/workflows/kdocs.yml
vendored
2
.github/workflows/kdocs.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-java@v1
|
- uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
java-version: 17
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew dokkaHtmlMultiModule
|
run: ./gradlew dokkaHtmlMultiModule
|
||||||
- name: Publish KDocs
|
- name: Publish KDocs
|
||||||
|
|||||||
9
.github/workflows/packages_publishing.yml
vendored
9
.github/workflows/packages_publishing.yml
vendored
@@ -7,9 +7,9 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-java@v1
|
- uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
java-version: 17
|
||||||
- name: Setup LibCurl
|
- name: Setup LibCurl
|
||||||
run: sudo apt install -y libcurl4-openssl-dev
|
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev
|
||||||
- name: Rewrite version
|
- name: Rewrite version
|
||||||
run: |
|
run: |
|
||||||
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
||||||
@@ -22,9 +22,10 @@ jobs:
|
|||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
- name: Publish to Gitea
|
- name: Publish to Gitea
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: ./gradlew publishAllPublicationsToGiteaRepository
|
run: ./gradlew publishAllPublicationsToInmoNexusRepository
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
INMONEXUS_USER: ${{ secrets.INMONEXUS_USER }}
|
||||||
|
INMONEXUS_PASSWORD: ${{ secrets.INMONEXUS_PASSWORD }}
|
||||||
- name: Publish to GithubPackages
|
- name: Publish to GithubPackages
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel
|
run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel
|
||||||
|
|||||||
61
CHANGELOG.md
61
CHANGELOG.md
@@ -1,5 +1,66 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 10.0.0
|
||||||
|
|
||||||
|
## 9.4.3
|
||||||
|
|
||||||
|
**IetfLanguageCode has been renamed to IetfLang in MicroUtils**
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.9.21` -> `1.9.22`
|
||||||
|
* `MicroUtils`: `0.20.19` -> `0.20.23`
|
||||||
|
|
||||||
|
## 9.4.2
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Serialization`: `1.6.1` -> `1.6.2`
|
||||||
|
* `Ktor`: `2.3.6` -> `2.3.7`
|
||||||
|
* `MicroUtils`: `0.20.15` -> `0.20.19`
|
||||||
|
* `UUID`: `0.8.1` -> `0.8.2`
|
||||||
|
|
||||||
|
## 9.4.1
|
||||||
|
|
||||||
|
* Replace warning about two bots from `LongPolling` to `DefaultKtorRequestsExecutor`
|
||||||
|
|
||||||
|
## 9.4.0
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.9.20` -> `1.9.21`
|
||||||
|
* `Serialization`: `1.6.0` -> `1.6.1`
|
||||||
|
* `Ktor`: `2.3.5` -> `2.3.6`
|
||||||
|
* `MicroUtils`: `0.20.12` -> `0.20.15`
|
||||||
|
|
||||||
|
## 9.3.0
|
||||||
|
|
||||||
|
This release become possible thanks to [Anton Lakotka](https://youtrack.jetbrains.com/users/anton.lakotka)
|
||||||
|
|
||||||
|
**THIS RELEASE CONTAINS UPDATES UP TO RELEASE CANDIDATES VERSIONS**
|
||||||
|
|
||||||
|
**UPDATE MAY HAVE BREAKING CHANGES**
|
||||||
|
|
||||||
|
**SINCE THIS UPDATE IT WILL BE REQUIRED TO USE JDK 17+ FOR DEVELOPMENT**
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Kotlin`: `1.8.22` -> `1.9.20`
|
||||||
|
* `Serialization`: `1.5.1` -> `1.6.0`
|
||||||
|
* `KorLibs`: `4.0.3` -> `4.0.10`
|
||||||
|
* `UUID`: `0.7.1` -> `0.8.1`
|
||||||
|
* `Ktor`: `2.3.4` -> `2.3.5`
|
||||||
|
* `MicroUtils`: `0.19.9` -> `0.20.12`
|
||||||
|
|
||||||
|
## 9.2.4
|
||||||
|
|
||||||
|
* `Utils`:
|
||||||
|
* New extensions `*.parseCommandsWithNamedArgs`
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* In expectaters and triggers of `commands` add `*WithNamedArgs` variants
|
||||||
|
* In expectaters and triggers of `commands` add opportunity to use custom separator
|
||||||
|
|
||||||
|
## 9.2.3
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Fix in `VoiceContent#createResend`
|
||||||
|
|
||||||
## 9.2.2
|
## 9.2.2
|
||||||
|
|
||||||
* `Core`:
|
* `Core`:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ buildscript {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.kotlin.dokka)
|
alias(libs.plugins.kotlin.dokka)
|
||||||
|
alias(libs.plugins.versions)
|
||||||
}
|
}
|
||||||
|
|
||||||
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
||||||
@@ -24,7 +25,7 @@ allprojects {
|
|||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
maven { url "https://git.inmo.dev/api/packages/InsanusMokrassar/maven" }
|
maven { url "https://nexus.inmo.dev/repository/maven-releases/" }
|
||||||
}
|
}
|
||||||
if (it != rootProject.findProject("docs")) {
|
if (it != rootProject.findProject("docs")) {
|
||||||
tasks.whenTaskAdded { task ->
|
tasks.whenTaskAdded { task ->
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Object callback = {
|
|||||||
|
|
||||||
sourceLink {
|
sourceLink {
|
||||||
localDirectory.set(file("../"))
|
localDirectory.set(file("../"))
|
||||||
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/"))
|
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/ktgbotapi/tree/master"))
|
||||||
remoteLineSuffix.set("#L")
|
remoteLineSuffix.set("#L")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=9.2.2
|
library_version=10.0.0
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "1.8.22"
|
kotlin = "1.9.22"
|
||||||
kotlin-serialization = "1.5.1"
|
kotlin-serialization = "1.6.2"
|
||||||
kotlin-coroutines = "1.7.3"
|
kotlin-coroutines = "1.7.3"
|
||||||
|
|
||||||
javax-activation = "1.1.1"
|
javax-activation = "1.1.1"
|
||||||
|
|
||||||
korlibs = "4.0.3"
|
korlibs = "4.0.10"
|
||||||
uuid = "0.7.1"
|
uuid = "0.8.2"
|
||||||
ktor = "2.3.4"
|
ktor = "2.3.7"
|
||||||
|
|
||||||
ksp = "1.8.22-1.0.11"
|
ksp = "1.9.22-1.0.16"
|
||||||
kotlin-poet = "1.14.2"
|
kotlin-poet = "1.15.3"
|
||||||
|
|
||||||
microutils = "0.19.9"
|
microutils = "0.20.23"
|
||||||
|
kslog = "1.3.1"
|
||||||
|
|
||||||
|
versions = "0.50.0"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
dokka = "1.8.20"
|
dokka = "1.9.10"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
||||||
@@ -52,6 +55,8 @@ microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", ver
|
|||||||
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
||||||
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
||||||
|
|
||||||
|
kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }
|
||||||
|
|
||||||
# ksp dependencies
|
# ksp dependencies
|
||||||
|
|
||||||
kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" }
|
kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" }
|
||||||
@@ -71,3 +76,4 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
|||||||
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||||
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||||
|
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ kotlin {
|
|||||||
jvm {
|
jvm {
|
||||||
compilations.main {
|
compilations.main {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "17"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
linuxX64()
|
linuxX64()
|
||||||
mingwX64()
|
mingwX64()
|
||||||
|
linuxArm64()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
@@ -40,10 +41,18 @@ kotlin {
|
|||||||
implementation libs.kotlin.test.junit
|
implementation libs.kotlin.test.junit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
all {
|
||||||
|
languageSettings {
|
||||||
|
optIn('dev.inmo.tgbotapi.utils.RiskFeature')
|
||||||
|
optIn('dev.inmo.tgbotapi.utils.PreviewFeature')
|
||||||
|
optIn('dev.inmo.micro_utils.common.Warning')
|
||||||
|
optIn('dev.inmo.micro_utils.common.PreviewFeature')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
task javadocsJar(type: Jar) {
|
task javadocsJar(type: Jar) {
|
||||||
archiveClassifier.convention("javadoc")
|
archiveClassifier = 'javadoc'
|
||||||
archiveClassifier.set("javadoc")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
@@ -20,22 +19,22 @@ publishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
|
|
||||||
developer {
|
developer {
|
||||||
id = "InsanusMokrassar"
|
id = "InsanusMokrassar"
|
||||||
name = "Ovsiannikov Aleksei"
|
name = "Ovsiannikov Aleksei"
|
||||||
email = "ovsyannikov.alexey95@gmail.com"
|
email = "ovsyannikov.alexey95@gmail.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
licenses {
|
licenses {
|
||||||
|
|
||||||
license {
|
license {
|
||||||
name = "Apache Software License 2.0"
|
name = "Apache Software License 2.0"
|
||||||
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
@@ -43,58 +42,77 @@ publishing {
|
|||||||
maven {
|
maven {
|
||||||
name = "GithubPackages"
|
name = "GithubPackages"
|
||||||
url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI")
|
url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI")
|
||||||
|
|
||||||
credentials {
|
credentials {
|
||||||
username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER')
|
username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER')
|
||||||
password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD')
|
password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) {
|
if ((project.hasProperty('INMONEXUS_USER') || System.getenv('INMONEXUS_USER') != null) && (project.hasProperty('INMONEXUS_PASSWORD') || System.getenv('INMONEXUS_PASSWORD') != null)) {
|
||||||
maven {
|
maven {
|
||||||
name = "Gitea"
|
name = "InmoNexus"
|
||||||
url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven")
|
url = uri("https://nexus.inmo.dev/repository/maven-releases/")
|
||||||
|
|
||||||
credentials(HttpHeaderCredentials) {
|
credentials {
|
||||||
name = "Authorization"
|
username = project.hasProperty('INMONEXUS_USER') ? project.property('INMONEXUS_USER') : System.getenv('INMONEXUS_USER')
|
||||||
value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN')
|
password = project.hasProperty('INMONEXUS_PASSWORD') ? project.property('INMONEXUS_PASSWORD') : System.getenv('INMONEXUS_PASSWORD')
|
||||||
}
|
}
|
||||||
|
|
||||||
authentication {
|
|
||||||
header(HttpHeaderAuthentication)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||||
maven {
|
maven {
|
||||||
name = "sonatype"
|
name = "sonatype"
|
||||||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
|
|
||||||
credentials {
|
credentials {
|
||||||
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
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')
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.hasProperty("signing.gnupg.keyName")) {
|
if (project.hasProperty("signing.gnupg.keyName")) {
|
||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
|
|
||||||
signing {
|
signing {
|
||||||
useGpgCmd()
|
useGpgCmd()
|
||||||
|
|
||||||
sign publishing.publications
|
sign publishing.publications
|
||||||
}
|
}
|
||||||
|
|
||||||
task signAll {
|
task signAll {
|
||||||
tasks.withType(Sign).forEach {
|
tasks.withType(Sign).forEach {
|
||||||
dependsOn(it)
|
dependsOn(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround to make android sign operations depend on signing tasks
|
||||||
|
project.getTasks().withType(AbstractPublishToMaven.class).configureEach {
|
||||||
|
def signingTasks = project.getTasks().withType(Sign.class)
|
||||||
|
mustRunAfter(signingTasks)
|
||||||
|
}
|
||||||
|
// Workaround to make test tasks use sign
|
||||||
|
project.getTasks().withType(Sign.class).configureEach { signTask ->
|
||||||
|
def withoutSign = (signTask.name.startsWith("sign") ? signTask.name.minus("sign") : signTask.name)
|
||||||
|
def pubName = withoutSign.endsWith("Publication") ? withoutSign.substring(0, withoutSign.length() - "Publication".length()) : withoutSign
|
||||||
|
// These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets
|
||||||
|
|
||||||
|
// Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
|
||||||
|
def debugTestTask = tasks.findByName("linkDebugTest$pubName")
|
||||||
|
if (debugTestTask != null) {
|
||||||
|
signTask.mustRunAfter(debugTestTask)
|
||||||
|
}
|
||||||
|
// Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
|
||||||
|
def testTask = tasks.findByName("compileTestKotlin$pubName")
|
||||||
|
if (testTask != null) {
|
||||||
|
signTask.mustRunAfter(testTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/TelegramBotAPI"},{"name":"Gitea","url":"https://git.inmo.dev/api/packages/InsanusMokrassar/maven","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.HttpHeaderCredentials","headerName":"Authorization","headerValueProperty":"GITEA_TOKEN"}},{"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/TelegramBotAPI"},{"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"}}}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.DeleteMessage
|
||||||
|
import dev.inmo.tgbotapi.requests.DeleteMessages
|
||||||
|
import dev.inmo.tgbotapi.requests.ForwardMessages
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun TelegramBot.deleteMessages(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageIds: List<MessageId>
|
||||||
|
) = messageIds.chunked(deleteMessagesLimit.last).map {
|
||||||
|
execute(
|
||||||
|
DeleteMessages(
|
||||||
|
chatId = chatId,
|
||||||
|
messageIds = it
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}.all { it }
|
||||||
|
|
||||||
|
suspend fun TelegramBot.deleteMessages(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageIds: Array<MessageId>
|
||||||
|
) = deleteMessages(
|
||||||
|
chatId = chatId,
|
||||||
|
messageIds = messageIds.toList()
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.deleteMessages(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
firstMessageId: MessageId,
|
||||||
|
vararg messageIds: MessageId
|
||||||
|
) = deleteMessages(
|
||||||
|
chatId = chatId,
|
||||||
|
messageIds = (listOf(firstMessageId) + messageIds.toList())
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.deleteMessages(
|
||||||
|
messages: List<Message>
|
||||||
|
) = messages.groupBy { it.chat }.map { (chat, messages) ->
|
||||||
|
deleteMessages(
|
||||||
|
chatId = chat.id,
|
||||||
|
messageIds = messages.map { it.messageId }
|
||||||
|
)
|
||||||
|
}.all { it }
|
||||||
|
|
||||||
|
suspend fun TelegramBot.delete(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageIds: List<MessageId>
|
||||||
|
) = deleteMessages(chatId = chatId, messageIds = messageIds)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.delete(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageIds: Array<MessageId>
|
||||||
|
) = deleteMessages(chatId = chatId, messageIds = messageIds)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.delete(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
firstMessageId: MessageId,
|
||||||
|
secondMessageId: MessageId,
|
||||||
|
vararg messageIds: MessageId
|
||||||
|
) = deleteMessages(chatId = chatId, messageIds = (listOf(firstMessageId, secondMessageId) + messageIds.toList()))
|
||||||
|
|
||||||
|
suspend fun TelegramBot.delete(
|
||||||
|
messages: List<Message>
|
||||||
|
) = deleteMessages(messages)
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.ForwardMessages
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forwardMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: List<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = messageIds.chunked(forwardMessagesLimit.last).flatMap {
|
||||||
|
execute(
|
||||||
|
ForwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = it,
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forwardMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: Array<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = forwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = messageIds.toList(),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forwardMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
firstMessageId: MessageId,
|
||||||
|
vararg messageIds: MessageId,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = forwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = (listOf(firstMessageId) + messageIds.toList()),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forwardMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messages: List<Message>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = messages.groupBy { it.chat }.flatMap { (chat, messages) ->
|
||||||
|
forwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = chat.id,
|
||||||
|
messageIds = messages.map { it.messageId },
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forward(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: List<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = forwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = messageIds,
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forward(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: Array<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = forwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = messageIds,
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forward(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
firstMessageId: MessageId,
|
||||||
|
vararg messageIds: MessageId,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = forwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
firstMessageId = firstMessageId,
|
||||||
|
messageIds = *messageIds,
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.forward(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messages: List<Message>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = forwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
messages = messages,
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands
|
import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
@@ -8,10 +8,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.deleteMyCommands(
|
suspend fun TelegramBot.deleteMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode?
|
languageCode: IetfLang?
|
||||||
) = execute(DeleteMyCommands(scope, languageCode))
|
) = execute(DeleteMyCommands(scope, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.deleteMyCommands(
|
suspend fun TelegramBot.deleteMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: String? = null
|
languageCode: String? = null
|
||||||
) = deleteMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
) = deleteMyCommands(scope, languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
@@ -8,10 +8,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.getMyCommands(
|
suspend fun TelegramBot.getMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyCommands(scope, languageCode))
|
) = execute(GetMyCommands(scope, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyCommands(
|
suspend fun TelegramBot.getMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
) = getMyCommands(scope, languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyDescription(
|
suspend fun TelegramBot.getMyDescription(
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyDescription(languageCode))
|
) = execute(GetMyDescription(languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyDescription(
|
suspend fun TelegramBot.getMyDescription(
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyDescription(languageCode ?.let(::IetfLanguageCode))
|
) = getMyDescription(languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyName(
|
suspend fun TelegramBot.getMyName(
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyName(languageCode))
|
) = execute(GetMyName(languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyName(
|
suspend fun TelegramBot.getMyName(
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyName(languageCode ?.let(::IetfLanguageCode))
|
) = getMyName(languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
|
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
|
||||||
@@ -8,9 +8,9 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyShortDescription(
|
suspend fun TelegramBot.getMyShortDescription(
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyShortDescription(languageCode))
|
) = execute(GetMyShortDescription(languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyShortDescription(
|
suspend fun TelegramBot.getMyShortDescription(
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyShortDescription(languageCode ?.let(::IetfLanguageCode))
|
) = getMyShortDescription(languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.SetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.SetMyCommands
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
@@ -10,20 +10,20 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
commands: List<BotCommand>,
|
commands: List<BotCommand>,
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode?
|
languageCode: IetfLang?
|
||||||
) = execute(SetMyCommands(commands, scope, languageCode))
|
) = execute(SetMyCommands(commands, scope, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
vararg commands: BotCommand,
|
vararg commands: BotCommand,
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode?
|
languageCode: IetfLang?
|
||||||
) = setMyCommands(commands.toList(), scope, languageCode)
|
) = setMyCommands(commands.toList(), scope, languageCode)
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
commands: List<BotCommand>,
|
commands: List<BotCommand>,
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: String? = null
|
languageCode: String? = null
|
||||||
) = setMyCommands(commands, scope, languageCode ?.let(::IetfLanguageCode))
|
) = setMyCommands(commands, scope, languageCode ?.let(::IetfLang))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
vararg commands: BotCommand,
|
vararg commands: BotCommand,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
||||||
@@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.setMyDescription(
|
suspend fun TelegramBot.setMyDescription(
|
||||||
description: String? = null,
|
description: String? = null,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(SetMyDescription(description, languageCode))
|
) = execute(SetMyDescription(description, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDescription(
|
suspend fun TelegramBot.setMyDescription(
|
||||||
description: String?,
|
description: String?,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = setMyDescription(description, languageCode ?.let(::IetfLanguageCode))
|
) = setMyDescription(description, languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||||
@@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.setMyName(
|
suspend fun TelegramBot.setMyName(
|
||||||
name: String? = null,
|
name: String? = null,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(SetMyName(name, languageCode))
|
) = execute(SetMyName(name, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyName(
|
suspend fun TelegramBot.setMyName(
|
||||||
name: String?,
|
name: String?,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = setMyName(name, languageCode ?.let(::IetfLanguageCode))
|
) = setMyName(name, languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
|
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyShortDescription(
|
suspend fun TelegramBot.setMyShortDescription(
|
||||||
shortDescription: String? = null,
|
shortDescription: String? = null,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(SetMyShortDescription(shortDescription, languageCode))
|
) = execute(SetMyShortDescription(shortDescription, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyShortDescription(
|
suspend fun TelegramBot.setMyShortDescription(
|
||||||
shortDescription: String?,
|
shortDescription: String?,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLanguageCode))
|
) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLang))
|
||||||
|
|||||||
@@ -194,9 +194,9 @@ suspend fun TelegramBot.edit(
|
|||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
) = editMessageText(chatId, messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -206,9 +206,9 @@ suspend fun TelegramBot.edit(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
|
) = editMessageText(chatId, messageId, entities, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -218,10 +218,10 @@ suspend fun TelegramBot.edit(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -231,10 +231,10 @@ suspend fun TelegramBot.edit(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -244,9 +244,9 @@ suspend fun TelegramBot.edit(
|
|||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = edit(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
) = edit(message.chat.id, message.messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -255,9 +255,9 @@ suspend fun TelegramBot.edit(
|
|||||||
suspend fun TelegramBot.edit(
|
suspend fun TelegramBot.edit(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
) = edit(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -266,10 +266,10 @@ suspend fun TelegramBot.edit(
|
|||||||
suspend fun TelegramBot.edit(
|
suspend fun TelegramBot.edit(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -278,10 +278,10 @@ suspend fun TelegramBot.edit(
|
|||||||
suspend fun TelegramBot.edit(
|
suspend fun TelegramBot.edit(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -290,10 +290,10 @@ suspend fun TelegramBot.edit(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -302,7 +302,7 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ suspend fun TelegramBot.edit(
|
|||||||
messageId: InlineMessageIdentifier,
|
messageId: InlineMessageIdentifier,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
) = editMessageText(messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -85,9 +85,9 @@ suspend fun TelegramBot.edit(
|
|||||||
suspend fun TelegramBot.edit(
|
suspend fun TelegramBot.edit(
|
||||||
messageId: InlineMessageIdentifier,
|
messageId: InlineMessageIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(messageId, entities, disableWebPagePreview, replyMarkup)
|
) = editMessageText(messageId, entities, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -96,10 +96,10 @@ suspend fun TelegramBot.edit(
|
|||||||
suspend fun TelegramBot.edit(
|
suspend fun TelegramBot.edit(
|
||||||
messageId: InlineMessageIdentifier,
|
messageId: InlineMessageIdentifier,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -108,7 +108,7 @@ suspend fun TelegramBot.edit(
|
|||||||
suspend fun TelegramBot.edit(
|
suspend fun TelegramBot.edit(
|
||||||
messageId: InlineMessageIdentifier,
|
messageId: InlineMessageIdentifier,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = edit(messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageId
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
@@ -23,10 +24,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
EditChatMessageText(chatId, messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,9 +39,9 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
) = editMessageText(chat.id, messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -50,9 +51,9 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
) = editMessageText(message.chat.id, message.messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -62,10 +63,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
|
EditChatMessageText(chatId, messageId, entities, linkPreviewOptions, replyMarkup)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,10 +77,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -89,10 +90,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -102,9 +103,9 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup)
|
) = editMessageText(chat.id, messageId, entities, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -114,10 +115,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -127,10 +128,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -139,9 +140,9 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
) = editMessageText(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -150,10 +151,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -162,10 +163,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: ContentMessage<TextContent>,
|
message: ContentMessage<TextContent>,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -175,9 +176,9 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: Message,
|
message: Message,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
) = editMessageText(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -187,10 +188,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: Message,
|
message: Message,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -200,7 +201,7 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
message: Message,
|
message: Message,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText
|
import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
@@ -18,9 +19,9 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))
|
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, linkPreviewOptions, replyMarkup))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -29,9 +30,9 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup))
|
) = execute(EditInlineMessageText(inlineMessageId, entities, linkPreviewOptions, replyMarkup))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -40,10 +41,10 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -52,7 +53,7 @@ suspend fun TelegramBot.editMessageText(
|
|||||||
suspend fun TelegramBot.editMessageText(
|
suspend fun TelegramBot.editMessageText(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null,
|
replyMarkup: InlineKeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.send.CopyMessages
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun TelegramBot.copyMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: List<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = messageIds.chunked(copyMessagesLimit.last).flatMap {
|
||||||
|
execute(
|
||||||
|
CopyMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = it,
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun TelegramBot.copyMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: Array<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = copyMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = messageIds.toList(),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.copyMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
firstMessageId: MessageId,
|
||||||
|
vararg messageIds: MessageId,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = copyMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = (listOf(firstMessageId) + messageIds.toList()),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.copyMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messages: List<Message>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = messages.groupBy { it.chat }.flatMap { (chat, messages) ->
|
||||||
|
copyMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = chat.id,
|
||||||
|
messageIds = messages.map { it.messageId },
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -176,7 +176,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
to: Message,
|
to: Message,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
@@ -185,7 +185,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
to.chat,
|
to.chat,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
to.threadIdOrNull,
|
to.threadIdOrNull,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@@ -201,7 +201,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
suspend inline fun TelegramBot.reply(
|
suspend inline fun TelegramBot.reply(
|
||||||
to: Message,
|
to: Message,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
@@ -209,7 +209,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
) = sendTextMessage(
|
) = sendTextMessage(
|
||||||
to.chat,
|
to.chat,
|
||||||
entities,
|
entities,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
to.threadIdOrNull,
|
to.threadIdOrNull,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@@ -225,13 +225,13 @@ suspend inline fun TelegramBot.reply(
|
|||||||
suspend fun TelegramBot.reply(
|
suspend fun TelegramBot.reply(
|
||||||
to: Message,
|
to: Message,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -240,13 +240,13 @@ suspend fun TelegramBot.reply(
|
|||||||
suspend fun TelegramBot.reply(
|
suspend fun TelegramBot.reply(
|
||||||
to: Message,
|
to: Message,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
// Venue
|
// Venue
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -197,7 +197,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
toChatId,
|
toChatId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
threadId,
|
threadId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@@ -214,7 +214,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
toChatId: IdChatIdentifier,
|
toChatId: IdChatIdentifier,
|
||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -223,7 +223,7 @@ suspend inline fun TelegramBot.reply(
|
|||||||
) = sendTextMessage(
|
) = sendTextMessage(
|
||||||
toChatId,
|
toChatId,
|
||||||
entities,
|
entities,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
threadId,
|
threadId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@@ -240,14 +240,14 @@ suspend fun TelegramBot.reply(
|
|||||||
toChatId: IdChatIdentifier,
|
toChatId: IdChatIdentifier,
|
||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -257,14 +257,14 @@ suspend fun TelegramBot.reply(
|
|||||||
toChatId: IdChatIdentifier,
|
toChatId: IdChatIdentifier,
|
||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
// Venue
|
// Venue
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -31,7 +31,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
chatId,
|
chatId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
threadId,
|
threadId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@@ -49,7 +49,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -57,7 +57,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendMessage(
|
) = sendMessage(
|
||||||
chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,14 +68,14 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,14 +86,14 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -102,7 +102,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
suspend fun TelegramBot.sendMessage(
|
suspend fun TelegramBot.sendMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -110,7 +110,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
SendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +120,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
suspend fun TelegramBot.sendMessage(
|
suspend fun TelegramBot.sendMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -128,7 +128,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,7 +138,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
suspend fun TelegramBot.sendMessage(
|
suspend fun TelegramBot.sendMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -146,7 +146,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -155,7 +155,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
suspend fun TelegramBot.sendTextMessage(
|
suspend fun TelegramBot.sendTextMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -163,7 +163,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendMessage(
|
) = sendMessage(
|
||||||
chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,7 +173,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
suspend fun TelegramBot.sendTextMessage(
|
suspend fun TelegramBot.sendTextMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -181,7 +181,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,7 +191,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
suspend fun TelegramBot.sendTextMessage(
|
suspend fun TelegramBot.sendTextMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -199,7 +199,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -208,14 +208,14 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
suspend fun TelegramBot.sendMessage(
|
suspend fun TelegramBot.sendMessage(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -224,7 +224,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
suspend fun TelegramBot.sendMessage(
|
suspend fun TelegramBot.sendMessage(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -232,7 +232,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +242,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
suspend fun TelegramBot.sendMessage(
|
suspend fun TelegramBot.sendMessage(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -250,7 +250,7 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -260,14 +260,14 @@ suspend fun TelegramBot.sendMessage(
|
|||||||
suspend fun TelegramBot.sendTextMessage(
|
suspend fun TelegramBot.sendTextMessage(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendTextMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -276,7 +276,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
suspend fun TelegramBot.sendTextMessage(
|
suspend fun TelegramBot.sendTextMessage(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -284,7 +284,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -294,7 +294,7 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
suspend fun TelegramBot.sendTextMessage(
|
suspend fun TelegramBot.sendTextMessage(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -302,4 +302,4 @@ suspend fun TelegramBot.sendTextMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|||||||
@@ -550,14 +550,14 @@ suspend fun TelegramBot.send(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendTextMessage(chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will execute [sendTextMessage] request
|
* Will execute [sendTextMessage] request
|
||||||
@@ -568,14 +568,14 @@ suspend fun TelegramBot.send(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendTextMessage(chat, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chat, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will execute [sendTextMessage] request
|
* Will execute [sendTextMessage] request
|
||||||
@@ -585,14 +585,14 @@ suspend fun TelegramBot.send(
|
|||||||
suspend fun TelegramBot.send(
|
suspend fun TelegramBot.send(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -601,7 +601,7 @@ suspend fun TelegramBot.send(
|
|||||||
suspend fun TelegramBot.send(
|
suspend fun TelegramBot.send(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -609,7 +609,7 @@ suspend fun TelegramBot.send(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -619,7 +619,7 @@ suspend fun TelegramBot.send(
|
|||||||
suspend fun TelegramBot.send(
|
suspend fun TelegramBot.send(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -627,7 +627,7 @@ suspend fun TelegramBot.send(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -638,14 +638,14 @@ suspend fun TelegramBot.send(
|
|||||||
suspend fun TelegramBot.send(
|
suspend fun TelegramBot.send(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendTextMessage(chat, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendTextMessage(chat, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
@@ -654,7 +654,7 @@ suspend fun TelegramBot.send(
|
|||||||
suspend fun TelegramBot.send(
|
suspend fun TelegramBot.send(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
separator: TextSource? = null,
|
separator: TextSource? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -662,7 +662,7 @@ suspend fun TelegramBot.send(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -672,7 +672,7 @@ suspend fun TelegramBot.send(
|
|||||||
suspend fun TelegramBot.send(
|
suspend fun TelegramBot.send(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
separator: String,
|
separator: String,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -680,7 +680,7 @@ suspend fun TelegramBot.send(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
builderBody: EntitiesBuilderBody
|
builderBody: EntitiesBuilderBody
|
||||||
) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will execute [sendPhoto] request
|
* Will execute [sendPhoto] request
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.send.SendAction
|
||||||
|
import dev.inmo.tgbotapi.requests.send.SetMessageReactions
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.actions.*
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||||
|
import dev.inmo.tgbotapi.types.threadId
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMessageReactions(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageId,
|
||||||
|
reactions: List<Reaction>,
|
||||||
|
big: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
SetMessageReactions(chatId, messageId, reactions, big)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMessageReaction(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageId,
|
||||||
|
reaction: Reaction?,
|
||||||
|
big: Boolean = false
|
||||||
|
) = setMessageReactions(chatId, messageId, listOfNotNull(reaction), big)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMessageReactions(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageId,
|
||||||
|
reactions: List<Reaction>,
|
||||||
|
big: Boolean = false
|
||||||
|
) = setMessageReactions(chat.id, messageId, reactions, big)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMessageReaction(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageId,
|
||||||
|
reaction: Reaction?,
|
||||||
|
big: Boolean = false
|
||||||
|
) = setMessageReaction(chat.id, messageId, reaction, big)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMessageReactions(
|
||||||
|
message: Message,
|
||||||
|
reactions: List<Reaction>,
|
||||||
|
big: Boolean = false
|
||||||
|
) = setMessageReactions(message.chat, message.messageId, reactions, big)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setMessageReaction(
|
||||||
|
message: Message,
|
||||||
|
reaction: Reaction?,
|
||||||
|
big: Boolean = false
|
||||||
|
) = setMessageReaction(message.chat, message.messageId, reaction, big)
|
||||||
@@ -13,6 +13,8 @@ kotlin {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
|
api project(":tgbotapi.core")
|
||||||
|
api project(":tgbotapi.utils")
|
||||||
api project(":tgbotapi.behaviour_builder")
|
api project(":tgbotapi.behaviour_builder")
|
||||||
api libs.microutils.fsm.common
|
api libs.microutils.fsm.common
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ kotlin {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(":tgbotapi.utils")
|
api project(path: ':tgbotapi.core')
|
||||||
|
api project(path: ':tgbotapi.utils')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||||
|
suspend inline fun <reified O : ChatMessageReactionUpdated> BehaviourContext.waitChatMessageReactionUpdated(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
): Flow<O> = expectFlow(
|
||||||
|
initRequest,
|
||||||
|
errorFactory
|
||||||
|
) {
|
||||||
|
(it.chatMessageReactionUpdatedUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitChatMessageReactionUpdatedByUser(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitChatMessageReactionUpdated<ChatMessageReactionUpdated.ByUser>(initRequest, errorFactory)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitChatMessageReactionUpdatedByChat(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitChatMessageReactionUpdated<ChatMessageReactionUpdated.ByChat>(initRequest, errorFactory)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionsCountUpdatedUpdateOrNull
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||||
|
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
suspend inline fun BehaviourContext.waitChatMessageReactionsCountUpdated(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
): Flow<ChatMessageReactionsCountUpdated> = expectFlow(
|
||||||
|
initRequest,
|
||||||
|
errorFactory
|
||||||
|
) {
|
||||||
|
(it.chatMessageReactionsCountUpdatedUpdateOrNull() ?.data).let(::listOfNotNull)
|
||||||
|
}
|
||||||
@@ -3,6 +3,10 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.TelegramBotCommandsDefaults
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithArgs
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithArgsSources
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithNamedArgs
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
@@ -79,35 +83,54 @@ fun Flow<CommonMessage<TextContent>>.requireCommandsWithoutParams() = filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map the commands with their arguments and source messages
|
* Uses [parseCommandsWithArgsSources] on incoming text sources and map them with [CommonMessage]
|
||||||
*/
|
*/
|
||||||
fun Flow<CommonMessage<TextContent>>.commandsWithParams(): Flow<Pair<CommonMessage<TextContent>, List<Pair<BotCommandTextSource, Array<TextSource>>>>> = mapNotNull {
|
fun Flow<CommonMessage<TextContent>>.commandsWithParams(): Flow<Pair<CommonMessage<TextContent>, List<Pair<BotCommandTextSource, Array<TextSource>>>>> = mapNotNull {
|
||||||
var currentCommandTextSource: BotCommandTextSource? = null
|
it to it.content.textSources.parseCommandsWithArgsSources().toList()
|
||||||
val currentArgs = mutableListOf<TextSource>()
|
|
||||||
val result = mutableListOf<Pair<BotCommandTextSource, Array<TextSource>>>()
|
|
||||||
|
|
||||||
fun addCurrentCommandToResult() {
|
|
||||||
currentCommandTextSource ?.let {
|
|
||||||
result.add(it to currentArgs.toTypedArray())
|
|
||||||
currentArgs.clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
it.content.textSources.forEach {
|
|
||||||
it.ifBotCommandTextSource {
|
|
||||||
addCurrentCommandToResult()
|
|
||||||
currentCommandTextSource = it
|
|
||||||
return@forEach
|
|
||||||
}
|
|
||||||
currentArgs.add(it)
|
|
||||||
}
|
|
||||||
addCurrentCommandToResult()
|
|
||||||
|
|
||||||
result.toList().takeIf { it.isNotEmpty() } ?.let { result ->
|
|
||||||
it to result
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses [parseCommandsWithArgs] on incoming text sources and map them with [CommonMessage]
|
||||||
|
*/
|
||||||
|
fun Flow<CommonMessage<TextContent>>.commandsWithArgs(
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex
|
||||||
|
): Flow<Pair<CommonMessage<TextContent>, List<Pair<String, Array<String>>>>> = mapNotNull {
|
||||||
|
val commandsWithArgs = it.content.textSources.parseCommandsWithArgs(argsSeparator).toList().ifEmpty {
|
||||||
|
return@mapNotNull null
|
||||||
|
}
|
||||||
|
|
||||||
|
it to commandsWithArgs
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses [parseCommandsWithArgs] on incoming text sources and map them with [CommonMessage]
|
||||||
|
*/
|
||||||
|
fun Flow<CommonMessage<TextContent>>.commandsWithArgs(
|
||||||
|
argsSeparator: String
|
||||||
|
): Flow<Pair<CommonMessage<TextContent>, List<Pair<String, Array<String>>>>> = commandsWithArgs(Regex(argsSeparator))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses [parseCommandsWithNamedArgs] on incoming text sources and map them with [CommonMessage]
|
||||||
|
*/
|
||||||
|
fun Flow<CommonMessage<TextContent>>.commandsWithNamedArgs(
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
): Flow<Pair<CommonMessage<TextContent>, List<Pair<String, List<Pair<String, String>>>>>> = mapNotNull {
|
||||||
|
val commandsWithArgs = it.content.textSources.parseCommandsWithNamedArgs(argsSeparator, nameArgSeparator).toList().ifEmpty {
|
||||||
|
return@mapNotNull null
|
||||||
|
}
|
||||||
|
|
||||||
|
it to commandsWithArgs
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses [parseCommandsWithNamedArgs] on incoming text sources and map them with [CommonMessage]
|
||||||
|
*/
|
||||||
|
fun Flow<CommonMessage<TextContent>>.commandsWithNamedArgs(
|
||||||
|
argsSeparator: String,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
): Flow<Pair<CommonMessage<TextContent>, List<Pair<String, List<Pair<String, String>>>>>> = commandsWithNamedArgs(Regex(argsSeparator), nameArgSeparator)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flat [commandsWithParams]. Each [Pair] of [BotCommandTextSource] and its [Array] of arg text sources will
|
* Flat [commandsWithParams]. Each [Pair] of [BotCommandTextSource] and its [Array] of arg text sources will
|
||||||
* be associated with its source message
|
* be associated with its source message
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
|||||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
@@ -202,7 +202,7 @@ suspend fun BehaviourContext.waitChatSharedRequest(
|
|||||||
suspend fun BehaviourContext.waitUserShared(
|
suspend fun BehaviourContext.waitUserShared(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEvents<UserShared>(initRequest, errorFactory)
|
) = waitEvents<UsersShared>(initRequest, errorFactory)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatShared(
|
suspend fun BehaviourContext.waitChatShared(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
|||||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
@@ -196,7 +196,7 @@ suspend fun BehaviourContext.waitChatSharedRequestEventsMessages(
|
|||||||
suspend fun BehaviourContext.waitUserSharedEventsMessages(
|
suspend fun BehaviourContext.waitUserSharedEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEventsMessages<UserShared>(initRequest, errorFactory)
|
) = waitEventsMessages<UsersShared>(initRequest, errorFactory)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatIdChatMessageReactionUpdatedMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull
|
||||||
|
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||||
|
import dev.inmo.tgbotapi.types.polls.*
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
|
internal suspend inline fun <BC : BehaviourContext, reified T : ChatMessageReactionUpdated> BC.onChatMessageReactionUpdated(
|
||||||
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
||||||
|
markerFactory: MarkerFactory<in T, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||||
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||||
|
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||||
|
(it.chatMessageReactionUpdatedUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onChatMessageReactionUpdatedByUser(
|
||||||
|
initialFilter: SimpleFilter<ChatMessageReactionUpdated.ByUser>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMessageReactionUpdated.ByUser, Update>? = null,
|
||||||
|
markerFactory: MarkerFactory<in ChatMessageReactionUpdated.ByUser, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMessageReactionUpdated.ByUser>
|
||||||
|
) = onChatMessageReactionUpdated(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onChatMessageReactionUpdatedByChat(
|
||||||
|
initialFilter: SimpleFilter<ChatMessageReactionUpdated.ByChat>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMessageReactionUpdated.ByChat, Update>? = null,
|
||||||
|
markerFactory: MarkerFactory<in ChatMessageReactionUpdated.ByChat, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMessageReactionUpdated.ByChat>
|
||||||
|
) = onChatMessageReactionUpdated(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onChatMessageReactionUpdatedUnknown(
|
||||||
|
initialFilter: SimpleFilter<ChatMessageReactionUpdated.Unknown>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMessageReactionUpdated.Unknown, Update>? = null,
|
||||||
|
markerFactory: MarkerFactory<in ChatMessageReactionUpdated.Unknown, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMessageReactionUpdated.Unknown>
|
||||||
|
) = onChatMessageReactionUpdated(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
@@ -11,7 +11,9 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByC
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
||||||
import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
|
import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
import dev.inmo.tgbotapi.extensions.utils.extensions.TelegramBotCommandsDefaults
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithArgs
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithNamedArgs
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
||||||
@@ -124,6 +126,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
) = command(
|
) = command(
|
||||||
commandRegex,
|
commandRegex,
|
||||||
@@ -132,7 +135,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
markerFactory = markerFactory
|
markerFactory = markerFactory
|
||||||
) {
|
) {
|
||||||
val args = it.parseCommandsWithParams().let { commandsWithArgs ->
|
val args = it.parseCommandsWithArgs(argsSeparator = argsSeparator).let { commandsWithArgs ->
|
||||||
val key = commandsWithArgs.keys.firstOrNull { it.matches(commandRegex) } ?: return@let null
|
val key = commandsWithArgs.keys.firstOrNull { it.matches(commandRegex) } ?: return@let null
|
||||||
commandsWithArgs[key]
|
commandsWithArgs[key]
|
||||||
} ?: emptyArray()
|
} ?: emptyArray()
|
||||||
@@ -144,12 +147,14 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
) = commandWithArgs(
|
) = commandWithArgs(
|
||||||
command.toRegex(),
|
command.toRegex(),
|
||||||
initialFilter = initialFilter,
|
initialFilter = initialFilter,
|
||||||
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
markerFactory = markerFactory,
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
scenarioReceiver = scenarioReceiver
|
scenarioReceiver = scenarioReceiver
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -158,12 +163,72 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
) = commandWithArgs(
|
) = commandWithArgs(
|
||||||
botCommand.command,
|
botCommand.command,
|
||||||
initialFilter = initialFilter,
|
initialFilter = initialFilter,
|
||||||
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
markerFactory = markerFactory,
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.commandWithNamedArgs(
|
||||||
|
commandRegex: Regex,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, List<Pair<String, String>>>
|
||||||
|
) = command(
|
||||||
|
commandRegex,
|
||||||
|
requireOnlyCommandInMessage = false,
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory
|
||||||
|
) {
|
||||||
|
val args = it.parseCommandsWithNamedArgs(argsSeparator = argsSeparator, nameArgSeparator = nameArgSeparator).let { commandsWithArgs ->
|
||||||
|
val key = commandsWithArgs.keys.firstOrNull { it.matches(commandRegex) } ?: return@let null
|
||||||
|
commandsWithArgs[key]
|
||||||
|
} ?: emptyList()
|
||||||
|
scenarioReceiver(it, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.commandWithNamedArgs(
|
||||||
|
command: String,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, List<Pair<String, String>>>
|
||||||
|
) = commandWithNamedArgs(
|
||||||
|
command.toRegex(),
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
nameArgSeparator = nameArgSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.commandWithNamedArgs(
|
||||||
|
botCommand: BotCommand,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, List<Pair<String, String>>>
|
||||||
|
) = commandWithNamedArgs(
|
||||||
|
botCommand.command,
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
nameArgSeparator = nameArgSeparator,
|
||||||
scenarioReceiver = scenarioReceiver
|
scenarioReceiver = scenarioReceiver
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -172,21 +237,99 @@ suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
|||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = commandWithArgs(
|
||||||
|
commandRegex = commandRegex,
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
command: String,
|
command: String,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommandWithArgs(
|
||||||
|
commandRegex = command.toRegex(),
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
botCommand: BotCommand,
|
botCommand: BotCommand,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
): Job = onCommandWithArgs(botCommand.command, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommandWithArgs(
|
||||||
|
command = botCommand.command,
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onCommandWithNamedArgs(
|
||||||
|
commandRegex: Regex,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, List<Pair<String, String>>>
|
||||||
|
) = commandWithNamedArgs(
|
||||||
|
commandRegex,
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
nameArgSeparator = nameArgSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver,
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onCommandWithNamedArgs(
|
||||||
|
command: String,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, List<Pair<String, String>>>
|
||||||
|
) = onCommandWithNamedArgs(
|
||||||
|
command.toRegex(),
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
nameArgSeparator = nameArgSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onCommandWithNamedArgs(
|
||||||
|
botCommand: BotCommand,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
argsSeparator: Regex = TelegramBotCommandsDefaults.defaultArgsSeparatorRegex,
|
||||||
|
nameArgSeparator: Regex = TelegramBotCommandsDefaults.defaultNamesArgsSeparatorRegex,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, List<Pair<String, String>>>
|
||||||
|
) = onCommandWithNamedArgs(
|
||||||
|
botCommand.command,
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory,
|
||||||
|
argsSeparator = argsSeparator,
|
||||||
|
nameArgSeparator = nameArgSeparator,
|
||||||
|
scenarioReceiver = scenarioReceiver
|
||||||
|
)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByC
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
||||||
import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
|
import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithArgs
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
@@ -65,7 +65,7 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
|||||||
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
markerFactory = markerFactory
|
markerFactory = markerFactory
|
||||||
) {
|
) {
|
||||||
val args = it.parseCommandsWithParams().let { commandsWithArgs ->
|
val args = it.parseCommandsWithArgs().let { commandsWithArgs ->
|
||||||
commandsWithArgs
|
commandsWithArgs
|
||||||
}
|
}
|
||||||
scenarioReceiver(it, args)
|
scenarioReceiver(it, args)
|
||||||
|
|||||||
@@ -4,22 +4,18 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.*
|
import dev.inmo.micro_utils.coroutines.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitDeepLinks
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.RegularTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.RegularTextSource
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import io.ktor.http.decodeURLQueryComponent
|
import io.ktor.http.decodeURLQueryComponent
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.filter
|
|
||||||
|
|
||||||
private val startRegex = Regex("start")
|
private val startRegex = Regex("start")
|
||||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage
|
|||||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
||||||
@@ -776,10 +776,10 @@ suspend fun <BC : BehaviourContext> BC.onChatSharedRequest(
|
|||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onUserShared(
|
suspend fun <BC : BehaviourContext> BC.onUserShared(
|
||||||
initialFilter: SimpleFilter<PrivateEventMessage<UserShared>>? = null,
|
initialFilter: SimpleFilter<PrivateEventMessage<UsersShared>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<UserShared>, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<UsersShared>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ChatEventMessage<UserShared>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ChatEventMessage<UsersShared>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<UserShared>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<UsersShared>>
|
||||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||||
|
|
||||||
|
object ByChatIdChatMessageReactionUpdatedMarkerFactory : MarkerFactory<ChatMessageReactionUpdated, Any> {
|
||||||
|
override suspend fun invoke(data: ChatMessageReactionUpdated) = data.chat.id
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
|
||||||
|
actual var defaultCoroutineScopeProvider: () -> CoroutineScope = { CoroutineScope(Dispatchers.Default) }
|
||||||
@@ -31,6 +31,8 @@ kotlin {
|
|||||||
api libs.microutils.languageCodes
|
api libs.microutils.languageCodes
|
||||||
|
|
||||||
api libs.ktor.client.core
|
api libs.ktor.client.core
|
||||||
|
|
||||||
|
api libs.kslog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commonTest {
|
commonTest {
|
||||||
@@ -55,6 +57,12 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linuxArm64Main {
|
||||||
|
dependencies {
|
||||||
|
api libs.ktor.client.cio
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mingwX64Main {
|
mingwX64Main {
|
||||||
dependencies {
|
dependencies {
|
||||||
api libs.ktor.client.winhttp
|
api libs.ktor.client.winhttp
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.abstracts.types
|
|
||||||
|
|
||||||
interface DisableWebPagePreview {
|
|
||||||
val disableWebPagePreview: Boolean?
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package dev.inmo.tgbotapi.abstracts.types
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||||
|
|
||||||
|
interface LinkPreviewOptionsContainer {
|
||||||
|
val linkPreviewOptions: LinkPreviewOptions?
|
||||||
|
val disableWebPagePreview: Boolean?
|
||||||
|
get() = linkPreviewOptions ?.isDisabled != true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("LinkPreviewOptionsContainer", "dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer"))
|
||||||
|
typealias DisableWebPagePreview = LinkPreviewOptionsContainer
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.tgbotapi.abstracts.types
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
|
|
||||||
|
interface MessagesAction: ChatRequest {
|
||||||
|
val messageIds: List<MessageId>
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor
|
package dev.inmo.tgbotapi.bot.ktor
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
|
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
@@ -14,12 +16,35 @@ import kotlinx.serialization.json.Json
|
|||||||
* * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor]
|
* * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor]
|
||||||
* * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor]
|
* * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor]
|
||||||
*/
|
*/
|
||||||
expect class KtorRequestsExecutor (
|
expect class KtorRequestsExecutor internal constructor(
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
client: HttpClient,
|
||||||
|
callsFactories: List<KtorCallFactory>,
|
||||||
|
excludeDefaultFactories: Boolean,
|
||||||
|
requestsLimiter: RequestLimiter,
|
||||||
|
jsonFormatter: Json,
|
||||||
|
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
|
logger: KSLog,
|
||||||
|
diff: Unit // just a diff property to know where constructor and where calling function with defaults
|
||||||
|
) : BaseRequestsExecutor
|
||||||
|
|
||||||
|
fun KtorRequestsExecutor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient(),
|
client: HttpClient = HttpClient(),
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean = false,
|
||||||
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||||
jsonFormatter: Json = nonstrictJsonFormat,
|
jsonFormatter: Json = nonstrictJsonFormat,
|
||||||
pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder,
|
||||||
) : BaseRequestsExecutor
|
logger: KSLog = DefaultKTgBotAPIKSLog,
|
||||||
|
) = KtorRequestsExecutor(
|
||||||
|
telegramAPIUrlsKeeper = telegramAPIUrlsKeeper,
|
||||||
|
client = client,
|
||||||
|
callsFactories = callsFactories,
|
||||||
|
excludeDefaultFactories = excludeDefaultFactories,
|
||||||
|
requestsLimiter = requestsLimiter,
|
||||||
|
jsonFormatter = jsonFormatter,
|
||||||
|
pipelineStepsHolder = pipelineStepsHolder,
|
||||||
|
logger = logger,
|
||||||
|
diff = kotlin.Unit,
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor
|
package dev.inmo.tgbotapi.bot.ktor
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.bot.ktor.base.*
|
import dev.inmo.tgbotapi.bot.ktor.base.*
|
||||||
@@ -10,9 +11,9 @@ import io.ktor.client.HttpClient
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
@RiskFeature
|
@RiskFeature
|
||||||
fun createTelegramBotDefaultKtorCallRequestsFactories() = listOf(
|
fun createTelegramBotDefaultKtorCallRequestsFactories(logger: KSLog? = null) = listOf(
|
||||||
SimpleRequestCallFactory(),
|
SimpleRequestCallFactory(logger),
|
||||||
MultipartRequestCallFactory(),
|
MultipartRequestCallFactory(logger),
|
||||||
DownloadFileRequestCallFactory,
|
DownloadFileRequestCallFactory,
|
||||||
DownloadFileChannelRequestCallFactory
|
DownloadFileChannelRequestCallFactory
|
||||||
)
|
)
|
||||||
@@ -25,6 +26,8 @@ class KtorRequestsExecutorBuilder(
|
|||||||
var excludeDefaultFactories: Boolean = false
|
var excludeDefaultFactories: Boolean = false
|
||||||
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter
|
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter
|
||||||
var jsonFormatter: Json = nonstrictJsonFormat
|
var jsonFormatter: Json = nonstrictJsonFormat
|
||||||
|
var logger: KSLog = DefaultKTgBotAPIKSLog
|
||||||
|
var pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||||
|
|
||||||
fun build() = KtorRequestsExecutor(
|
fun build() = KtorRequestsExecutor(
|
||||||
telegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper,
|
||||||
@@ -32,7 +35,9 @@ class KtorRequestsExecutorBuilder(
|
|||||||
callsFactories,
|
callsFactories,
|
||||||
excludeDefaultFactories,
|
excludeDefaultFactories,
|
||||||
requestsLimiter,
|
requestsLimiter,
|
||||||
jsonFormatter
|
jsonFormatter,
|
||||||
|
pipelineStepsHolder,
|
||||||
|
logger
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,30 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
|
import dev.inmo.kslog.common.v
|
||||||
|
import dev.inmo.kslog.common.w
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.requests.GetUpdatesRequest
|
import dev.inmo.tgbotapi.requests.GetUpdatesRequest
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.Response
|
import dev.inmo.tgbotapi.types.Response
|
||||||
|
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.plugins.timeout
|
import io.ktor.client.plugins.timeout
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.bodyAsText
|
import io.ktor.client.statement.bodyAsText
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
var defaultUpdateTimeoutForZeroDelay = 1000L
|
var defaultUpdateTimeoutForZeroDelay = 1000L
|
||||||
|
|
||||||
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
abstract class AbstractRequestCallFactory(
|
||||||
|
protected open val logger: KSLog = DefaultKTgBotAPIKSLog
|
||||||
|
) : KtorCallFactory {
|
||||||
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
||||||
override suspend fun <T : Any> makeCall(
|
override suspend fun <T : Any> makeCall(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
@@ -26,6 +33,7 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
jsonFormatter: Json
|
jsonFormatter: Json
|
||||||
): T? {
|
): T? {
|
||||||
val preparedBody = prepareCallBody(client, urlsKeeper, request) ?: return null
|
val preparedBody = prepareCallBody(client, urlsKeeper, request) ?: return null
|
||||||
|
logger.v { "Prepared body for $request: $preparedBody" }
|
||||||
|
|
||||||
client.post {
|
client.post {
|
||||||
url(
|
url(
|
||||||
@@ -54,7 +62,9 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
setBody(preparedBody)
|
setBody(preparedBody)
|
||||||
}.let { response ->
|
}.let { response ->
|
||||||
val content = response.bodyAsText()
|
val content = response.bodyAsText()
|
||||||
|
logger.v { "Raw answer for $request: $content" }
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||||
|
logger.v { "Answer as json for $request: $responseObject" }
|
||||||
|
|
||||||
return runCatchingSafely {
|
return runCatchingSafely {
|
||||||
(responseObject.result?.let {
|
(responseObject.result?.let {
|
||||||
@@ -66,6 +76,8 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
"Can't get result object from $content"
|
"Can't get result object from $content"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
}.onFailure {
|
||||||
|
logger.w { "Got exception answer for $request: $it" }
|
||||||
}.getOrThrow()
|
}.getOrThrow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.*
|
||||||
|
import dev.inmo.micro_utils.coroutines.defaultSafelyExceptionHandler
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.BotException
|
import dev.inmo.tgbotapi.bot.exceptions.BotException
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
||||||
|
import dev.inmo.tgbotapi.bot.exceptions.GetUpdatesConflict
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories
|
import dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
@@ -19,19 +23,23 @@ import io.ktor.client.plugins.*
|
|||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
class DefaultKtorRequestsExecutor(
|
class DefaultKtorRequestsExecutor internal constructor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient(),
|
client: HttpClient,
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory>,
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean,
|
||||||
private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
private val requestsLimiter: RequestLimiter,
|
||||||
private val jsonFormatter: Json = nonstrictJsonFormat,
|
private val jsonFormatter: Json,
|
||||||
private val pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
private val pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
|
private val logger: KSLog,
|
||||||
|
diff: Unit
|
||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||||
if (!excludeDefaultFactories) {
|
if (!excludeDefaultFactories) {
|
||||||
this + createTelegramBotDefaultKtorCallRequestsFactories()
|
logger.v { "Installing default factories" }
|
||||||
|
this + createTelegramBotDefaultKtorCallRequestsFactories(logger)
|
||||||
} else {
|
} else {
|
||||||
|
logger.v { "Default factories will not be installed" }
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,19 +52,23 @@ class DefaultKtorRequestsExecutor(
|
|||||||
|
|
||||||
override suspend fun <T : Any> execute(request: Request<T>): T {
|
override suspend fun <T : Any> execute(request: Request<T>): T {
|
||||||
return runCatchingSafely {
|
return runCatchingSafely {
|
||||||
|
logger.v { "Start request $request" }
|
||||||
pipelineStepsHolder.onBeforeSearchCallFactory(request, callsFactories)
|
pipelineStepsHolder.onBeforeSearchCallFactory(request, callsFactories)
|
||||||
requestsLimiter.limit(request) {
|
requestsLimiter.limit(request) {
|
||||||
var result: T? = null
|
var result: T? = null
|
||||||
lateinit var factoryHandledRequest: KtorCallFactory
|
lateinit var factoryHandledRequest: KtorCallFactory
|
||||||
for (potentialFactory in callsFactories) {
|
for (potentialFactory in callsFactories) {
|
||||||
pipelineStepsHolder.onBeforeCallFactoryMakeCall(request, potentialFactory)
|
pipelineStepsHolder.onBeforeCallFactoryMakeCall(request, potentialFactory)
|
||||||
result = potentialFactory.makeCall(
|
logger.v { "Trying factory $potentialFactory for $request" }
|
||||||
|
val resultFromFactory = potentialFactory.makeCall(
|
||||||
client,
|
client,
|
||||||
telegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper,
|
||||||
request,
|
request,
|
||||||
jsonFormatter
|
jsonFormatter
|
||||||
)
|
)
|
||||||
result = pipelineStepsHolder.onAfterCallFactoryMakeCall(result, request, potentialFactory)
|
logger.v { "Result of factory $potentialFactory handling $request: $resultFromFactory" }
|
||||||
|
result = pipelineStepsHolder.onAfterCallFactoryMakeCall(resultFromFactory, request, potentialFactory)
|
||||||
|
logger.v { "Result of pipeline $pipelineStepsHolder handling $resultFromFactory: $result" }
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
factoryHandledRequest = potentialFactory
|
factoryHandledRequest = potentialFactory
|
||||||
break
|
break
|
||||||
@@ -69,6 +81,7 @@ class DefaultKtorRequestsExecutor(
|
|||||||
}
|
}
|
||||||
}.let {
|
}.let {
|
||||||
val result = it.exceptionOrNull() ?.let { e ->
|
val result = it.exceptionOrNull() ?.let { e ->
|
||||||
|
logger.v(e) { "Got exception on handling of $request" }
|
||||||
pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it }
|
pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it }
|
||||||
|
|
||||||
when (e) {
|
when (e) {
|
||||||
@@ -88,9 +101,18 @@ class DefaultKtorRequestsExecutor(
|
|||||||
}
|
}
|
||||||
is BotException -> e
|
is BotException -> e
|
||||||
else -> CommonBotException(cause = e)
|
else -> CommonBotException(cause = e)
|
||||||
|
}.also { newException ->
|
||||||
|
logger.v(newException) { "Result exception on handling of $request is an exception" }
|
||||||
|
if (newException is GetUpdatesConflict) {
|
||||||
|
logger.w(newException) {
|
||||||
|
"Warning!!! Other bot with the same bot token requests updates with getUpdate in parallel"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} ?.let { Result.failure(it) } ?: it
|
} ?.let { Result.failure(it) } ?: it
|
||||||
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories)
|
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories).also {
|
||||||
|
logger.v { "Result of handling $request: $it" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
|||||||
import dev.inmo.tgbotapi.requests.DownloadFileStream
|
import dev.inmo.tgbotapi.requests.DownloadFileStream
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.utils.ByteReadChannelAllocator
|
import dev.inmo.tgbotapi.utils.ByteReadChannelAllocator
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.receive
|
import io.ktor.client.call.receive
|
||||||
@@ -15,6 +16,7 @@ import io.ktor.utils.io.*
|
|||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
@RiskFeature
|
||||||
object DownloadFileChannelRequestCallFactory : KtorCallFactory {
|
object DownloadFileChannelRequestCallFactory : KtorCallFactory {
|
||||||
override suspend fun <T : Any> makeCall(
|
override suspend fun <T : Any> makeCall(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import dev.inmo.micro_utils.coroutines.safely
|
|||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.requests.DownloadFile
|
import dev.inmo.tgbotapi.requests.DownloadFile
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.statement.readBytes
|
import io.ktor.client.statement.readBytes
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
@RiskFeature
|
||||||
object DownloadFileRequestCallFactory : KtorCallFactory {
|
object DownloadFileRequestCallFactory : KtorCallFactory {
|
||||||
override suspend fun <T : Any> makeCall(
|
override suspend fun <T : Any> makeCall(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import dev.inmo.tgbotapi.utils.mapWithCommonValues
|
import dev.inmo.tgbotapi.utils.mapWithCommonValues
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
@@ -8,7 +10,7 @@ import io.ktor.client.request.forms.*
|
|||||||
import io.ktor.http.Headers
|
import io.ktor.http.Headers
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
|
|
||||||
class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
class MultipartRequestCallFactory(logger: KSLog? = null) : AbstractRequestCallFactory(logger ?: DefaultKTgBotAPIKSLog) {
|
||||||
override fun <T : Any> prepareCallBody(
|
override fun <T : Any> prepareCallBody(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||||
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
@@ -45,6 +49,7 @@ class MultipleClientKtorRequestsExecutor (
|
|||||||
jsonFormatter: Json,
|
jsonFormatter: Json,
|
||||||
pipelineStepsHolder: KtorPipelineStepsHolder,
|
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
requestExecutorsCount: Int,
|
requestExecutorsCount: Int,
|
||||||
|
logger: KSLog,
|
||||||
clientFactory: () -> HttpClient
|
clientFactory: () -> HttpClient
|
||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
private val requestExecutors = (0 until requestExecutorsCount).map {
|
private val requestExecutors = (0 until requestExecutorsCount).map {
|
||||||
@@ -55,7 +60,9 @@ class MultipleClientKtorRequestsExecutor (
|
|||||||
excludeDefaultFactories,
|
excludeDefaultFactories,
|
||||||
requestsLimiter,
|
requestsLimiter,
|
||||||
jsonFormatter,
|
jsonFormatter,
|
||||||
pipelineStepsHolder
|
pipelineStepsHolder,
|
||||||
|
logger,
|
||||||
|
Unit
|
||||||
)
|
)
|
||||||
}.toSet()
|
}.toSet()
|
||||||
private val freeClients = MutableStateFlow<Set<DefaultKtorRequestsExecutor>>(requestExecutors)
|
private val freeClients = MutableStateFlow<Set<DefaultKtorRequestsExecutor>>(requestExecutors)
|
||||||
@@ -68,14 +75,16 @@ class MultipleClientKtorRequestsExecutor (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
internal constructor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
callsFactories: List<KtorCallFactory>,
|
callsFactories: List<KtorCallFactory>,
|
||||||
excludeDefaultFactories: Boolean,
|
excludeDefaultFactories: Boolean,
|
||||||
requestsLimiter: RequestLimiter,
|
requestsLimiter: RequestLimiter,
|
||||||
jsonFormatter: Json,
|
jsonFormatter: Json,
|
||||||
pipelineStepsHolder: KtorPipelineStepsHolder
|
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
|
logger: KSLog,
|
||||||
|
diff: Unit
|
||||||
) : this(
|
) : this(
|
||||||
telegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper,
|
||||||
callsFactories,
|
callsFactories,
|
||||||
@@ -84,6 +93,7 @@ class MultipleClientKtorRequestsExecutor (
|
|||||||
jsonFormatter,
|
jsonFormatter,
|
||||||
pipelineStepsHolder,
|
pipelineStepsHolder,
|
||||||
client.engineConfig.threadsCount,
|
client.engineConfig.threadsCount,
|
||||||
|
logger,
|
||||||
{ platformClientCopy(client) }
|
{ platformClientCopy(client) }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.content.TextContent
|
import io.ktor.http.content.TextContent
|
||||||
|
|
||||||
class SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
class SimpleRequestCallFactory(logger: KSLog? = null) : AbstractRequestCallFactory(logger ?: DefaultKTgBotAPIKSLog) {
|
||||||
override fun <T : Any> prepareCallBody(
|
override fun <T : Any> prepareCallBody(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.MessageAction
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.MessagesAction
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class DeleteMessages(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageIdsField)
|
||||||
|
override val messageIds: List<MessageId>
|
||||||
|
) : SimpleRequest<Boolean>, MessagesAction {
|
||||||
|
override fun method(): String = "deleteMessages"
|
||||||
|
|
||||||
|
init {
|
||||||
|
require(messageIds.size in deleteMessagesLimit) {
|
||||||
|
"Messages count for deleteMessages must be in $deleteMessagesLimit range"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = Boolean.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.DisableNotification
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.MessagesAction
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
|
fun ForwardMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: Array<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = ForwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = messageIds.toList(),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
fun ForwardMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageId,
|
||||||
|
vararg messageIds: MessageId,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = ForwardMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = (listOf(messageId) + messageIds.toList()),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ForwardMessages (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
val toChatId: ChatIdentifier,
|
||||||
|
@SerialName(fromChatIdField)
|
||||||
|
val fromChatId: ChatIdentifier,
|
||||||
|
@SerialName(messageIdsField)
|
||||||
|
override val messageIds: List<MessageId>,
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
override val threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
@SerialName(disableNotificationField)
|
||||||
|
override val disableNotification: Boolean = false,
|
||||||
|
@SerialName(protectContentField)
|
||||||
|
override val protectContent: Boolean = false,
|
||||||
|
@SerialName(removeCaptionField)
|
||||||
|
private val removeCaption: Boolean = false
|
||||||
|
): SimpleRequest<List<MessageId>>,
|
||||||
|
MessagesAction,
|
||||||
|
ProtectContent,
|
||||||
|
OptionallyMessageThreadRequest,
|
||||||
|
DisableNotification {
|
||||||
|
override val chatId: ChatIdentifier
|
||||||
|
get() = fromChatId
|
||||||
|
|
||||||
|
init {
|
||||||
|
require(messageIds.size in forwardMessagesLimit) {
|
||||||
|
"Messages count for forwardMessages must be in $forwardMessagesLimit range"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun method(): String = "forwardMessages"
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<List<MessageId>>
|
||||||
|
get() = ListSerializer(MessageIdSerializer)
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.commands.*
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
import dev.inmo.tgbotapi.types.languageCodeField
|
import dev.inmo.tgbotapi.types.languageCodeField
|
||||||
import dev.inmo.tgbotapi.types.scopeField
|
import dev.inmo.tgbotapi.types.scopeField
|
||||||
@@ -14,8 +15,8 @@ data class DeleteMyCommands(
|
|||||||
@Serializable(BotCommandScopeSerializer::class)
|
@Serializable(BotCommandScopeSerializer::class)
|
||||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : MyCommandsRequest<Boolean> {
|
) : MyCommandsRequest<Boolean> {
|
||||||
override fun method(): String = "deleteMyCommands"
|
override fun method(): String = "deleteMyCommands"
|
||||||
override val requestSerializer: SerializationStrategy<DeleteMyCommands>
|
override val requestSerializer: SerializationStrategy<DeleteMyCommands>
|
||||||
@@ -28,7 +29,7 @@ data class DeleteMyCommands(
|
|||||||
languageCode: String?
|
languageCode: String?
|
||||||
) : this(
|
) : this(
|
||||||
scope,
|
scope,
|
||||||
languageCode ?.let(::IetfLanguageCode)
|
languageCode ?.let(::IetfLang)
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object : MyCommandsRequest<Boolean> by DeleteMyCommands()
|
companion object : MyCommandsRequest<Boolean> by DeleteMyCommands()
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.commands.*
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -15,8 +16,8 @@ data class GetMyCommands(
|
|||||||
@Serializable(BotCommandScopeSerializer::class)
|
@Serializable(BotCommandScopeSerializer::class)
|
||||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : MyCommandsRequest<List<BotCommand>> {
|
) : MyCommandsRequest<List<BotCommand>> {
|
||||||
override fun method(): String = "getMyCommands"
|
override fun method(): String = "getMyCommands"
|
||||||
override val resultDeserializer: DeserializationStrategy<List<BotCommand>>
|
override val resultDeserializer: DeserializationStrategy<List<BotCommand>>
|
||||||
@@ -29,7 +30,7 @@ data class GetMyCommands(
|
|||||||
languageCode: String?
|
languageCode: String?
|
||||||
) : this(
|
) : this(
|
||||||
scope,
|
scope,
|
||||||
languageCode ?.let(::IetfLanguageCode)
|
languageCode ?.let(::IetfLang)
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object : MyCommandsRequest<List<BotCommand>> by GetMyCommands()
|
companion object : MyCommandsRequest<List<BotCommand>> by GetMyCommands()
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@@ -12,8 +13,8 @@ import kotlinx.serialization.builtins.serializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
class GetMyDescription(
|
class GetMyDescription(
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<BotDescription>, WithOptionalLanguageCode {
|
) : SimpleRequest<BotDescription>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "getMyDescription"
|
override fun method(): String = "getMyDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<BotDescription>
|
override val resultDeserializer: DeserializationStrategy<BotDescription>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@@ -12,8 +13,8 @@ import kotlinx.serialization.builtins.serializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
class GetMyName(
|
class GetMyName(
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<BotName>, WithOptionalLanguageCode {
|
) : SimpleRequest<BotName>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "getMyName"
|
override fun method(): String = "getMyName"
|
||||||
override val resultDeserializer: DeserializationStrategy<BotName>
|
override val resultDeserializer: DeserializationStrategy<BotName>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@@ -12,8 +13,8 @@ import kotlinx.serialization.builtins.serializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
class GetMyShortDescription(
|
class GetMyShortDescription(
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<BotShortDescription>, WithOptionalLanguageCode {
|
) : SimpleRequest<BotShortDescription>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "getMyShortDescription"
|
override fun method(): String = "getMyShortDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<BotShortDescription>
|
override val resultDeserializer: DeserializationStrategy<BotShortDescription>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.commands.*
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -15,8 +16,8 @@ class SetMyCommands(
|
|||||||
@Serializable(BotCommandScopeSerializer::class)
|
@Serializable(BotCommandScopeSerializer::class)
|
||||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : MyCommandsRequest<Boolean> {
|
) : MyCommandsRequest<Boolean> {
|
||||||
override fun method(): String = "setMyCommands"
|
override fun method(): String = "setMyCommands"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
@@ -31,7 +32,7 @@ class SetMyCommands(
|
|||||||
) : this(
|
) : this(
|
||||||
commands,
|
commands,
|
||||||
scope,
|
scope,
|
||||||
languageCode ?.let(::IetfLanguageCode)
|
languageCode ?.let(::IetfLang)
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@@ -14,8 +14,8 @@ class SetMyDescription(
|
|||||||
@SerialName(descriptionField)
|
@SerialName(descriptionField)
|
||||||
val description: String? = null,
|
val description: String? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "setMyDescription"
|
override fun method(): String = "setMyDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@@ -14,8 +14,8 @@ class SetMyName(
|
|||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "setMyName"
|
override fun method(): String = "setMyName"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@@ -14,8 +14,8 @@ class SetMyShortDescription(
|
|||||||
@SerialName(shortDescriptionField)
|
@SerialName(shortDescriptionField)
|
||||||
val shortDescription: String? = null,
|
val shortDescription: String? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "setMyShortDescription"
|
override fun method(): String = "setMyShortDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.edit.abstracts
|
|
||||||
|
|
||||||
interface EditDisableWebPagePreviewMessage {
|
|
||||||
val disableWebPagePreview: Boolean?
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.edit.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer
|
||||||
|
|
||||||
|
interface EditLinkPreviewOptionsContainer : LinkPreviewOptionsContainer
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("EditLinkPreviewOptionsContainer", "dev.inmo.tgbotapi.requests.edit.abstracts.EditLinkPreviewOptionsContainer"))
|
||||||
|
typealias EditDisableWebPagePreviewMessage = EditLinkPreviewOptionsContainer
|
||||||
@@ -22,7 +22,7 @@ fun EditChatMessageText(
|
|||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = EditChatMessageText(
|
) = EditChatMessageText(
|
||||||
chatId,
|
chatId,
|
||||||
@@ -30,7 +30,7 @@ fun EditChatMessageText(
|
|||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ fun EditChatMessageText(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = EditChatMessageText(
|
) = EditChatMessageText(
|
||||||
chatId,
|
chatId,
|
||||||
@@ -46,7 +46,7 @@ fun EditChatMessageText(
|
|||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,11 +62,11 @@ data class EditChatMessageText internal constructor(
|
|||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(entitiesField)
|
@SerialName(entitiesField)
|
||||||
private val rawEntities: List<RawMessageEntity>? = null,
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
@SerialName(disableWebPagePreviewField)
|
@SerialName(linkPreviewOptionsField)
|
||||||
override val disableWebPagePreview: Boolean? = null,
|
override val linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer {
|
||||||
override val textSources: TextSourcesList? by lazy {
|
override val textSources: TextSourcesList? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,28 +16,28 @@ fun EditInlineMessageText(
|
|||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = EditInlineMessageText(
|
) = EditInlineMessageText(
|
||||||
inlineMessageId,
|
inlineMessageId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
fun EditInlineMessageText(
|
fun EditInlineMessageText(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = EditInlineMessageText(
|
) = EditInlineMessageText(
|
||||||
inlineMessageId,
|
inlineMessageId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -51,11 +51,11 @@ data class EditInlineMessageText internal constructor(
|
|||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(entitiesField)
|
@SerialName(entitiesField)
|
||||||
private val rawEntities: List<RawMessageEntity>? = null,
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
@SerialName(disableWebPagePreviewField)
|
@SerialName(linkPreviewOptionsField)
|
||||||
override val disableWebPagePreview: Boolean? = null,
|
override val linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer {
|
||||||
override val textSources: TextSourcesList? by lazy {
|
override val textSources: TextSourcesList? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.DisableNotification
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.MessagesAction
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||||
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
|
fun CopyMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageIds: Array<MessageId>,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = CopyMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = messageIds.toList(),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
fun CopyMessages(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageId,
|
||||||
|
vararg messageIds: MessageId,
|
||||||
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
removeCaption: Boolean = false
|
||||||
|
) = CopyMessages(
|
||||||
|
toChatId = toChatId,
|
||||||
|
fromChatId = fromChatId,
|
||||||
|
messageIds = (listOf(messageId) + messageIds.toList()),
|
||||||
|
threadId = threadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent,
|
||||||
|
removeCaption = removeCaption
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CopyMessages (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
val toChatId: ChatIdentifier,
|
||||||
|
@SerialName(fromChatIdField)
|
||||||
|
val fromChatId: ChatIdentifier,
|
||||||
|
@SerialName(messageIdsField)
|
||||||
|
override val messageIds: List<MessageId>,
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
override val threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
@SerialName(disableNotificationField)
|
||||||
|
override val disableNotification: Boolean = false,
|
||||||
|
@SerialName(protectContentField)
|
||||||
|
override val protectContent: Boolean = false,
|
||||||
|
@SerialName(removeCaptionField)
|
||||||
|
private val removeCaption: Boolean = false
|
||||||
|
): SimpleRequest<List<MessageId>>,
|
||||||
|
MessagesAction,
|
||||||
|
ProtectContent,
|
||||||
|
OptionallyMessageThreadRequest,
|
||||||
|
DisableNotification {
|
||||||
|
override val chatId: ChatIdentifier
|
||||||
|
get() = fromChatId
|
||||||
|
|
||||||
|
init {
|
||||||
|
require(messageIds.size in copyMessagesLimit) {
|
||||||
|
"Messages count for copyMessages must be in $copyMessagesLimit range"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun method(): String = "copyMessages"
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<List<MessageId>>
|
||||||
|
get() = ListSerializer(MessageIdSerializer)
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send
|
package dev.inmo.tgbotapi.requests.send
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview
|
import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
@@ -24,7 +24,7 @@ fun SendTextMessage(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -37,7 +37,7 @@ fun SendTextMessage(
|
|||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
threadId,
|
threadId,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
@@ -48,7 +48,7 @@ fun SendTextMessage(
|
|||||||
fun SendTextMessage(
|
fun SendTextMessage(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null,
|
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -61,7 +61,7 @@ fun SendTextMessage(
|
|||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
threadId,
|
threadId,
|
||||||
disableWebPagePreview,
|
linkPreviewOptions,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
@@ -81,8 +81,8 @@ data class SendTextMessage internal constructor(
|
|||||||
private val rawEntities: List<RawMessageEntity>? = null,
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
@SerialName(messageThreadIdField)
|
@SerialName(messageThreadIdField)
|
||||||
override val threadId: MessageThreadId? = chatId.threadId,
|
override val threadId: MessageThreadId? = chatId.threadId,
|
||||||
@SerialName(disableWebPagePreviewField)
|
@SerialName(linkPreviewOptionsField)
|
||||||
override val disableWebPagePreview: Boolean? = null,
|
override val linkPreviewOptions: LinkPreviewOptions? = null,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
override val disableNotification: Boolean = false,
|
override val disableNotification: Boolean = false,
|
||||||
@SerialName(protectContentField)
|
@SerialName(protectContentField)
|
||||||
@@ -96,7 +96,7 @@ data class SendTextMessage internal constructor(
|
|||||||
) : SendMessageRequest<ContentMessage<TextContent>>,
|
) : SendMessageRequest<ContentMessage<TextContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<TextContent>>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<TextContent>>,
|
||||||
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
||||||
DisableWebPagePreview
|
LinkPreviewOptionsContainer
|
||||||
{
|
{
|
||||||
override val textSources: TextSourcesList? by lazy {
|
override val textSources: TextSourcesList? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetMessageReactions(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageIdField)
|
||||||
|
val messageId: MessageId,
|
||||||
|
@SerialName(reactionField)
|
||||||
|
val reactions: List<Reaction>,
|
||||||
|
@SerialName(isBigField)
|
||||||
|
val big: Boolean = false
|
||||||
|
) : SimpleRequest<Boolean>, ChatRequest {
|
||||||
|
override fun method(): String = "setMessageReaction"
|
||||||
|
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = Boolean.serializer()
|
||||||
|
}
|
||||||
@@ -175,6 +175,12 @@ val keywordsInStickerLimit = 0 .. 20
|
|||||||
|
|
||||||
val stickerKeywordLengthLimit = 0 .. 64
|
val stickerKeywordLengthLimit = 0 .. 64
|
||||||
|
|
||||||
|
val keyboardButtonRequestUserLimit = 1 .. 10
|
||||||
|
|
||||||
|
val forwardMessagesLimit = 1 .. 100
|
||||||
|
val copyMessagesLimit = forwardMessagesLimit
|
||||||
|
val deleteMessagesLimit = forwardMessagesLimit
|
||||||
|
|
||||||
const val botActionActualityTime: Seconds = 5
|
const val botActionActualityTime: Seconds = 5
|
||||||
|
|
||||||
val cloudStorageKeyLimit = 1 .. 128
|
val cloudStorageKeyLimit = 1 .. 128
|
||||||
@@ -196,13 +202,17 @@ const val tgWebAppStartParamField = "tgWebAppStartParam"
|
|||||||
const val chatIdField = "chat_id"
|
const val chatIdField = "chat_id"
|
||||||
const val senderChatIdField = "sender_chat_id"
|
const val senderChatIdField = "sender_chat_id"
|
||||||
const val messageIdField = "message_id"
|
const val messageIdField = "message_id"
|
||||||
|
const val messageIdsField = "message_ids"
|
||||||
|
const val actorChatField = "actor_chat"
|
||||||
const val messageThreadIdField = "message_thread_id"
|
const val messageThreadIdField = "message_thread_id"
|
||||||
const val mediaGroupIdField = "media_group_id"
|
const val mediaGroupIdField = "media_group_id"
|
||||||
const val updateIdField = "update_id"
|
const val updateIdField = "update_id"
|
||||||
const val fromChatIdField = "from_chat_id"
|
const val fromChatIdField = "from_chat_id"
|
||||||
const val disableWebPagePreviewField = "disable_web_page_preview"
|
const val disableWebPagePreviewField = "disable_web_page_preview"
|
||||||
|
const val linkPreviewOptionsField = "link_preview_options"
|
||||||
const val disableNotificationField = "disable_notification"
|
const val disableNotificationField = "disable_notification"
|
||||||
const val protectContentField = "protect_content"
|
const val protectContentField = "protect_content"
|
||||||
|
const val removeCaptionField = "remove_caption"
|
||||||
const val replyToMessageIdField = "reply_to_message_id"
|
const val replyToMessageIdField = "reply_to_message_id"
|
||||||
const val allowSendingWithoutReplyField = "allow_sending_without_reply"
|
const val allowSendingWithoutReplyField = "allow_sending_without_reply"
|
||||||
const val replyMarkupField = "reply_markup"
|
const val replyMarkupField = "reply_markup"
|
||||||
@@ -229,6 +239,7 @@ const val textEntitiesField = "text_entities"
|
|||||||
const val entitiesField = "entities"
|
const val entitiesField = "entities"
|
||||||
const val stickerSetNameField = "set_name"
|
const val stickerSetNameField = "set_name"
|
||||||
const val customEmojiIdField = "custom_emoji_id"
|
const val customEmojiIdField = "custom_emoji_id"
|
||||||
|
const val customEmojiField = "custom_emoji"
|
||||||
const val customEmojiIdsField = "custom_emoji_ids"
|
const val customEmojiIdsField = "custom_emoji_ids"
|
||||||
const val premiumAnimationField = "premium_animation"
|
const val premiumAnimationField = "premium_animation"
|
||||||
const val stickerSetNameFullField = "sticker_set_name"
|
const val stickerSetNameFullField = "sticker_set_name"
|
||||||
@@ -236,6 +247,7 @@ const val slowModeDelayField = "slow_mode_delay"
|
|||||||
const val maskPositionField = "mask_position"
|
const val maskPositionField = "mask_position"
|
||||||
const val phoneNumberField = "phone_number"
|
const val phoneNumberField = "phone_number"
|
||||||
const val userIdField = "user_id"
|
const val userIdField = "user_id"
|
||||||
|
const val userIdsField = "user_ids"
|
||||||
const val onlyIfBannedField = "only_if_banned"
|
const val onlyIfBannedField = "only_if_banned"
|
||||||
const val containsMasksField = "contains_masks"
|
const val containsMasksField = "contains_masks"
|
||||||
const val resultIdField = "result_id"
|
const val resultIdField = "result_id"
|
||||||
@@ -322,8 +334,10 @@ const val requestContactField = "request_contact"
|
|||||||
const val requestLocationField = "request_location"
|
const val requestLocationField = "request_location"
|
||||||
const val requestPollField = "request_poll"
|
const val requestPollField = "request_poll"
|
||||||
const val requestUserField = "request_user"
|
const val requestUserField = "request_user"
|
||||||
|
const val requestUsersField = "request_users"
|
||||||
const val requestChatField = "request_chat"
|
const val requestChatField = "request_chat"
|
||||||
const val requestIdField = "request_id"
|
const val requestIdField = "request_id"
|
||||||
|
const val maxQuantityField = "max_quantity"
|
||||||
|
|
||||||
const val userIsBotField = "user_is_bot"
|
const val userIsBotField = "user_is_bot"
|
||||||
const val userIsPremiumField = "user_is_premium"
|
const val userIsPremiumField = "user_is_premium"
|
||||||
@@ -460,6 +474,12 @@ const val fromField = "from"
|
|||||||
const val userChatIdField = "user_chat_id"
|
const val userChatIdField = "user_chat_id"
|
||||||
const val userField = "user"
|
const val userField = "user"
|
||||||
const val dateField = "date"
|
const val dateField = "date"
|
||||||
|
const val reactionsField = "reactions"
|
||||||
|
const val reactionField = "reaction"
|
||||||
|
const val availableReactionsField = "available_reactions"
|
||||||
|
const val isBigField = "is_big"
|
||||||
|
const val oldReactionField = "old_reaction"
|
||||||
|
const val newReactionField = "new_reaction"
|
||||||
const val chatField = "chat"
|
const val chatField = "chat"
|
||||||
const val usernameField = "username"
|
const val usernameField = "username"
|
||||||
const val bioField = "bio"
|
const val bioField = "bio"
|
||||||
@@ -523,6 +543,7 @@ const val shippingQueryIdField = "shipping_query_id"
|
|||||||
const val preCheckoutQueryIdField = "pre_checkout_query_id"
|
const val preCheckoutQueryIdField = "pre_checkout_query_id"
|
||||||
const val shippingOptionsField = "shipping_options"
|
const val shippingOptionsField = "shipping_options"
|
||||||
const val countryCodeField = "country_code"
|
const val countryCodeField = "country_code"
|
||||||
|
const val totalCountField = "total_count"
|
||||||
const val stateField = "state"
|
const val stateField = "state"
|
||||||
const val cityField = "city"
|
const val cityField = "city"
|
||||||
const val firstStreetLineField = "street_line1"
|
const val firstStreetLineField = "street_line1"
|
||||||
@@ -536,6 +557,10 @@ const val providerTokenField = "provider_token"
|
|||||||
const val providerDataField = "provider_data"
|
const val providerDataField = "provider_data"
|
||||||
const val usersField = "users"
|
const val usersField = "users"
|
||||||
const val startDateField = "start_date"
|
const val startDateField = "start_date"
|
||||||
|
const val showAboveTextField = "show_above_text"
|
||||||
|
const val isDisabledField = "is_disabled"
|
||||||
|
const val preferSmallMediaField = "prefer_small_media"
|
||||||
|
const val preferLargeMediaField = "prefer_large_media"
|
||||||
|
|
||||||
const val requireNameField = "need_name"
|
const val requireNameField = "need_name"
|
||||||
const val requirePhoneNumberField = "need_phone_number"
|
const val requirePhoneNumberField = "need_phone_number"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
|
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||||
import dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview
|
import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
@@ -19,16 +19,16 @@ import kotlinx.serialization.Serializable
|
|||||||
fun InputTextMessageContent(
|
fun InputTextMessageContent(
|
||||||
text: String,
|
text: String,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableWebPagePreview: Boolean? = null
|
linkPreviewOptions: LinkPreviewOptions? = null
|
||||||
) = InputTextMessageContent(text, parseMode, null, disableWebPagePreview)
|
) = InputTextMessageContent(text, parseMode, null, linkPreviewOptions)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the [InputMessageContent] of a text message to be sent as the result of an inline query.
|
* Represents the [InputMessageContent] of a text message to be sent as the result of an inline query.
|
||||||
*/
|
*/
|
||||||
fun InputTextMessageContent(
|
fun InputTextMessageContent(
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableWebPagePreview: Boolean? = null
|
linkPreviewOptions: LinkPreviewOptions? = null
|
||||||
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview)
|
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), linkPreviewOptions)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class InputTextMessageContent internal constructor(
|
data class InputTextMessageContent internal constructor(
|
||||||
@@ -38,9 +38,9 @@ data class InputTextMessageContent internal constructor(
|
|||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(entitiesField)
|
@SerialName(entitiesField)
|
||||||
private val rawEntities: List<RawMessageEntity>? = null,
|
private val rawEntities: List<RawMessageEntity>? = null,
|
||||||
@SerialName(disableWebPagePreviewField)
|
@SerialName(linkPreviewOptionsField)
|
||||||
override val disableWebPagePreview: Boolean? = null
|
override val linkPreviewOptions: LinkPreviewOptions? = null
|
||||||
) : TextedOutput, DisableWebPagePreview, InputMessageContent {
|
) : TextedOutput, LinkPreviewOptionsContainer, InputMessageContent {
|
||||||
override val textSources: TextSourcesList? by lazy {
|
override val textSources: TextSourcesList? by lazy {
|
||||||
rawEntities ?.asTextSources(text)
|
rawEntities ?.asTextSources(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import kotlinx.serialization.Required
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
sealed interface LinkPreviewOptions {
|
||||||
|
val isDisabled: Boolean
|
||||||
|
val url: String?
|
||||||
|
val preferSmallMedia: Boolean
|
||||||
|
val preferLargeMedia: Boolean
|
||||||
|
val showAboveText: Boolean
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data object Disabled : LinkPreviewOptions {
|
||||||
|
@Required
|
||||||
|
@SerialName(isDisabledField)
|
||||||
|
override val isDisabled: Boolean = true
|
||||||
|
override val url: String?
|
||||||
|
get() = null
|
||||||
|
override val preferSmallMedia: Boolean
|
||||||
|
get() = false
|
||||||
|
override val preferLargeMedia: Boolean
|
||||||
|
get() = false
|
||||||
|
override val showAboveText: Boolean
|
||||||
|
get() = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Large(
|
||||||
|
@SerialName(urlField)
|
||||||
|
override val url: String?,
|
||||||
|
@SerialName(showAboveTextField)
|
||||||
|
override val showAboveText: Boolean
|
||||||
|
) : LinkPreviewOptions {
|
||||||
|
@Required
|
||||||
|
@SerialName(isDisabledField)
|
||||||
|
override val isDisabled: Boolean = false
|
||||||
|
@Required
|
||||||
|
@SerialName(preferLargeMediaField)
|
||||||
|
override val preferLargeMedia: Boolean = true
|
||||||
|
override val preferSmallMedia: Boolean
|
||||||
|
get() = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Small(
|
||||||
|
@SerialName(urlField)
|
||||||
|
override val url: String?,
|
||||||
|
@SerialName(showAboveTextField)
|
||||||
|
override val showAboveText: Boolean
|
||||||
|
) : LinkPreviewOptions {
|
||||||
|
@Required
|
||||||
|
@SerialName(isDisabledField)
|
||||||
|
override val isDisabled: Boolean = false
|
||||||
|
@Required
|
||||||
|
@SerialName(preferSmallMediaField)
|
||||||
|
override val preferSmallMedia: Boolean = true
|
||||||
|
override val preferLargeMedia: Boolean
|
||||||
|
get() = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Medium(
|
||||||
|
@SerialName(urlField)
|
||||||
|
override val url: String?,
|
||||||
|
@SerialName(showAboveTextField)
|
||||||
|
override val showAboveText: Boolean
|
||||||
|
) : LinkPreviewOptions {
|
||||||
|
@Required
|
||||||
|
@SerialName(isDisabledField)
|
||||||
|
override val isDisabled: Boolean = false
|
||||||
|
override val preferSmallMedia: Boolean
|
||||||
|
get() = false
|
||||||
|
override val preferLargeMedia: Boolean
|
||||||
|
get() = false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,8 +14,29 @@ const val UPDATE_POLL_ANSWER = "poll_answer"
|
|||||||
const val UPDATE_MY_CHAT_MEMBER = "my_chat_member"
|
const val UPDATE_MY_CHAT_MEMBER = "my_chat_member"
|
||||||
const val UPDATE_CHAT_MEMBER = "chat_member"
|
const val UPDATE_CHAT_MEMBER = "chat_member"
|
||||||
const val UPDATE_CHAT_JOIN_REQUEST = "chat_join_request"
|
const val UPDATE_CHAT_JOIN_REQUEST = "chat_join_request"
|
||||||
|
const val UPDATE_MESSAGE_REACTION = "message_reaction"
|
||||||
|
const val UPDATE_MESSAGE_REACTION_COUNT = "message_reaction_count"
|
||||||
|
|
||||||
val ALL_UPDATES_LIST = listOf(
|
val ALL_UPDATES_LIST = listOf(
|
||||||
|
UPDATE_MESSAGE,
|
||||||
|
UPDATE_EDITED_MESSAGE,
|
||||||
|
UPDATE_CHANNEL_POST,
|
||||||
|
UPDATE_EDITED_CHANNEL_POST,
|
||||||
|
UPDATE_CHOSEN_INLINE_RESULT,
|
||||||
|
UPDATE_INLINE_QUERY,
|
||||||
|
UPDATE_CALLBACK_QUERY,
|
||||||
|
UPDATE_SHIPPING_QUERY,
|
||||||
|
UPDATE_PRE_CHECKOUT_QUERY,
|
||||||
|
UPDATE_POLL,
|
||||||
|
UPDATE_POLL_ANSWER,
|
||||||
|
UPDATE_MY_CHAT_MEMBER,
|
||||||
|
UPDATE_CHAT_MEMBER,
|
||||||
|
UPDATE_CHAT_JOIN_REQUEST,
|
||||||
|
UPDATE_MESSAGE_REACTION,
|
||||||
|
UPDATE_MESSAGE_REACTION_COUNT
|
||||||
|
)
|
||||||
|
|
||||||
|
val ALL_UPDATES_LIST_WITHOUT_REACTIONS = listOf(
|
||||||
UPDATE_MESSAGE,
|
UPDATE_MESSAGE,
|
||||||
UPDATE_EDITED_MESSAGE,
|
UPDATE_EDITED_MESSAGE,
|
||||||
UPDATE_CHANNEL_POST,
|
UPDATE_CHANNEL_POST,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.types.abstracts
|
package dev.inmo.tgbotapi.types.abstracts
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
|
|
||||||
interface WithOptionalLanguageCode {
|
interface WithOptionalLanguageCode {
|
||||||
val ietfLanguageCode: IetfLanguageCode?
|
val ietfLanguageCode: IetfLang?
|
||||||
|
|
||||||
val languageCode: String?
|
val languageCode: String?
|
||||||
get() = ietfLanguageCode ?.code
|
get() = ietfLanguageCode ?.code
|
||||||
|
|||||||
@@ -103,13 +103,13 @@ data class RequestPollKeyboardButton(
|
|||||||
*
|
*
|
||||||
* In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is
|
* In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is
|
||||||
* recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming
|
* recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming
|
||||||
* [dev.inmo.tgbotapi.types.request.UserShared.requestId]
|
* [dev.inmo.tgbotapi.types.request.UsersShared.requestId]
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RequestUserKeyboardButton(
|
data class RequestUserKeyboardButton(
|
||||||
override val text: String,
|
override val text: String,
|
||||||
@SerialName(requestUserField)
|
@SerialName(requestUsersField)
|
||||||
val requestUser: KeyboardButtonRequestUser
|
val requestUsers: KeyboardButtonRequestUsers
|
||||||
) : KeyboardButton
|
) : KeyboardButton
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,11 +160,11 @@ object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
|||||||
asJson[requestPollField] ?.jsonObject ?: buildJsonObject { }
|
asJson[requestPollField] ?.jsonObject ?: buildJsonObject { }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
asJson is JsonObject && asJson[requestUserField] != null -> RequestUserKeyboardButton(
|
asJson is JsonObject && asJson[requestUsersField] != null -> RequestUserKeyboardButton(
|
||||||
asJson[textField]!!.jsonPrimitive.content,
|
asJson[textField]!!.jsonPrimitive.content,
|
||||||
nonstrictJsonFormat.decodeFromJsonElement(
|
nonstrictJsonFormat.decodeFromJsonElement(
|
||||||
KeyboardButtonRequestUser.serializer(),
|
KeyboardButtonRequestUsers.serializer(),
|
||||||
asJson[requestUserField] ?.jsonObject ?: buildJsonObject { }
|
asJson[requestUsersField] ?.jsonObject ?: buildJsonObject { }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
asJson is JsonObject && asJson[requestChatField] != null -> RequestChatKeyboardButton(
|
asJson is JsonObject && asJson[requestChatField] != null -> RequestChatKeyboardButton(
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.buttons
|
package dev.inmo.tgbotapi.types.buttons
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.request.RequestId
|
import dev.inmo.tgbotapi.types.request.RequestId
|
||||||
import dev.inmo.tgbotapi.types.requestIdField
|
|
||||||
import dev.inmo.tgbotapi.types.userIsBotField
|
|
||||||
import dev.inmo.tgbotapi.types.userIsPremiumField
|
|
||||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
import kotlinx.serialization.EncodeDefault
|
import kotlinx.serialization.EncodeDefault
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
@@ -14,17 +12,20 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
|||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
@Serializable(KeyboardButtonRequestUser.Companion::class)
|
@Serializable(KeyboardButtonRequestUsers.Companion::class)
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded
|
||||||
sealed interface KeyboardButtonRequestUser {
|
sealed interface KeyboardButtonRequestUsers {
|
||||||
val requestId: RequestId
|
val requestId: RequestId
|
||||||
val isBot: Boolean?
|
val isBot: Boolean?
|
||||||
|
val maxCount: Int
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Any(
|
data class Any(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId
|
override val requestId: RequestId,
|
||||||
) : KeyboardButtonRequestUser {
|
@SerialName(maxQuantityField)
|
||||||
|
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
|
) : KeyboardButtonRequestUsers {
|
||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val isBot: Boolean? = null
|
override val isBot: Boolean? = null
|
||||||
@@ -35,8 +36,10 @@ sealed interface KeyboardButtonRequestUser {
|
|||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId,
|
override val requestId: RequestId,
|
||||||
@SerialName(userIsPremiumField)
|
@SerialName(userIsPremiumField)
|
||||||
val isPremium: Boolean? = null
|
val isPremium: Boolean? = null,
|
||||||
) : KeyboardButtonRequestUser {
|
@SerialName(maxQuantityField)
|
||||||
|
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
|
) : KeyboardButtonRequestUsers {
|
||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val isBot: Boolean = false
|
override val isBot: Boolean = false
|
||||||
@@ -45,15 +48,17 @@ sealed interface KeyboardButtonRequestUser {
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class Bot(
|
data class Bot(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId
|
override val requestId: RequestId,
|
||||||
) : KeyboardButtonRequestUser {
|
@SerialName(maxQuantityField)
|
||||||
|
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
|
) : KeyboardButtonRequestUsers {
|
||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val isBot: Boolean = true
|
override val isBot: Boolean = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializer(KeyboardButtonRequestUser::class)
|
@Serializer(KeyboardButtonRequestUsers::class)
|
||||||
companion object : KSerializer<KeyboardButtonRequestUser> {
|
companion object : KSerializer<KeyboardButtonRequestUsers> {
|
||||||
@Serializable
|
@Serializable
|
||||||
private data class Surrogate(
|
private data class Surrogate(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
@@ -61,31 +66,37 @@ sealed interface KeyboardButtonRequestUser {
|
|||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
val userIsBot: Boolean? = null,
|
val userIsBot: Boolean? = null,
|
||||||
@SerialName(userIsPremiumField)
|
@SerialName(userIsPremiumField)
|
||||||
val userIsPremium: Boolean? = null
|
val userIsPremium: Boolean? = null,
|
||||||
|
@SerialName(maxQuantityField)
|
||||||
|
val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
)
|
)
|
||||||
private val realSerializer = Surrogate.serializer()
|
private val realSerializer = Surrogate.serializer()
|
||||||
|
|
||||||
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): KeyboardButtonRequestUser {
|
override fun deserialize(decoder: Decoder): KeyboardButtonRequestUsers {
|
||||||
val surrogate = realSerializer.deserialize(decoder)
|
val surrogate = realSerializer.deserialize(decoder)
|
||||||
|
|
||||||
return when (surrogate.userIsBot) {
|
return when (surrogate.userIsBot) {
|
||||||
true -> Bot(surrogate.requestId)
|
true -> Bot(surrogate.requestId, surrogate.maxCount)
|
||||||
false -> Common(surrogate.requestId, surrogate.userIsPremium)
|
false -> Common(surrogate.requestId, surrogate.userIsPremium, surrogate.maxCount)
|
||||||
null -> Any(surrogate.requestId)
|
null -> Any(surrogate.requestId, surrogate.maxCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUser) {
|
override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUsers) {
|
||||||
realSerializer.serialize(
|
realSerializer.serialize(
|
||||||
encoder,
|
encoder,
|
||||||
Surrogate(
|
Surrogate(
|
||||||
value.requestId,
|
value.requestId,
|
||||||
value.isBot,
|
value.isBot,
|
||||||
(value as? Common) ?.isPremium
|
(value as? Common) ?.isPremium,
|
||||||
|
value.maxCount
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("KeyboardButtonRequestUsers", "dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers"))
|
||||||
|
typealias KeyboardButtonRequestUser = KeyboardButtonRequestUsers
|
||||||
@@ -57,25 +57,25 @@ inline fun webAppReplyButton(
|
|||||||
*/
|
*/
|
||||||
inline fun requestUserReplyButton(
|
inline fun requestUserReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestUser: KeyboardButtonRequestUser
|
requestUser: KeyboardButtonRequestUsers
|
||||||
) = RequestUserKeyboardButton(
|
) = RequestUserKeyboardButton(
|
||||||
text,
|
text,
|
||||||
requestUser
|
requestUser
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot]
|
||||||
*/
|
*/
|
||||||
inline fun requestBotReplyButton(
|
inline fun requestBotReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestId: RequestId
|
requestId: RequestId
|
||||||
) = requestUserReplyButton(
|
) = requestUserReplyButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Bot(requestId)
|
KeyboardButtonRequestUsers.Bot(requestId)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common]
|
||||||
*/
|
*/
|
||||||
inline fun requestUserReplyButton(
|
inline fun requestUserReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -83,18 +83,18 @@ inline fun requestUserReplyButton(
|
|||||||
premiumUser: Boolean? = null
|
premiumUser: Boolean? = null
|
||||||
) = requestUserReplyButton(
|
) = requestUserReplyButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Common(requestId, premiumUser)
|
KeyboardButtonRequestUsers.Common(requestId, premiumUser)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any]
|
||||||
*/
|
*/
|
||||||
inline fun requestUserOrBotReplyButton(
|
inline fun requestUserOrBotReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestId: RequestId
|
requestId: RequestId
|
||||||
) = requestUserReplyButton(
|
) = requestUserReplyButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Any(requestId)
|
KeyboardButtonRequestUsers.Any(requestId)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.chat
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||||
|
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 kotlinx.serialization.json.JsonDecoder
|
||||||
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
|
||||||
|
@Serializable(ChatMessageReactionUpdated.Companion::class)
|
||||||
|
@ClassCastsIncluded
|
||||||
|
sealed interface ChatMessageReactionUpdated {
|
||||||
|
val chat: PreviewChat
|
||||||
|
val messageId: MessageIdentifier
|
||||||
|
val reactedUser: PreviewUser?
|
||||||
|
val reactedChat: PreviewChat?
|
||||||
|
val date: TelegramDate
|
||||||
|
val old: List<Reaction>
|
||||||
|
val new: List<Reaction>
|
||||||
|
|
||||||
|
@Serializable(Companion::class)
|
||||||
|
data class ByUser(
|
||||||
|
@SerialName(chatField)
|
||||||
|
override val chat: PreviewChat,
|
||||||
|
@SerialName(messageIdField)
|
||||||
|
override val messageId: MessageIdentifier,
|
||||||
|
@SerialName(userField)
|
||||||
|
override val reactedUser: PreviewUser,
|
||||||
|
@Serializable(TelegramDateSerializer::class)
|
||||||
|
@SerialName(dateField)
|
||||||
|
override val date: TelegramDate,
|
||||||
|
@SerialName(oldReactionField)
|
||||||
|
override val old: List<Reaction>,
|
||||||
|
@SerialName(newReactionField)
|
||||||
|
override val new: List<Reaction>
|
||||||
|
) : ChatMessageReactionUpdated {
|
||||||
|
override val reactedChat: PreviewChat?
|
||||||
|
get() = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(Companion::class)
|
||||||
|
data class ByChat(
|
||||||
|
@SerialName(chatField)
|
||||||
|
override val chat: PreviewChat,
|
||||||
|
@SerialName(messageIdField)
|
||||||
|
override val messageId: MessageIdentifier,
|
||||||
|
@SerialName(actorChatField)
|
||||||
|
override val reactedChat: PreviewChat,
|
||||||
|
@Serializable(TelegramDateSerializer::class)
|
||||||
|
@SerialName(dateField)
|
||||||
|
override val date: TelegramDate,
|
||||||
|
@SerialName(oldReactionField)
|
||||||
|
override val old: List<Reaction>,
|
||||||
|
@SerialName(newReactionField)
|
||||||
|
override val new: List<Reaction>
|
||||||
|
) : ChatMessageReactionUpdated {
|
||||||
|
override val reactedUser: PreviewUser?
|
||||||
|
get() = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(Companion::class)
|
||||||
|
data class Unknown(
|
||||||
|
@SerialName(chatField)
|
||||||
|
override val chat: PreviewChat,
|
||||||
|
@SerialName(messageIdField)
|
||||||
|
override val messageId: MessageIdentifier,
|
||||||
|
@SerialName(actorChatField)
|
||||||
|
override val reactedChat: PreviewChat?,
|
||||||
|
@SerialName(userField)
|
||||||
|
override val reactedUser: PreviewUser?,
|
||||||
|
@Serializable(TelegramDateSerializer::class)
|
||||||
|
@SerialName(dateField)
|
||||||
|
override val date: TelegramDate,
|
||||||
|
@SerialName(oldReactionField)
|
||||||
|
override val old: List<Reaction>,
|
||||||
|
@SerialName(newReactionField)
|
||||||
|
override val new: List<Reaction>,
|
||||||
|
val source: JsonElement?
|
||||||
|
) : ChatMessageReactionUpdated
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Surrogate internal constructor(
|
||||||
|
@SerialName(chatField)
|
||||||
|
val chat: PreviewChat,
|
||||||
|
@SerialName(messageIdField)
|
||||||
|
val messageId: MessageIdentifier,
|
||||||
|
@SerialName(userField)
|
||||||
|
val reactedUser: PreviewUser? = null,
|
||||||
|
@SerialName(actorChatField)
|
||||||
|
val reactedChat: PreviewChat? = null,
|
||||||
|
@Serializable(TelegramDateSerializer::class)
|
||||||
|
@SerialName(dateField)
|
||||||
|
val date: TelegramDate,
|
||||||
|
@SerialName(oldReactionField)
|
||||||
|
val old: List<Reaction>,
|
||||||
|
@SerialName(newReactionField)
|
||||||
|
val new: List<Reaction>
|
||||||
|
)
|
||||||
|
|
||||||
|
companion object : KSerializer<ChatMessageReactionUpdated> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = Surrogate.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): ChatMessageReactionUpdated {
|
||||||
|
val (surrogate, jsonElement) = if (decoder is JsonDecoder) {
|
||||||
|
val jsonElement = decoder.decodeJsonElement()
|
||||||
|
decoder.json.decodeFromJsonElement(Surrogate.serializer(), jsonElement) to jsonElement
|
||||||
|
} else {
|
||||||
|
Surrogate.serializer().deserialize(decoder) to null
|
||||||
|
}
|
||||||
|
return when {
|
||||||
|
surrogate.reactedUser != null -> ByUser(
|
||||||
|
surrogate.chat,
|
||||||
|
surrogate.messageId,
|
||||||
|
surrogate.reactedUser,
|
||||||
|
surrogate.date,
|
||||||
|
surrogate.old,
|
||||||
|
surrogate.new
|
||||||
|
)
|
||||||
|
surrogate.reactedChat != null -> ByChat(
|
||||||
|
surrogate.chat,
|
||||||
|
surrogate.messageId,
|
||||||
|
surrogate.reactedChat,
|
||||||
|
surrogate.date,
|
||||||
|
surrogate.old,
|
||||||
|
surrogate.new
|
||||||
|
)
|
||||||
|
else -> Unknown(
|
||||||
|
surrogate.chat,
|
||||||
|
surrogate.messageId,
|
||||||
|
surrogate.reactedUser,
|
||||||
|
surrogate.reactedChat,
|
||||||
|
surrogate.date,
|
||||||
|
surrogate.old,
|
||||||
|
surrogate.new,
|
||||||
|
jsonElement
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: ChatMessageReactionUpdated) {
|
||||||
|
if (value is Unknown && value.source != null) {
|
||||||
|
JsonElement.serializer().serialize(encoder, value.source)
|
||||||
|
} else {
|
||||||
|
Surrogate(
|
||||||
|
value.chat,
|
||||||
|
value.messageId,
|
||||||
|
value.reactedUser,
|
||||||
|
value.reactedChat,
|
||||||
|
value.date,
|
||||||
|
value.old,
|
||||||
|
value.new
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.chat
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.reactions.ReactionsCount
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ChatMessageReactionsCountUpdated(
|
||||||
|
@SerialName(chatField)
|
||||||
|
val chat: PreviewChat,
|
||||||
|
@SerialName(messageIdField)
|
||||||
|
val messageId: MessageIdentifier,
|
||||||
|
@Serializable(TelegramDateSerializer::class)
|
||||||
|
@SerialName(dateField)
|
||||||
|
val date: TelegramDate,
|
||||||
|
@SerialName(reactionsField)
|
||||||
|
val reactions: List<ReactionsCount>
|
||||||
|
)
|
||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.chat
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
|
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import korlibs.time.DateTime
|
import korlibs.time.DateTime
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@@ -32,7 +33,9 @@ data class ExtendedChannelChatImpl(
|
|||||||
@SerialName(linkedChatIdField)
|
@SerialName(linkedChatIdField)
|
||||||
override val linkedGroupChatId: IdChatIdentifier? = null,
|
override val linkedGroupChatId: IdChatIdentifier? = null,
|
||||||
@SerialName(hasHiddenMembersField)
|
@SerialName(hasHiddenMembersField)
|
||||||
override val membersHidden: Boolean = false
|
override val membersHidden: Boolean = false,
|
||||||
|
@SerialName(availableReactionsField)
|
||||||
|
override val availableReactions: List<Reaction>? = null
|
||||||
) : ExtendedChannelChat
|
) : ExtendedChannelChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -54,7 +57,9 @@ data class ExtendedGroupChatImpl(
|
|||||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||||
override val pinnedMessage: Message? = null,
|
override val pinnedMessage: Message? = null,
|
||||||
@SerialName(hasHiddenMembersField)
|
@SerialName(hasHiddenMembersField)
|
||||||
override val membersHidden: Boolean = false
|
override val membersHidden: Boolean = false,
|
||||||
|
@SerialName(availableReactionsField)
|
||||||
|
override val availableReactions: List<Reaction>? = null
|
||||||
) : ExtendedGroupChat
|
) : ExtendedGroupChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -125,7 +130,9 @@ data class ExtendedSupergroupChatImpl(
|
|||||||
@SerialName(hasAggressiveAntiSpamEnabledField)
|
@SerialName(hasAggressiveAntiSpamEnabledField)
|
||||||
override val isAggressiveAntiSpamEnabled: Boolean = false,
|
override val isAggressiveAntiSpamEnabled: Boolean = false,
|
||||||
@SerialName(hasHiddenMembersField)
|
@SerialName(hasHiddenMembersField)
|
||||||
override val membersHidden: Boolean = false
|
override val membersHidden: Boolean = false,
|
||||||
|
@SerialName(availableReactionsField)
|
||||||
|
override val availableReactions: List<Reaction>? = null
|
||||||
) : ExtendedSupergroupChat
|
) : ExtendedSupergroupChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -167,7 +174,9 @@ data class ExtendedForumChatImpl(
|
|||||||
@SerialName(hasAggressiveAntiSpamEnabledField)
|
@SerialName(hasAggressiveAntiSpamEnabledField)
|
||||||
override val isAggressiveAntiSpamEnabled: Boolean = false,
|
override val isAggressiveAntiSpamEnabled: Boolean = false,
|
||||||
@SerialName(hasHiddenMembersField)
|
@SerialName(hasHiddenMembersField)
|
||||||
override val membersHidden: Boolean = false
|
override val membersHidden: Boolean = false,
|
||||||
|
@SerialName(availableReactionsField)
|
||||||
|
override val availableReactions: List<Reaction>? = null
|
||||||
) : ExtendedForumChat
|
) : ExtendedForumChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.chat
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
|
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||||
import korlibs.time.DateTime
|
import korlibs.time.DateTime
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ sealed interface ExtendedPublicChat : ExtendedChat, PublicChat {
|
|||||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||||
val pinnedMessage: Message?
|
val pinnedMessage: Message?
|
||||||
val membersHidden: Boolean
|
val membersHidden: Boolean
|
||||||
|
val availableReactions: List<Reaction>?
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.chat
|
package dev.inmo.tgbotapi.types.chat
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
@@ -99,8 +99,8 @@ data class CommonUser(
|
|||||||
@SerialName(usernameField)
|
@SerialName(usernameField)
|
||||||
override val username: Username? = null,
|
override val username: Username? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null,
|
override val ietfLanguageCode: IetfLang? = null,
|
||||||
@SerialName(isPremiumField)
|
@SerialName(isPremiumField)
|
||||||
override val isPremium: Boolean = false,
|
override val isPremium: Boolean = false,
|
||||||
@SerialName(addedToAttachmentMenuField)
|
@SerialName(addedToAttachmentMenuField)
|
||||||
@@ -112,5 +112,5 @@ data class CommonUser(
|
|||||||
lastName: String = "",
|
lastName: String = "",
|
||||||
username: Username? = null,
|
username: Username? = null,
|
||||||
languageCode: String
|
languageCode: String
|
||||||
) : this(id, firstName, lastName, username, IetfLanguageCode(languageCode))
|
) : this(id, firstName, lastName, username, IetfLang(languageCode))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import dev.inmo.tgbotapi.types.payments.Invoice
|
|||||||
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
|
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
|
||||||
import dev.inmo.tgbotapi.types.polls.Poll
|
import dev.inmo.tgbotapi.types.polls.Poll
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.types.stories.Story
|
import dev.inmo.tgbotapi.types.stories.Story
|
||||||
import dev.inmo.tgbotapi.types.venue.Venue
|
import dev.inmo.tgbotapi.types.venue.Venue
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@@ -97,7 +97,7 @@ internal data class RawMessage(
|
|||||||
private val dice: Dice? = null,
|
private val dice: Dice? = null,
|
||||||
private val successful_payment: SuccessfulPayment? = null,
|
private val successful_payment: SuccessfulPayment? = null,
|
||||||
|
|
||||||
private val user_shared: UserShared? = null,
|
private val users_shared: UsersShared? = null,
|
||||||
private val chat_shared: ChatShared? = null,
|
private val chat_shared: ChatShared? = null,
|
||||||
|
|
||||||
// Voice Chat Service Messages
|
// Voice Chat Service Messages
|
||||||
@@ -128,6 +128,8 @@ internal data class RawMessage(
|
|||||||
private val passport_data: PassportData? = null,
|
private val passport_data: PassportData? = null,
|
||||||
private val proximity_alert_triggered: ProximityAlertTriggered? = null,
|
private val proximity_alert_triggered: ProximityAlertTriggered? = null,
|
||||||
|
|
||||||
|
private val link_preview_options: LinkPreviewOptions? = null,
|
||||||
|
|
||||||
private val reply_markup: InlineKeyboardMarkup? = null
|
private val reply_markup: InlineKeyboardMarkup? = null
|
||||||
) {
|
) {
|
||||||
private val content: MessageContent? by lazy {
|
private val content: MessageContent? by lazy {
|
||||||
@@ -141,7 +143,7 @@ internal data class RawMessage(
|
|||||||
messageId,
|
messageId,
|
||||||
story
|
story
|
||||||
)
|
)
|
||||||
text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text))
|
text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text), link_preview_options)
|
||||||
audio != null -> AudioContent(
|
audio != null -> AudioContent(
|
||||||
audio,
|
audio,
|
||||||
caption,
|
caption,
|
||||||
@@ -264,7 +266,7 @@ internal data class RawMessage(
|
|||||||
successful_payment != null -> SuccessfulPaymentEvent(successful_payment)
|
successful_payment != null -> SuccessfulPaymentEvent(successful_payment)
|
||||||
connected_website != null -> UserLoggedIn(connected_website)
|
connected_website != null -> UserLoggedIn(connected_website)
|
||||||
web_app_data != null -> web_app_data
|
web_app_data != null -> web_app_data
|
||||||
user_shared != null -> user_shared
|
users_shared != null -> users_shared
|
||||||
chat_shared != null -> chat_shared
|
chat_shared != null -> chat_shared
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,24 +22,25 @@ internal data class RawMessageEntity(
|
|||||||
val priority by lazy {
|
val priority by lazy {
|
||||||
when (type) {
|
when (type) {
|
||||||
// Types with potential subsources should have priority
|
// Types with potential subsources should have priority
|
||||||
"mention" -> 0
|
"mention" -> 1
|
||||||
"hashtag" -> 0
|
"hashtag" -> 1
|
||||||
"cashtag" -> 0
|
"cashtag" -> 1
|
||||||
"email" -> 0
|
"email" -> 1
|
||||||
"phone_number" -> 0
|
"phone_number" -> 1
|
||||||
"bold" -> 0
|
"bold" -> 1
|
||||||
"italic" -> 0
|
"blockquote" -> 0
|
||||||
"text_mention" -> 0
|
"italic" -> 1
|
||||||
"strikethrough" -> 0
|
"text_mention" -> 1
|
||||||
"underline" -> 0
|
"strikethrough" -> 1
|
||||||
"spoiler" -> 0
|
"underline" -> 1
|
||||||
"custom_emoji" -> 0
|
"spoiler" -> 1
|
||||||
"bot_command" -> 1
|
"custom_emoji" -> 1
|
||||||
"url" -> 1
|
"bot_command" -> 2
|
||||||
"code" -> 1
|
"url" -> 2
|
||||||
"pre" -> 1
|
"code" -> 2
|
||||||
"text_link" -> 1
|
"pre" -> 2
|
||||||
else -> 1
|
"text_link" -> 2
|
||||||
|
else -> 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +62,7 @@ internal fun RawMessageEntity.asTextSource(
|
|||||||
"email" -> EMailTextSource(sourceSubstring, subPartsWithRegulars)
|
"email" -> EMailTextSource(sourceSubstring, subPartsWithRegulars)
|
||||||
"phone_number" -> PhoneNumberTextSource(sourceSubstring, subPartsWithRegulars)
|
"phone_number" -> PhoneNumberTextSource(sourceSubstring, subPartsWithRegulars)
|
||||||
"bold" -> BoldTextSource(sourceSubstring, subPartsWithRegulars)
|
"bold" -> BoldTextSource(sourceSubstring, subPartsWithRegulars)
|
||||||
|
"blockquote" -> BlockquoteTextSource(sourceSubstring, subPartsWithRegulars)
|
||||||
"italic" -> ItalicTextSource(sourceSubstring, subPartsWithRegulars)
|
"italic" -> ItalicTextSource(sourceSubstring, subPartsWithRegulars)
|
||||||
"code" -> CodeTextSource(sourceSubstring)
|
"code" -> CodeTextSource(sourceSubstring)
|
||||||
"pre" -> PreTextSource(sourceSubstring, language)
|
"pre" -> PreTextSource(sourceSubstring, language)
|
||||||
@@ -180,6 +182,7 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEn
|
|||||||
is EMailTextSource -> RawMessageEntity("email", offset, length)
|
is EMailTextSource -> RawMessageEntity("email", offset, length)
|
||||||
is PhoneNumberTextSource -> RawMessageEntity("phone_number", offset, length)
|
is PhoneNumberTextSource -> RawMessageEntity("phone_number", offset, length)
|
||||||
is BoldTextSource -> RawMessageEntity("bold", offset, length)
|
is BoldTextSource -> RawMessageEntity("bold", offset, length)
|
||||||
|
is BlockquoteTextSource -> RawMessageEntity("blockquote", offset, length)
|
||||||
is ItalicTextSource -> RawMessageEntity("italic", offset, length)
|
is ItalicTextSource -> RawMessageEntity("italic", offset, length)
|
||||||
is CodeTextSource -> RawMessageEntity("code", offset, length)
|
is CodeTextSource -> RawMessageEntity("code", offset, length)
|
||||||
is PreTextSource -> RawMessageEntity("pre", offset, length, language = language)
|
is PreTextSource -> RawMessageEntity("pre", offset, length, language = language)
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import dev.inmo.tgbotapi.types.MessageId
|
|||||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
|
||||||
import dev.inmo.tgbotapi.types.stories.Story
|
import dev.inmo.tgbotapi.types.stories.Story
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@@ -25,7 +27,7 @@ data class StoryContent(
|
|||||||
replyToMessageId: MessageId?,
|
replyToMessageId: MessageId?,
|
||||||
allowSendingWithoutReply: Boolean?,
|
allowSendingWithoutReply: Boolean?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<out Message> {
|
): Request<PossiblyForwardedMessage> {
|
||||||
return ForwardMessage(
|
return ForwardMessage(
|
||||||
chat.id,
|
chat.id,
|
||||||
toChatId = chatId,
|
toChatId = chatId,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.abstracts.TextedInput
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageId
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
@@ -15,6 +16,7 @@ import kotlinx.serialization.Serializable
|
|||||||
data class TextContent(
|
data class TextContent(
|
||||||
override val text: String,
|
override val text: String,
|
||||||
override val textSources: TextSourcesList = emptyList(),
|
override val textSources: TextSourcesList = emptyList(),
|
||||||
|
val linkPreviewOptions: LinkPreviewOptions? = null
|
||||||
) : TextedContent {
|
) : TextedContent {
|
||||||
override fun createResend(
|
override fun createResend(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@@ -27,7 +29,7 @@ data class TextContent(
|
|||||||
): Request<ContentMessage<TextContent>> = SendTextMessage(
|
): Request<ContentMessage<TextContent>> = SendTextMessage(
|
||||||
chatId,
|
chatId,
|
||||||
textSources,
|
textSources,
|
||||||
false,
|
linkPreviewOptions,
|
||||||
messageThreadId,
|
messageThreadId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.MessageThreadId
|
|||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.files.VoiceFile
|
import dev.inmo.tgbotapi.types.files.VoiceFile
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
|
import dev.inmo.tgbotapi.types.threadId
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -27,16 +28,16 @@ data class VoiceContent(
|
|||||||
allowSendingWithoutReply: Boolean?,
|
allowSendingWithoutReply: Boolean?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<ContentMessage<VoiceContent>> = SendVoice(
|
): Request<ContentMessage<VoiceContent>> = SendVoice(
|
||||||
chatId,
|
chatId = chatId,
|
||||||
media.fileId,
|
voice = media.fileId,
|
||||||
textSources,
|
entities = textSources,
|
||||||
media.duration,
|
threadId = messageThreadId,
|
||||||
messageThreadId,
|
duration = media.duration,
|
||||||
disableNotification,
|
disableNotification = disableNotification,
|
||||||
protectContent,
|
protectContent = protectContent,
|
||||||
replyToMessageId,
|
replyToMessageId = replyToMessageId,
|
||||||
allowSendingWithoutReply,
|
allowSendingWithoutReply = allowSendingWithoutReply,
|
||||||
replyMarkup
|
replyMarkup = replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun asTelegramMedia(): TelegramMediaAudio = TelegramMediaAudio(
|
override fun asTelegramMedia(): TelegramMediaAudio = TelegramMediaAudio(
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.textsources
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
|
import dev.inmo.tgbotapi.utils.internal.*
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see blockquote
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||||
|
override val source: String,
|
||||||
|
override val subsources: TextSourcesList
|
||||||
|
) : MultilevelTextSource {
|
||||||
|
override val markdown: String by lazy { source.blockquoteMarkdown() }
|
||||||
|
override val markdownV2: String by lazy { blockquoteMarkdownV2() }
|
||||||
|
override val html: String by lazy { blockquoteHTML() }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun blockquote(parts: TextSourcesList) = BlockquoteTextSource(parts.makeString(), parts)
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun blockquote(vararg parts: TextSource) = blockquote(parts.toList())
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun blockquote(text: String) = blockquote(regular(text))
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.reactions
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||||
|
import dev.inmo.tgbotapi.types.customEmojiField
|
||||||
|
import dev.inmo.tgbotapi.types.emojiField
|
||||||
|
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 kotlinx.serialization.json.JsonDecoder
|
||||||
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
|
||||||
|
@Serializable(Reaction.Companion::class)
|
||||||
|
@ClassCastsIncluded
|
||||||
|
sealed interface Reaction {
|
||||||
|
val type: String
|
||||||
|
|
||||||
|
@Serializable(Reaction.Companion::class)
|
||||||
|
data class Emoji(
|
||||||
|
val emoji: String
|
||||||
|
) : Reaction {
|
||||||
|
override val type: String
|
||||||
|
get() = Companion.type
|
||||||
|
companion object {
|
||||||
|
const val type: String = "emoji"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(Reaction.Companion::class)
|
||||||
|
data class CustomEmoji(
|
||||||
|
val customEmoji: CustomEmojiId
|
||||||
|
) : Reaction {
|
||||||
|
override val type: String
|
||||||
|
get() = Companion.type
|
||||||
|
companion object {
|
||||||
|
const val type: String = "custom_emoji"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(Reaction.Companion::class)
|
||||||
|
data class Unknown(
|
||||||
|
override val type: String,
|
||||||
|
val sourceJson: JsonElement?
|
||||||
|
) : Reaction
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
private data class Surrogate(
|
||||||
|
val type: String,
|
||||||
|
@SerialName(emojiField)
|
||||||
|
val emoji: String? = null,
|
||||||
|
@SerialName(customEmojiField)
|
||||||
|
val customEmoji: CustomEmojiId? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
companion object : KSerializer<Reaction> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = Surrogate.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): Reaction {
|
||||||
|
val (surrogate, json) = if (decoder is JsonDecoder) {
|
||||||
|
val json = decoder.decodeJsonElement()
|
||||||
|
decoder.json.decodeFromJsonElement(Surrogate.serializer(), json) to json
|
||||||
|
} else {
|
||||||
|
Surrogate.serializer().deserialize(decoder) to null
|
||||||
|
}
|
||||||
|
|
||||||
|
return when {
|
||||||
|
surrogate.emoji != null -> Emoji(surrogate.emoji)
|
||||||
|
surrogate.customEmoji != null -> CustomEmoji(surrogate.customEmoji)
|
||||||
|
else -> Unknown(surrogate.type, json)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: Reaction) {
|
||||||
|
if (value is Unknown && value.sourceJson != null) {
|
||||||
|
JsonElement.serializer().serialize(encoder, value.sourceJson)
|
||||||
|
} else {
|
||||||
|
Surrogate.serializer().serialize(
|
||||||
|
encoder,
|
||||||
|
Surrogate(
|
||||||
|
type = value.type,
|
||||||
|
emoji = (value as? Emoji) ?.emoji,
|
||||||
|
customEmoji = (value as? CustomEmoji) ?.customEmoji,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.reactions
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.totalCountField
|
||||||
|
import dev.inmo.tgbotapi.types.typeField
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ReactionsCount(
|
||||||
|
@SerialName(typeField)
|
||||||
|
val reaction: Reaction,
|
||||||
|
@SerialName(totalCountField)
|
||||||
|
val count: Int
|
||||||
|
)
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
package dev.inmo.tgbotapi.types.request
|
package dev.inmo.tgbotapi.types.request
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.requestIdField
|
|
||||||
import dev.inmo.tgbotapi.types.userIdField
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UserShared(
|
data class UsersShared(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId,
|
override val requestId: RequestId,
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdsField)
|
||||||
val userId: UserId
|
val userIds: List<UserId>
|
||||||
) : ChatSharedRequest {
|
) : ChatSharedRequest {
|
||||||
|
val userId: UserId
|
||||||
|
get() = userIds.first()
|
||||||
|
constructor(
|
||||||
|
requestId: RequestId,
|
||||||
|
userId: UserId
|
||||||
|
) : this(requestId, listOf(userId))
|
||||||
override val chatId: ChatId
|
override val chatId: ChatId
|
||||||
get() = userId
|
get() = userId
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user