mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 12:00:18 +00:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b06b63703 | |||
| bf7fc25285 | |||
| 4df242747f | |||
| e831ca143e | |||
| 44838a2088 | |||
| 3823b03453 | |||
| ec48708195 | |||
| 6a06775bc4 | |||
| bbdff0b31a | |||
| cb4880bd00 | |||
| a18eda3db6 | |||
| d8f6429385 | |||
| be74249b67 | |||
| 69f658e4a8 | |||
| 8c51ca9d72 | |||
| 48c4a3156b | |||
| 92407c9010 | |||
| 86937cc096 | |||
| ea614b790b | |||
| c994332cb9 | |||
| 9d893ffa48 | |||
| 57d2fe85c5 | |||
| c68b148d5e | |||
| 0a0a7cea0e | |||
| ea981605f6 | |||
| fe1e65a83c | |||
| c85983bd59 | |||
| d72e1029d3 | |||
| 4b89563cff | |||
| 542079f4bf | |||
|
|
5c7164e864 | ||
| 6329905f62 | |||
| c54945e4cc | |||
| 8f20e1d617 | |||
|
|
edbfedb74e | ||
|
|
b5006cd1e0 | ||
| ca01ce7843 | |||
| 54fad3f338 | |||
| 15ef481fd7 | |||
| 91e1202674 | |||
| bdd39963a8 | |||
| 01dfedf540 | |||
| 8ded892b72 | |||
| d0b606469b | |||
| 678f79da04 | |||
| fde2c79f4c | |||
| acaf46e015 | |||
| 3f9237b5de | |||
| 3d7334dd62 | |||
| 26306f1567 | |||
| 247553d990 | |||
| 049a8a3263 | |||
| cc67a31e97 | |||
| 8791573145 | |||
| 5752f7a4fb | |||
| ade236eaa3 | |||
| e7340a483a | |||
| c7dc69d09f | |||
| c2487c5adc | |||
| 7c4808f163 | |||
| b91b516659 | |||
| 57cdc4ff2a | |||
| 864992aff0 | |||
| e18e8ba6df | |||
| 02cedc6626 | |||
| 619b890956 | |||
| 100a76a832 | |||
| c583ae6761 | |||
| 7429ffb514 | |||
| 95aeedfb94 | |||
| 095e318a78 | |||
| 4aa2d2ae41 | |||
| e936d25c13 | |||
| 97a2a5d9fd | |||
| 00ab532eac | |||
| c2cc6ee1ec |
94
CHANGELOG.md
94
CHANGELOG.md
@@ -1,5 +1,99 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 3.0.1
|
||||
|
||||
**ALL OLD DEPRECATIONS HAVE BEEN REMOVED**
|
||||
|
||||
**`copyMessage` HAVE CHANGED THEIR SIGNATURE BY SWAPPING FROM AND TO CHAT IDS**
|
||||
|
||||
* `Versions`:
|
||||
* `Kotlin`: `1.6.21` -> `1.7.10`
|
||||
* `Serialization`: `1.3.3` -> `1.4.0-RC`
|
||||
* `Korlibs`: `2.7.0` -> `3.0.0`
|
||||
* `UUID`: `0.4.1` -> `0.5.0`
|
||||
* `MicroUtils`: `0.11.13` -> `0.12.0`
|
||||
* `Core`:
|
||||
* Interface `ReplyMakrup` has been renamed to `WithReplyMarkup` to correspond its purpose
|
||||
* Data class `LeftChatMember` has been renamed to `LeftChatMemberEvent` to avoid type ambiguite with the other `LeftChatMember`
|
||||
* `ForwardInfo` hierarchy has been fully reworked:
|
||||
* `AnonymousForwardInfo` -> `ForwardInfo.ByAnonymous`
|
||||
* `UserForwardInfo` -> `ForwardInfo.ByUser`
|
||||
* `ForwardFromPublicChatInfo` -> `ForwardInfo.PublicChat`
|
||||
* `ForwardFromChannelInfo` -> `ForwardInfo.PublicChat.FromChannel`
|
||||
* `ForwardFromSupergroupInfo` -> `ForwardInfo.PublicChat.FromSupergroup`
|
||||
* `ForwardInfo.PublicChat.SentByChannel` ___has been created___
|
||||
* `API`:
|
||||
* Add new `Flow`-based live locations API
|
||||
* Add `sendLocation` for sending live locations
|
||||
* `Utils`:
|
||||
* **BREAKING CHANGES** Now all new classcasts (like `Chat.ifPrivateChat` etc.) have been rewritten to be generated with `ksp` and `kotlin poet`
|
||||
|
||||
## 2.2.2
|
||||
|
||||
* `Utils`:
|
||||
* `buildEntities` now is inline
|
||||
* `Behaviour Builder`:
|
||||
* Fixes in `CallbackQuery` triggers
|
||||
|
||||
## 2.2.1
|
||||
|
||||
* `Versions`:
|
||||
* `Coroutines`: `1.6.3` -> `1.6.4`
|
||||
* `MicroUtils`: `0.11.12` -> `0.11.13`
|
||||
* `Core`:
|
||||
* New `typealiase`s for `CommonMessage` with all supported content types, more info: [PR](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/629)
|
||||
* `Utils`:
|
||||
* New extensions for all types of messages `*.withContentOrNull` and `*.withContentOrThrow` as analogies to the same ones from class casts
|
||||
|
||||
## 2.2.0
|
||||
|
||||
* `Core`:
|
||||
* For `CopyMessage` order of parameters has been changed
|
||||
* `ReplyForce` defaults changes:
|
||||
* All old companion properties (like `ReplyForce.ReplyForceSelective`) have been renamed:
|
||||
* `ReplyForceSelective` -> `Selective`
|
||||
* `ReplyForceNonSelective` -> `NonSelective`
|
||||
* `ReplyForceDefault` -> `Default`
|
||||
* New companion functions:
|
||||
* `ReplyForce#Selective`
|
||||
* `ReplyForce#NonSelective`
|
||||
* Rename `CreatorChatMember` -> `OwnerChatMember`
|
||||
* `API`:
|
||||
* For `copyMessage` order of parameters has been changed
|
||||
* `Utils`:
|
||||
* New extension `Message#sameChat`
|
||||
* New extension `Message#sameMessage`
|
||||
* New functions `flatInlineKeyboard` and `flatReplyKeyboard`
|
||||
* Experimentally add new triple of class casts: `if*`, `*OrNull` and `*OrThrow`
|
||||
|
||||
## 2.1.3
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.11.9` -> `0.11.12`
|
||||
* `Utils`:
|
||||
* Rename `UserId` extension `link` to `userLink`
|
||||
* `Core`
|
||||
* `ChatJoinRequest#inviteLink` is nullable due to the fact that join requests without link do not require invite link
|
||||
|
||||
## 2.1.2
|
||||
|
||||
* `Versions`:
|
||||
* `Coroutines`: `1.6.1` -> `1.6.3`
|
||||
* `Ktor`: `2.0.2` -> `2.0.3`
|
||||
* `MicroUtils`: `0.11.6` -> `0.11.9`
|
||||
|
||||
## 2.1.1
|
||||
|
||||
* `API`:
|
||||
* Now it is possible to edit any message text via `editMessageText` (but with warning)
|
||||
* Now it is possible to edit any message caption via `editMessageCaption` (but with warning)
|
||||
* Media message caption edit method (`editMessageCaption`) now returns the message with the same generic type (as it must be in telegram system)
|
||||
* New extensions `TelegramBot#edit` has been added for all possible editions types
|
||||
* New extensions `TelegramBot#send` has been added for all possible sending types
|
||||
* New extensions `TelegramBot#delete` has been added
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.11.3` -> `0.11.6`
|
||||
|
||||
## 2.1.0
|
||||
|
||||
__This update contains including of [Telegram Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)__
|
||||
|
||||
15
README.md
15
README.md
@@ -1,8 +1,17 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
|
||||
| [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) [](https://t.me/InMoTelegramBotAPI) |
|
||||
|:---:|
|
||||
| [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||
|:---:|:---:|
|
||||
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
||||
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
||||
|
||||
<!--- [](https://t.me/InMoTelegramBotAPI) --->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://t.me/InMoTelegramBotAPI">
|
||||
<img src="./resources/tg_channel_qr.jpg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||
|
||||
|
||||
21
build.gradle
21
build.gradle
@@ -6,19 +6,21 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
|
||||
classpath libs.kotlin.gradle.plugin
|
||||
classpath libs.kotlin.ksp.plugin
|
||||
classpath libs.kotlin.serialization.plugin
|
||||
classpath libs.kotlin.dokka.plugin
|
||||
classpath libs.github.release.plugin
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
||||
}
|
||||
|
||||
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
if (it != rootProject.findProject("docs")) {
|
||||
tasks.whenTaskAdded { task ->
|
||||
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
||||
@@ -27,6 +29,7 @@ allprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
apply from: "./extensions.gradle"
|
||||
|
||||
private String getCurrentVersionChangelog() {
|
||||
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
||||
@@ -48,7 +51,7 @@ if (new File(projectDir, "secret.gradle").exists()) {
|
||||
owner "InsanusMokrassar"
|
||||
repo "TelegramBotAPI"
|
||||
|
||||
tagName "$library_version"
|
||||
tagName "v$library_version"
|
||||
releaseName "$library_version"
|
||||
targetCommitish "$library_version"
|
||||
|
||||
|
||||
@@ -1,45 +1,17 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "org.jetbrains.dokka" version "$dokka_version"
|
||||
id "org.jetbrains.dokka"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
project.description = "Full collection of all built-in tgbotapi tools"
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
|
||||
api project(":tgbotapi.core")
|
||||
api project(":tgbotapi.api")
|
||||
api project(":tgbotapi.utils")
|
||||
@@ -58,12 +30,13 @@ kotlin {
|
||||
|
||||
private List<SourceDirectorySet> findSourcesWithName(String... approximateNames) {
|
||||
return parent.subprojects
|
||||
.findAll { it != project }
|
||||
.collectMany { it.kotlin.sourceSets }
|
||||
.findAll { sourceSet -> approximateNames.any {
|
||||
nameToFilter -> sourceSet.name.contains(nameToFilter)
|
||||
}
|
||||
}.collect { it.kotlin }
|
||||
.findAll { it != project && it.hasProperty("kotlin") }
|
||||
.collectMany { it.kotlin.sourceSets }
|
||||
.findAll { sourceSet ->
|
||||
approximateNames.any { nameToFilter ->
|
||||
sourceSet.name.contains(nameToFilter)
|
||||
}
|
||||
}.collect { it.kotlin }
|
||||
}
|
||||
|
||||
Object callback = {
|
||||
@@ -103,8 +76,3 @@ Object callback = {
|
||||
|
||||
tasks.dokkaGfm(callback)
|
||||
tasks.dokkaHtml(callback)
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
8
extensions.gradle
Normal file
8
extensions.gradle
Normal file
@@ -0,0 +1,8 @@
|
||||
allprojects {
|
||||
ext {
|
||||
mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization.gradle"
|
||||
mppJsProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJsProject.gradle"
|
||||
|
||||
publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle"
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,5 @@ kotlin.js.generate.externals=true
|
||||
kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
kotlin_version=1.6.21
|
||||
kotlin_coroutines_version=1.6.1
|
||||
kotlin_serialisation_runtime_version=1.3.3
|
||||
korlibs_version=2.7.0
|
||||
uuid_version=0.4.1
|
||||
ktor_version=2.0.2
|
||||
|
||||
micro_utils_version=0.11.3
|
||||
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
|
||||
dokka_version=1.6.21
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=2.1.0
|
||||
|
||||
github_release_plugin_version=2.4.1
|
||||
library_version=3.0.1
|
||||
|
||||
68
gradle/libs.versions.toml
Normal file
68
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,68 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "1.7.10"
|
||||
kotlin-serialization = "1.4.0-RC"
|
||||
kotlin-coroutines = "1.6.4"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "3.0.0"
|
||||
uuid = "0.5.0"
|
||||
ktor = "2.0.3"
|
||||
|
||||
ksp = "1.7.10-1.0.6"
|
||||
kotlin-poet = "1.12.0"
|
||||
|
||||
microutils = "0.12.0"
|
||||
|
||||
github-release-plugin = "2.4.1"
|
||||
|
||||
[libraries]
|
||||
|
||||
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
|
||||
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
|
||||
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlin-serialization" }
|
||||
kotlin-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlin-serialization" }
|
||||
kotlin-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" }
|
||||
kotlin-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" }
|
||||
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
|
||||
kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kotlin" }
|
||||
|
||||
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
||||
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
||||
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
|
||||
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
|
||||
|
||||
javax-activation = { module = "javax.activation:activation", version.ref = "javax-activation" }
|
||||
|
||||
korlibs-klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "korlibs" }
|
||||
korlibs-krypto = { module = "com.soywiz.korlibs.krypto:krypto", version.ref = "korlibs" }
|
||||
|
||||
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
|
||||
|
||||
microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.ref = "microutils" }
|
||||
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" }
|
||||
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
|
||||
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" }
|
||||
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
|
||||
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
||||
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
||||
|
||||
# ksp dependencies
|
||||
|
||||
kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" }
|
||||
ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
|
||||
|
||||
# buildscript classpaths
|
||||
|
||||
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
kotlin-ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
|
||||
kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||
kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "kotlin" }
|
||||
github-release-plugin = { module = "com.github.breadmoirai:github-release", version.ref = "github-release-plugin" }
|
||||
|
||||
[plugins]
|
||||
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
|
||||
32
mppJsProject.gradle
Normal file
32
mppJsProject.gradle
Normal file
@@ -0,0 +1,32 @@
|
||||
project.version = "$version"
|
||||
project.group = "$group"
|
||||
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
js (IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation libs.kotlin
|
||||
api libs.kotlin.serialization
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.common
|
||||
implementation libs.kotlin.test.annotations.common
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.js
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
mppProjectWithSerialization.gradle
Normal file
47
mppProjectWithSerialization.gradle
Normal file
@@ -0,0 +1,47 @@
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js (IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation libs.kotlin
|
||||
api libs.kotlin.serialization
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.common
|
||||
implementation libs.kotlin.test.annotations.common
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.js
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
BIN
resources/tg_channel_qr.jpg
Normal file
BIN
resources/tg_channel_qr.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 593 KiB |
@@ -12,6 +12,8 @@ pluginManagement {
|
||||
}
|
||||
|
||||
include ":tgbotapi.core"
|
||||
include ":tgbotapi.ksp:processor"
|
||||
include ":tgbotapi.ksp:lib"
|
||||
include ":tgbotapi.api"
|
||||
include ":tgbotapi.utils"
|
||||
include ":tgbotapi.behaviour_builder"
|
||||
|
||||
@@ -1,56 +1,20 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor"
|
||||
|
||||
apply from: "../publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api project(":tgbotapi.core")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,20 @@ suspend fun TelegramBot.deleteMessage(
|
||||
message: Message
|
||||
) = deleteMessage(message.chat, message.messageId)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier
|
||||
) = deleteMessage(chatId, messageId)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
) = deleteMessage(chat, messageId)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
message: Message
|
||||
) = deleteMessage(message)
|
||||
|
||||
suspend fun Message.delete(
|
||||
requestsExecutor: TelegramBot
|
||||
) = requestsExecutor.deleteMessage(this)
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.abstracts.*
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.math.ceil
|
||||
|
||||
@Serializable
|
||||
data class EditLiveLocationInfo(
|
||||
override val latitude: Double,
|
||||
override val longitude: Double,
|
||||
override val horizontalAccuracy: Meters? = null,
|
||||
override val heading: Degrees? = null,
|
||||
override val proximityAlertRadius: Meters? = null,
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : Locationed, HorizontallyAccured, ProximityAlertable, Headed, WithReplyMarkup
|
||||
|
||||
/**
|
||||
* Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing,
|
||||
* the message will be sent again and new edits will be applied to the new message
|
||||
*/
|
||||
suspend fun TelegramBot.handleLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
locationsFlow: Flow<EditLiveLocationInfo>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
var currentLiveLocationMessage: ContentMessage<LocationContent>? = null
|
||||
val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
|
||||
while (isActive) {
|
||||
delay(liveTimeMillis)
|
||||
// Remove previous location message info to resend live location message
|
||||
currentLiveLocationMessage = null
|
||||
}
|
||||
}
|
||||
locationsFlow.collect {
|
||||
val capturedLiveLocationMessage = currentLiveLocationMessage
|
||||
if (capturedLiveLocationMessage == null) {
|
||||
updateMessageJob.start()
|
||||
currentLiveLocationMessage = sendLiveLocation(
|
||||
chatId,
|
||||
it.latitude,
|
||||
it.longitude,
|
||||
ceil(liveTimeMillis.toDouble() / 1000).toInt(),
|
||||
it.horizontalAccuracy,
|
||||
it.heading,
|
||||
it.proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
it.replyMarkup
|
||||
)
|
||||
} else {
|
||||
editLiveLocation(
|
||||
capturedLiveLocationMessage,
|
||||
it.latitude,
|
||||
it.longitude,
|
||||
it.horizontalAccuracy,
|
||||
it.heading,
|
||||
it.proximityAlertRadius,
|
||||
it.replyMarkup
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
|
||||
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
|
||||
*/
|
||||
@JvmName("handleLiveLocationWithLocation")
|
||||
@JsName("handleLiveLocationWithLocation")
|
||||
suspend fun TelegramBot.handleLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
locationsFlow: Flow<Location>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
chatId,
|
||||
locationsFlow.map {
|
||||
EditLiveLocationInfo(
|
||||
it.latitude,
|
||||
it.longitude,
|
||||
it.horizontalAccuracy,
|
||||
(it as? LiveLocation) ?.heading,
|
||||
(it as? LiveLocation) ?.proximityAlertRadius,
|
||||
(it as? WithReplyMarkup) ?.replyMarkup as? InlineKeyboardMarkup
|
||||
)
|
||||
},
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
|
||||
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
|
||||
*/
|
||||
@JvmName("handleLiveLocationWithLatLong")
|
||||
@JsName("handleLiveLocationWithLatLong")
|
||||
suspend fun TelegramBot.handleLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
locationsFlow: Flow<Pair<Double, Double>>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
chatId,
|
||||
locationsFlow.map { (lat, long) ->
|
||||
EditLiveLocationInfo(
|
||||
lat,
|
||||
long
|
||||
)
|
||||
},
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedWithTextSources
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.caption.editMessageCaption
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.media.editMessageMedia
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
import dev.inmo.tgbotapi.types.media.TelegramMedia
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun <T> TelegramBot.edit(
|
||||
message: ContentMessage<T>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message, text, parseMode, replyMarkup)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun <T> TelegramBot.edit(
|
||||
message: ContentMessage<T>,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message, entities, replyMarkup)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<LocationContent>,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(
|
||||
chatId, messageId, location, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat, messageId, location, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<LocationContent>,
|
||||
location: LiveLocation,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message, location, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chatId, messageId, media, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chat, messageId, media, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<MediaContent>,
|
||||
media: TelegramMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(message, media, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chat, messageId, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(message, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message, entities, disableWebPagePreview, replyMarkup)
|
||||
@@ -11,7 +11,9 @@ import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
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.content.MediaContent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -48,8 +50,9 @@ suspend fun <T> TelegramBot.editMessageCaption(
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) as ContentMessage<T>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,6 +87,20 @@ suspend fun <T> TelegramBot.editMessageCaption(
|
||||
message: ContentMessage<T>,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup) as ContentMessage<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not media message this method will throw an exception")
|
||||
suspend fun <T> TelegramBot.editMessageCaption(
|
||||
message: Message,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {
|
||||
return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
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.content.TextContent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -87,3 +89,15 @@ suspend fun TelegramBot.editMessageText(
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
* as a builder for that
|
||||
*/
|
||||
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: Message,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
|
||||
@@ -16,7 +16,227 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChat: Chat,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
toChat: Chat,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChat: Chat,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
toChat: Chat,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
message: Message,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, message.messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
message: Message,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
@@ -26,7 +246,18 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(fromChatId, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -34,8 +265,8 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
@@ -44,15 +275,26 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
toChatId,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
@@ -61,15 +303,26 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChatId,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
fromChat: Chat,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
@@ -78,7 +331,19 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -86,40 +351,7 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChatId, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
message: Message,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChat, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -128,7 +360,17 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
CopyMessage(fromChatId, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
CopyMessage(
|
||||
fromChatId,
|
||||
messageId,
|
||||
toChatId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -136,8 +378,8 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
fromChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -145,15 +387,25 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
toChatId,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -161,15 +413,25 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChatId,
|
||||
messageId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
fromChat: Chat,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -177,34 +439,14 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
message: Message,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChatId, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
toChat: Chat,
|
||||
message: Message,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChat, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
toChat.id,
|
||||
fromChat.id,
|
||||
messageId,
|
||||
entities,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.*
|
||||
import dev.inmo.tgbotapi.extensions.api.send.games.sendGame
|
||||
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
||||
import dev.inmo.tgbotapi.extensions.api.send.payments.sendInvoice
|
||||
@@ -29,6 +31,10 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import dev.inmo.tgbotapi.types.venue.Venue
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
|
||||
// Contact
|
||||
@@ -950,7 +956,18 @@ suspend inline fun TelegramBot.reply(
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, to.chat.id, messageId, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(
|
||||
to.chat.id,
|
||||
fromChatId,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
to.messageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
@@ -995,6 +1012,80 @@ suspend fun TelegramBot.reply(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||
*
|
||||
* @see handleLiveLocation
|
||||
*/
|
||||
suspend fun TelegramBot.reply(
|
||||
message: Message,
|
||||
locationsFlow: Flow<EditLiveLocationInfo>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = handleLiveLocation(
|
||||
message.chat.id,
|
||||
locationsFlow,
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
message.messageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
|
||||
/**
|
||||
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||
*
|
||||
* @see handleLiveLocation
|
||||
*/
|
||||
@JvmName("replyLiveLocationWithLocation")
|
||||
@JsName("replyLiveLocationWithLocation")
|
||||
suspend fun TelegramBot.reply(
|
||||
message: Message,
|
||||
locationsFlow: Flow<Location>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
message.chat.id,
|
||||
locationsFlow,
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
message.messageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||
*
|
||||
* @see handleLiveLocation
|
||||
*/
|
||||
@JvmName("replyLiveLocationWithLatLong")
|
||||
@JsName("replyLiveLocationWithLatLong")
|
||||
suspend fun TelegramBot.reply(
|
||||
message: Message,
|
||||
locationsFlow: Flow<Pair<Double, Double>>,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) {
|
||||
handleLiveLocation(
|
||||
message.chat.id,
|
||||
locationsFlow,
|
||||
liveTimeMillis,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
message.messageId,
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.reply(
|
||||
to: Message,
|
||||
mediaFile: TelegramMediaFile,
|
||||
|
||||
@@ -22,7 +22,7 @@ suspend fun <T> TelegramBot.withAction(
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
val botActionJob = CoroutineScope(coroutineContext).launch {
|
||||
val botActionJob = CoroutineScope(currentCoroutineContext()).launch {
|
||||
while (isActive) {
|
||||
delay(refreshTime)
|
||||
safelyWithoutExceptions {
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
|
||||
import dev.inmo.tgbotapi.requests.send.SendStaticLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendLiveLocation(
|
||||
chatId,
|
||||
latitude,
|
||||
longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chatId,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
latitude,
|
||||
longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
livePeriod,
|
||||
horizontalAccuracy,
|
||||
heading,
|
||||
proximityAlertRadius,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||
*/
|
||||
suspend fun TelegramBot.sendLiveLocation(
|
||||
chat: Chat,
|
||||
location: Location,
|
||||
livePeriod: Seconds,
|
||||
horizontalAccuracy: Meters? = null,
|
||||
heading: Degrees? = null,
|
||||
proximityAlertRadius: Meters? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||
|
||||
/**
|
||||
@@ -40,7 +41,7 @@ suspend fun TelegramBot.sendLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
@@ -87,7 +88,7 @@ suspend fun TelegramBot.sendLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
@@ -125,7 +126,7 @@ suspend fun TelegramBot.sendStaticLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendStaticLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
@@ -154,7 +155,7 @@ suspend fun TelegramBot.sendStaticLocation(
|
||||
*/
|
||||
suspend fun TelegramBot.sendStaticLocation(
|
||||
chat: Chat,
|
||||
location: StaticLocation,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,56 +1,20 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
project.description = "Behaviour Builder extension with built-in FSM"
|
||||
project.description = "Behaviour Builder DSL"
|
||||
|
||||
apply from: "../publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api project(":tgbotapi.behaviour_builder")
|
||||
api "dev.inmo:micro_utils.fsm.common:$micro_utils_version"
|
||||
api libs.microutils.fsm.common
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ messages and filter messages for context which will be used in subcontext. Full
|
||||
telegramBotWithBehaviour(TOKEN) {
|
||||
onText(
|
||||
includeFilterByChatInBehaviourSubContext = true, // if false - last lambda will receive all messages instead of filtered by chat messages
|
||||
additionalFilter = { message: CommonMessage<TextContent> ->
|
||||
additionalFilter = { message: TextMessage ->
|
||||
// here you may check incoming message for any requirements before it will be passed to the main lambda
|
||||
}
|
||||
) { message: CommonMessage<TextContent> -> // this here is `BehaviourContext`
|
||||
) { message: TextMessage -> // this here is `BehaviourContext`
|
||||
// here put your actions and additional waiters
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ Waiters targeted to get some content "here and now", they must be used inside so
|
||||
|
||||
```kotlin
|
||||
telegramBotWithBehaviour(TOKEN) {
|
||||
onCommand("start") { message: CommonMessage<TextContent> ->
|
||||
onCommand("start") { message: TextMessage ->
|
||||
val userPhotos = waitPhoto(
|
||||
SendTextMessage(it.chat.id, "Ok, send me some photo, please"), // init request, can be any `Request` object
|
||||
{ update: Update -> // That is update which is NOT passed requirements. In current context we expect some photo, but received something else
|
||||
|
||||
@@ -1,55 +1,19 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
project.description = "Behaviour Builder DSL"
|
||||
|
||||
apply from: "../publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api project(":tgbotapi.utils")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,20 +57,6 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope {
|
||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
triggersHolder: TriggersHolder = TriggersHolder()
|
||||
): BehaviourContext
|
||||
|
||||
/**
|
||||
* @param updatesFilter unused
|
||||
*/
|
||||
@Deprecated("Do not use this method")
|
||||
fun copy(
|
||||
bot: TelegramBot = this.bot,
|
||||
scope: CoroutineScope = this.scope,
|
||||
broadcastChannelsSize: Int = 100,
|
||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
triggersHolder: TriggersHolder = TriggersHolder(),
|
||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||
): BehaviourContext = copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder)
|
||||
}
|
||||
|
||||
class DefaultBehaviourContext(
|
||||
@@ -79,9 +65,7 @@ class DefaultBehaviourContext(
|
||||
broadcastChannelsSize: Int = 100,
|
||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||
private val upstreamUpdatesFlow: Flow<Update>? = null,
|
||||
override val triggersHolder: TriggersHolder = TriggersHolder(),
|
||||
@Deprecated("This parameter is not used anymore")
|
||||
private val updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||
override val triggersHolder: TriggersHolder = TriggersHolder()
|
||||
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
|
||||
|
||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
||||
@@ -137,19 +121,6 @@ fun <BC : BehaviourContext> BC.createSubContext(
|
||||
triggersHolder = triggersHolder
|
||||
) as BC
|
||||
|
||||
/**
|
||||
* Creates new [BehaviourContext] using its [BehaviourContext.copy] method
|
||||
*
|
||||
* @param updatesFilter This param will not be used anymore
|
||||
*/
|
||||
@Deprecated("It is not recommended to use updates filter anymore")
|
||||
fun <BC : BehaviourContext> BC.createSubContext(
|
||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
||||
) = createSubContext(scope, triggersHolder, updatesUpstreamFlow)
|
||||
|
||||
/**
|
||||
* Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext]
|
||||
*
|
||||
@@ -187,27 +158,6 @@ suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
|
||||
* using [doInContext]
|
||||
*
|
||||
* @param stopOnCompletion ___TRUE BY DEFAULT___
|
||||
* @param updatesFilter Is not used anymore
|
||||
*/
|
||||
@Deprecated("It is not recommended to use updates filter anymore")
|
||||
suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter(
|
||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
||||
stopOnCompletion: Boolean = true,
|
||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
||||
): T {
|
||||
return createSubContextAndDoWithUpdatesFilter(
|
||||
scope, triggersHolder, updatesUpstreamFlow, stopOnCompletion, behaviourContextReceiver
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will cancel ALL subsequent contexts, expectations and waiters
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.callbackQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.queries.callback.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias CallbackQueryMapper<T> = suspend T.() -> T?
|
||||
|
||||
@@ -22,7 +20,7 @@ suspend inline fun <reified O> BehaviourContext.waitCallbackQueries(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.asCallbackQueryUpdate() ?.data as O).let(::listOfNotNull)
|
||||
(it.callbackQueryUpdateOrNull() ?.data as O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatJoinRequestUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias ChatJoinRequestsMapper = suspend ChatJoinRequest.() -> ChatJoinRequest?
|
||||
|
||||
@@ -20,7 +18,7 @@ suspend inline fun <reified O> BehaviourContext.internalWaitChatJoinRequests(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.asChatJoinRequestUpdate() ?.data as? O).let(::listOfNotNull)
|
||||
(it.chatJoinRequestUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
|
||||
@@ -10,7 +9,6 @@ import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias ChatMemberUpdatedMapper<T> = suspend T.() -> T?
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.chosenInlineResultUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias ChosenInlineResultMapper<T> = suspend T.() -> T?
|
||||
|
||||
@@ -20,7 +18,7 @@ suspend inline fun <reified O> BehaviourContext.waitChosenInlineResults(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.asChosenInlineResultUpdate() ?.data as? O).let(::listOfNotNull)
|
||||
(it.chosenInlineResultUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChosenInlineResult(
|
||||
|
||||
@@ -3,18 +3,9 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -4,18 +4,12 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -3,22 +3,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asCommonMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedContent(
|
||||
|
||||
@@ -3,23 +3,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asCommonMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedContentMessage(
|
||||
@@ -32,7 +25,7 @@ suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedConte
|
||||
) {
|
||||
val messages = when (it) {
|
||||
is BaseEditMessageUpdate -> {
|
||||
val commonMessage = it.data.asCommonMessage() ?: return@expectFlow emptyList()
|
||||
val commonMessage = it.data.commonMessageOrNull() ?: return@expectFlow emptyList()
|
||||
if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) {
|
||||
listOf(commonMessage)
|
||||
} else {
|
||||
|
||||
@@ -3,19 +3,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias EventMessageToEventMapper<T> = suspend ChatEventMessage<T>.() -> T?
|
||||
|
||||
@@ -27,7 +24,7 @@ suspend inline fun <reified O : ChatEvent> BehaviourContext.waitEvents(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent<O>() ?.chatEvent.let(::listOfNotNull)
|
||||
it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.withEvent<O>() ?.chatEvent.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChannelEvents(
|
||||
|
||||
@@ -3,19 +3,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.ChannelEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : ChatEvent> BehaviourContext.waitEventsMessages(
|
||||
@@ -25,7 +22,7 @@ suspend inline fun <reified O : ChatEvent> BehaviourContext.waitEventsMessages(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.withEvent<O>().let(::listOfNotNull)
|
||||
it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.withEvent<O>().let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChannelEventsMessages(
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.inlineQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias InlineQueryMapper<T> = suspend T.() -> T?
|
||||
|
||||
@@ -20,7 +18,7 @@ suspend inline fun <reified O : InlineQuery> BehaviourContext.waitInlineQueries(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.asInlineQueryUpdate() ?.data as? O).let(::listOfNotNull)
|
||||
(it.inlineQueryUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitAnyInlineQuery(
|
||||
|
||||
@@ -2,15 +2,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -20,7 +15,7 @@ suspend inline fun <reified T : MediaGroupContent> BehaviourContext.buildMediaGr
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<List<MediaGroupMessage<T>>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update ->
|
||||
update.asSentMediaGroupUpdate() ?.data ?.let { mediaGroup ->
|
||||
update.sentMediaGroupUpdateOrNull() ?.data ?.let { mediaGroup ->
|
||||
val mapped = mediaGroup.mapNotNull { it.withContent<T>() }
|
||||
listOf(
|
||||
mapped
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.messageUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.passportMessageOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.PassportMessage
|
||||
import dev.inmo.tgbotapi.types.passport.PassportData
|
||||
@@ -11,7 +10,6 @@ import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportEle
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias PassportMessageMapper = suspend PassportMessage.() -> PassportData
|
||||
|
||||
@@ -23,7 +21,7 @@ suspend inline fun <reified O : EncryptedPassportElement> BehaviourContext.waitP
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.asMessageUpdate() ?.data ?.asPassportMessage() ?.passportData ?.data ?.filterIsInstance<O>() ?: emptyList()
|
||||
it.messageUpdateOrNull() ?.data ?.passportMessageOrNull() ?.passportData ?.data ?.filterIsInstance<O>() ?: emptyList()
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitAnyPassportMessages(
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.pollAnswerUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer?
|
||||
|
||||
@@ -19,5 +15,5 @@ suspend fun BehaviourContext.waitPollAnswers(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.asPollAnswerUpdate() ?.data.let(::listOfNotNull)
|
||||
it.pollAnswerUpdateOrNull() ?.data.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.pollUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias PollMapper<T> = suspend T.() -> T?
|
||||
|
||||
@@ -20,7 +18,7 @@ suspend inline fun <reified O : Poll> BehaviourContext.waitPolls(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.asPollUpdate() ?.data as? O).let(::listOfNotNull)
|
||||
(it.pollUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.preCheckoutQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery?
|
||||
|
||||
@@ -19,5 +15,5 @@ suspend fun BehaviourContext.waitPreCheckoutQueries(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.asPreCheckoutQueryUpdate() ?.data.let(::listOfNotNull)
|
||||
it.preCheckoutQueryUpdateOrNull() ?.data.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.shippingQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias ShippingQueryMapper = suspend ShippingQuery.() -> ShippingQuery?
|
||||
|
||||
@@ -17,5 +15,5 @@ suspend fun BehaviourContext.waitShippingQueries(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.asShippingQueryUpdate() ?.data).let(::listOfNotNull)
|
||||
(it.shippingQueryUpdateOrNull() ?.data).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
||||
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,8 +9,8 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilte
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserCallbackQueryMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus
|
||||
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
||||
import dev.inmo.tgbotapi.extensions.utils.callbackQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.queries.callback.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -21,7 +21,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : CallbackQuery> B
|
||||
markerFactory: MarkerFactory<in T, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asCallbackQueryUpdate() ?.data as? T) ?.let(::listOfNotNull)
|
||||
(it.callbackQueryUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ suspend fun <BC : BehaviourContext> BC.onDataCallbackQuery(
|
||||
markerFactory: MarkerFactory<in DataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DataCallbackQuery>
|
||||
) = onDataCallbackQuery(
|
||||
initialFilter = initialFilter + {
|
||||
initialFilter = initialFilter * {
|
||||
it.data.matches(dataRegex)
|
||||
},
|
||||
subcontextUpdatesFilter,
|
||||
@@ -239,7 +239,7 @@ suspend fun <BC : BehaviourContext> BC.onInlineMessageIdDataCallbackQuery(
|
||||
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InlineMessageIdDataCallbackQuery>
|
||||
) = onInlineMessageIdDataCallbackQuery(
|
||||
initialFilter = initialFilter + {
|
||||
initialFilter = initialFilter * {
|
||||
it.data.matches(dataRegex)
|
||||
},
|
||||
subcontextUpdatesFilter,
|
||||
@@ -367,7 +367,7 @@ suspend fun <BC : BehaviourContext> BC.onMessageDataCallbackQuery(
|
||||
markerFactory: MarkerFactory<in MessageDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MessageDataCallbackQuery>
|
||||
) = onMessageDataCallbackQuery(
|
||||
initialFilter = initialFilter + {
|
||||
initialFilter = initialFilter * {
|
||||
it.data.matches(dataRegex)
|
||||
},
|
||||
subcontextUpdatesFilter,
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ChatJoinRequestFil
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatJoinRequestMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatJoinRequestUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -29,5 +29,5 @@ suspend fun <BC : BehaviourContext> BC.onChatJoinRequest(
|
||||
markerFactory: MarkerFactory<in ChatJoinRequest, Any> = ByChatChatJoinRequestMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatJoinRequest>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asChatJoinRequestUpdate() ?.data) ?.let(::listOfNotNull)
|
||||
(it.chatJoinRequestUpdateOrNull() ?.data) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ 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.ByUserIdChosenInlineResultMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.chosenInlineResultUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -16,7 +16,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : ChosenInlineResu
|
||||
markerFactory: MarkerFactory<in T, Any> = ByUserIdChosenInlineResultMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asChosenInlineResultUpdate() ?.data as? T) ?.let(::listOfNotNull)
|
||||
(it.chosenInlineResultUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
|
||||
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.times
|
||||
import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
|
||||
import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.coroutines.Job
|
||||
|
||||
@@ -21,9 +21,9 @@ internal suspend fun <BC : BehaviourContext> BC.commandUncounted(
|
||||
commandRegex: Regex,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = onText(
|
||||
CommonMessageFilter<TextContent> { message ->
|
||||
val content = message.content
|
||||
@@ -34,7 +34,7 @@ internal suspend fun <BC : BehaviourContext> BC.commandUncounted(
|
||||
true
|
||||
}
|
||||
sizeRequirement && textSources.any {
|
||||
commandRegex.matches(it.asBotCommandTextSource() ?.command ?: return@any false)
|
||||
commandRegex.matches(it.botCommandTextSourceOrNull() ?.command ?: return@any false)
|
||||
}
|
||||
}.let {
|
||||
initialFilter ?.times(it) ?: it
|
||||
@@ -48,9 +48,9 @@ suspend fun <BC : BehaviourContext> BC.command(
|
||||
commandRegex: Regex,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = runCatchingSafely {
|
||||
commandUncounted(
|
||||
commandRegex,
|
||||
@@ -77,35 +77,35 @@ suspend fun <BC : BehaviourContext> BC.command(
|
||||
command: String,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||
commandRegex: Regex,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||
command: String,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
commandRegex: Regex,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
) = command(
|
||||
commandRegex,
|
||||
requireOnlyCommandInMessage = false,
|
||||
@@ -123,9 +123,9 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
command: String,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
) = commandWithArgs(
|
||||
command.toRegex(),
|
||||
initialFilter = initialFilter,
|
||||
@@ -137,15 +137,15 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||
commandRegex: Regex,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||
command: String,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -8,22 +8,21 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
|
||||
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.times
|
||||
import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
|
||||
import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import kotlinx.coroutines.Job
|
||||
|
||||
|
||||
@PreviewFeature
|
||||
suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = onText(
|
||||
CommonMessageFilter<TextContent> { message ->
|
||||
val content = message.content
|
||||
@@ -34,7 +33,7 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
||||
true
|
||||
}
|
||||
sizeRequirement && textSources.any {
|
||||
val command = it.asBotCommandTextSource() ?.command ?: return@any false
|
||||
val command = it.botCommandTextSourceOrNull() ?.command ?: return@any false
|
||||
!triggersHolder.handleableCommandsHolder.isHandled(command)
|
||||
}
|
||||
}.let {
|
||||
@@ -49,17 +48,17 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
||||
suspend fun <BC : BehaviourContext> BC.onUnhandledCommand(
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
): Job = unhandledCommand(requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@PreviewFeature
|
||||
suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Map<String, Array<String>>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
||||
) = onUnhandledCommand(
|
||||
requireOnlyCommandInMessage = false,
|
||||
initialFilter = initialFilter,
|
||||
@@ -75,7 +74,7 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
||||
@PreviewFeature
|
||||
suspend fun <BC : BehaviourContext> BC.onUnhandledCommandWithArgs(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Map<String, Array<String>>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
||||
): Job = unhandledCommandWithArgs(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -12,12 +12,9 @@ import dev.inmo.tgbotapi.extensions.utils.whenCommonMessage
|
||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||
|
||||
typealias CommonMessageFilter<T> = SimpleFilter<CommonMessage<T>>
|
||||
|
||||
@@ -75,9 +72,9 @@ suspend fun <BC : BehaviourContext> BC.onContentMessage(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onContact(
|
||||
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<ContactContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<ContactContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<ContactContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -99,9 +96,9 @@ suspend fun <BC : BehaviourContext> BC.onContact(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onDice(
|
||||
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DiceContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -123,9 +120,9 @@ suspend fun <BC : BehaviourContext> BC.onDice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onGame(
|
||||
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<GameContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<GameContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<GameContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -147,9 +144,9 @@ suspend fun <BC : BehaviourContext> BC.onGame(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onLocation(
|
||||
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<LocationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<LocationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<LocationContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -171,9 +168,9 @@ suspend fun <BC : BehaviourContext> BC.onLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
||||
initialFilter: CommonMessageFilter<LiveLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<LiveLocationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<LiveLocationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<LiveLocationContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LiveLocationMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in LiveLocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LiveLocationMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -195,9 +192,9 @@ suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
||||
initialFilter: CommonMessageFilter<StaticLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<StaticLocationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<StaticLocationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<StaticLocationContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StaticLocationMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in StaticLocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StaticLocationMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -219,9 +216,9 @@ suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onPoll(
|
||||
initialFilter: CommonMessageFilter<PollContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<PollContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<PollContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<PollContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PollMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in PollMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PollMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -243,9 +240,9 @@ suspend fun <BC : BehaviourContext> BC.onPoll(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onText(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -267,9 +264,9 @@ suspend fun <BC : BehaviourContext> BC.onText(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVenue(
|
||||
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VenueContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VenueContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VenueContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -291,9 +288,9 @@ suspend fun <BC : BehaviourContext> BC.onVenue(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
||||
initialFilter: CommonMessageFilter<AudioMediaGroupContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AudioMediaGroupContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AudioMediaGroupContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AudioMediaGroupContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -315,9 +312,9 @@ suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
||||
initialFilter: CommonMessageFilter<DocumentMediaGroupContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DocumentMediaGroupContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DocumentMediaGroupContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DocumentMediaGroupContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -339,9 +336,9 @@ suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
||||
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextedMediaContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextedMediaContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextedMediaContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -363,9 +360,9 @@ suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
||||
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MediaCollectionContent<TelegramMediaFile>>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MediaCollectionContent<TelegramMediaFile>>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MediaCollectionContent<TelegramMediaFile>>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -387,9 +384,9 @@ suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onMedia(
|
||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MediaContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MediaContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MediaContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -411,9 +408,9 @@ suspend fun <BC : BehaviourContext> BC.onMedia(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onAnimation(
|
||||
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AnimationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AnimationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AnimationContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -435,9 +432,9 @@ suspend fun <BC : BehaviourContext> BC.onAnimation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onAudio(
|
||||
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AudioContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AudioContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AudioContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -459,9 +456,9 @@ suspend fun <BC : BehaviourContext> BC.onAudio(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onDocument(
|
||||
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DocumentContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DocumentContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DocumentContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -483,9 +480,9 @@ suspend fun <BC : BehaviourContext> BC.onDocument(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onPhoto(
|
||||
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<PhotoContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<PhotoContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<PhotoContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -507,9 +504,9 @@ suspend fun <BC : BehaviourContext> BC.onPhoto(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onSticker(
|
||||
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<StickerContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<StickerContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<StickerContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -531,9 +528,9 @@ suspend fun <BC : BehaviourContext> BC.onSticker(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVideo(
|
||||
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VideoContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VideoContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VideoContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -555,9 +552,9 @@ suspend fun <BC : BehaviourContext> BC.onVideo(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
||||
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VideoNoteContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VideoNoteContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VideoNoteContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -579,9 +576,9 @@ suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onVoice(
|
||||
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VoiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VoiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VoiceContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -603,9 +600,9 @@ suspend fun <BC : BehaviourContext> BC.onVoice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onInvoice(
|
||||
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<InvoiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<InvoiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<InvoiceContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
||||
) = onContentMessageWithType(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
|
||||
@@ -20,17 +20,11 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilte
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
||||
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.utils.asEditMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.editMessageUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaCollectionContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -41,7 +35,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent>
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<T>>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
when (it) {
|
||||
is BaseEditMessageUpdate -> (it.asEditMessageUpdate() ?.data ?.withContent<T>())
|
||||
is BaseEditMessageUpdate -> (it.editMessageUpdateOrNull() ?.data ?.withContent<T>())
|
||||
else -> null
|
||||
} ?.let(::listOfNotNull)
|
||||
}
|
||||
@@ -85,9 +79,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedContentMessage(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedContact(
|
||||
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<ContactContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<ContactContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<ContactContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -109,9 +103,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedContact(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedDice(
|
||||
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DiceContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -133,9 +127,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedDice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedGame(
|
||||
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<GameContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<GameContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<GameContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -157,9 +151,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedGame(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedLocation(
|
||||
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<LocationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<LocationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<LocationContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -181,9 +175,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedLocation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedText(
|
||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -205,9 +199,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedText(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVenue(
|
||||
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VenueContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VenueContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VenueContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -229,9 +223,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedVenue(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
|
||||
initialFilter: CommonMessageFilter<AudioMediaGroupContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AudioMediaGroupContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AudioMediaGroupContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AudioMediaGroupContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -253,9 +247,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
|
||||
initialFilter: CommonMessageFilter<DocumentMediaGroupContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DocumentMediaGroupContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DocumentMediaGroupContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DocumentMediaGroupContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -277,9 +271,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedTextedMediaContent(
|
||||
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextedMediaContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextedMediaContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextedMediaContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -301,9 +295,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedTextedMediaContent(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedMediaCollection(
|
||||
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MediaCollectionContent<TelegramMediaFile>>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MediaCollectionContent<TelegramMediaFile>>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MediaCollectionContent<TelegramMediaFile>>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -325,9 +319,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedMediaCollection(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedMedia(
|
||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MediaContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MediaContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MediaContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -349,9 +343,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedMedia(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedAnimation(
|
||||
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AnimationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AnimationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AnimationContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -373,9 +367,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedAnimation(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedAudio(
|
||||
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AudioContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AudioContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AudioContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -397,9 +391,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedAudio(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedDocument(
|
||||
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DocumentContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DocumentContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DocumentContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -421,9 +415,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedDocument(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedPhoto(
|
||||
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<PhotoContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<PhotoContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<PhotoContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -445,9 +439,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedPhoto(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedSticker(
|
||||
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<StickerContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<StickerContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<StickerContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -469,9 +463,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedSticker(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVideo(
|
||||
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VideoContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VideoContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VideoContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -493,9 +487,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedVideo(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVideoNote(
|
||||
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VideoNoteContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VideoNoteContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VideoNoteContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -517,9 +511,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedVideoNote(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedVoice(
|
||||
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VoiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VoiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VoiceContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
@@ -541,9 +535,9 @@ suspend fun <BC : BehaviourContext> BC.onEditedVoice(
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onEditedInvoice(
|
||||
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<InvoiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<InvoiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<InvoiceContent>>
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
||||
)= onEditedContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
|
||||
@@ -7,8 +7,8 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
|
||||
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.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asBaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatEventMessageOrNull
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
@@ -24,7 +24,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.on
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<T>>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
(it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.takeIf { it.chatEvent is T } as? ChatEventMessage<T>) ?.let(::listOfNotNull)
|
||||
(it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.takeIf { it.chatEvent is T } as? ChatEventMessage<T>) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.InlineQueryFilterB
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserInlineQueryMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.inlineQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -15,7 +15,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : InlineQuery> BC.
|
||||
markerFactory: MarkerFactory<in T, Any> = ByUserInlineQueryMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asInlineQueryUpdate() ?.data as? T) ?.let(::listOfNotNull)
|
||||
(it.inlineQueryUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
|
||||
@@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessagesFilterByCh
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMediaGroupMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
@@ -20,7 +20,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MediaGroupConten
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<T>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<T>>>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asSentMediaGroupUpdate() ?.data ?.takeIf { messages ->
|
||||
(it.sentMediaGroupUpdateOrNull() ?.data ?.takeIf { messages ->
|
||||
messages.all { message ->
|
||||
message.content is T
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha
|
||||
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.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.messageUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.passportMessageOrNull
|
||||
import dev.inmo.tgbotapi.types.message.PassportMessage
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportElement
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
@@ -17,7 +17,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : EncryptedPasspor
|
||||
markerFactory: MarkerFactory<in PassportMessage, Any> = ByChatMessageMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PassportMessage>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asMessageUpdate() ?.data ?.asPassportMessage() ?.takeIf { it.passportData.data.any { it is T } }) ?.let(::listOfNotNull)
|
||||
(it.messageUpdateOrNull() ?.data ?.passportMessageOrNull() ?.takeIf { it.passportData.data.any { it is T } }) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ 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.ByIdPollAnswerMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.pollAnswerUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -16,7 +16,7 @@ internal suspend inline fun <BC : BehaviourContext> BC.onPollAnswered(
|
||||
markerFactory: MarkerFactory<in PollAnswer, Any> = ByIdPollAnswerMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PollAnswer>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asPollAnswerUpdate() ?.data) ?.let(::listOfNotNull)
|
||||
(it.pollAnswerUpdateOrNull() ?.data) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ 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.ByIdPollMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.pollUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -16,7 +16,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : Poll> BC.onPollU
|
||||
markerFactory: MarkerFactory<in T, Any> = ByIdPollMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asPollUpdate() ?.data as? T) ?.let(::listOfNotNull)
|
||||
(it.pollUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.PreCheckoutQueryFi
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserPreCheckoutQueryMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.preCheckoutQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -31,5 +31,5 @@ suspend fun <BC : BehaviourContext> BC.onPreCheckoutQuery(
|
||||
markerFactory: MarkerFactory<in PreCheckoutQuery, Any> = ByUserPreCheckoutQueryMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PreCheckoutQuery>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asPreCheckoutQueryUpdate() ?.data) ?.let(::listOfNotNull)
|
||||
(it.preCheckoutQueryUpdateOrNull() ?.data) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ShippingQueryFilte
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserShippingQueryMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.shippingQueryUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
@@ -31,5 +31,5 @@ suspend fun <BC : BehaviourContext> BC.onShippingQuery(
|
||||
markerFactory: MarkerFactory<in ShippingQuery, Any> = ByUserShippingQueryMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ShippingQuery>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.asShippingQueryUpdate() ?.data) ?.let(::listOfNotNull)
|
||||
(it.shippingQueryUpdateOrNull() ?.data) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.utils
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTypeReceiver
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitEditedLocation
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitEditedLocationMessage
|
||||
import dev.inmo.tgbotapi.types.location.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
|
||||
|
||||
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
|
||||
|
||||
object ByUserCallbackQueryMarkerFactory : MarkerFactory<CallbackQuery, Any> {
|
||||
override suspend fun invoke(data: CallbackQuery) = data.user
|
||||
|
||||
@@ -1,107 +1,63 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.google.devtools.ksp"
|
||||
}
|
||||
|
||||
project.version = "$library_version"
|
||||
project.group = "$library_group"
|
||||
project.description = "Core part of tgbotapi with all (and only) required functionality for working with Telegram Bot API"
|
||||
|
||||
apply from: "../publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||
api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
|
||||
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
||||
api libs.kotlin.coroutines
|
||||
api libs.kotlin.serialization
|
||||
api libs.kotlin.serialization.properties
|
||||
|
||||
api "com.soywiz.korlibs.klock:klock:$korlibs_version"
|
||||
api "com.soywiz.korlibs.krypto:krypto:$korlibs_version"
|
||||
api "com.benasher44:uuid:$uuid_version"
|
||||
api libs.korlibs.klock
|
||||
api libs.korlibs.krypto
|
||||
api libs.uuid
|
||||
|
||||
api "dev.inmo:micro_utils.coroutines:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.serialization.base64:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.serialization.encapsulator:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.serialization.typed_serializer:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.ktor.common:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.language_codes:$micro_utils_version"
|
||||
api libs.microutils.coroutines
|
||||
api libs.microutils.serialization.base64
|
||||
api libs.microutils.serialization.encapsulator
|
||||
api libs.microutils.serialization.typedSerializer
|
||||
api libs.microutils.ktor.common
|
||||
api libs.microutils.languageCodes
|
||||
|
||||
api "io.ktor:ktor-client-core:$ktor_version"
|
||||
api libs.ktor.client.core
|
||||
|
||||
implementation project(":tgbotapi.ksp:lib")
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-common')
|
||||
implementation kotlin('test-annotations-common')
|
||||
implementation project(":tgbotapi.utils")
|
||||
}
|
||||
}
|
||||
|
||||
jvmMain {
|
||||
dependencies {
|
||||
api "io.ktor:ktor-server:$ktor_version"
|
||||
api "io.ktor:ktor-server-host-common:$ktor_version"
|
||||
api libs.ktor.server
|
||||
api libs.ktor.server.host.common
|
||||
|
||||
api "io.ktor:ktor-client-cio:$ktor_version"
|
||||
api libs.ktor.client.cio
|
||||
|
||||
api "javax.activation:activation:$javax_activation_version"
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
implementation kotlin('test-js')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targets.all {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"]
|
||||
api libs.javax.activation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
dependencies {
|
||||
add("kspCommonMainMetadata", project(":tgbotapi.ksp:processor"))
|
||||
add("kspJvm", project(":tgbotapi.ksp:processor"))
|
||||
}
|
||||
|
||||
ksp {
|
||||
arg("cctargetPackage", "dev.inmo.tgbotapi.extensions.utils")
|
||||
arg("ccoutputFileName", "ClassCastsNew")
|
||||
arg("ccoutputFolder", project(":tgbotapi.utils").file("src/commonMain/kotlin").absolutePath)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Priced
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface CommonSendInvoiceData : Titled, Currencied, Priced {
|
||||
val description: String
|
||||
val payload: String
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
|
||||
/**
|
||||
@@ -7,6 +8,7 @@ import dev.inmo.tgbotapi.types.chat.User
|
||||
*
|
||||
* @see FromUser
|
||||
*/
|
||||
@ClassCastsIncluded
|
||||
interface WithUser {
|
||||
val user: User
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package dev.inmo.tgbotapi.abstracts.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
|
||||
interface ReplyMarkup {
|
||||
val replyMarkup: KeyboardMarkup?
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.inmo.tgbotapi.abstracts.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
|
||||
interface WithReplyMarkup {
|
||||
val replyMarkup: KeyboardMarkup?
|
||||
}
|
||||
@Deprecated("Renamed", ReplaceWith("WithReplyMarkup", "dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup"))
|
||||
typealias ReplyMarkup = WithReplyMarkup
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.requests
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.MessageAction
|
||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@@ -17,7 +17,7 @@ data class StopPoll(
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
||||
) : MessageAction, SimpleRequest<Poll>, WithReplyMarkup {
|
||||
override fun method(): String = "stopPoll"
|
||||
override val resultDeserializer: DeserializationStrategy<Poll>
|
||||
get() = PollSerializer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.edit.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
interface EditReplyMessage : ReplyMarkup {
|
||||
interface EditReplyMessage : WithReplyMarkup {
|
||||
override val replyMarkup: InlineKeyboardMarkup?
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@ import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
// TODO:: Swap fromChatId and toChatId for more correct order of parameters
|
||||
|
||||
const val OrderChangingDeprecationWarn = "The order of parameters in this factory will be changed soon. To avoid unexpected behaviour, swap message id and target chat id parameters"
|
||||
|
||||
fun CopyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
@@ -27,11 +31,23 @@ fun CopyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = CopyMessage(fromChatId, toChatId, messageId, text, parseMode, null, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = CopyMessage(
|
||||
toChatId,
|
||||
fromChatId,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
null,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
fun CopyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: List<TextSource>,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -40,8 +56,57 @@ fun CopyMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = CopyMessage(
|
||||
fromChatId,
|
||||
toChatId,
|
||||
fromChatId,
|
||||
messageId,
|
||||
entities.makeString(),
|
||||
null,
|
||||
entities.toRawMessageEntities(),
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
fun CopyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = CopyMessage(
|
||||
toChatId,
|
||||
fromChatId,
|
||||
messageId,
|
||||
text,
|
||||
parseMode,
|
||||
null,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
fun CopyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
entities: List<TextSource>,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = CopyMessage(
|
||||
toChatId,
|
||||
fromChatId,
|
||||
messageId,
|
||||
entities.makeString(),
|
||||
null,
|
||||
@@ -55,10 +120,10 @@ fun CopyMessage(
|
||||
|
||||
@Serializable
|
||||
data class CopyMessage internal constructor(
|
||||
@SerialName(fromChatIdField)
|
||||
val fromChatId: ChatIdentifier,
|
||||
@SerialName(chatIdField)
|
||||
val toChatId: ChatIdentifier,
|
||||
@SerialName(fromChatIdField)
|
||||
val fromChatId: ChatIdentifier,
|
||||
@SerialName(messageIdField)
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(captionField)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package dev.inmo.tgbotapi.requests.send.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
|
||||
interface ReplyingMarkupSendMessageRequest<T: Any>: SendMessageRequest<T>, ReplyMarkup
|
||||
interface ReplyingMarkupSendMessageRequest<T: Any>: SendMessageRequest<T>, WithReplyMarkup
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.requests.send.games
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
@@ -29,7 +29,7 @@ data class SendGame (
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<ContentMessage<GameContent>>,
|
||||
ReplyMarkup {
|
||||
WithReplyMarkup {
|
||||
override fun method(): String = "sendGame"
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
|
||||
get() = commonResultDeserializer
|
||||
|
||||
@@ -72,7 +72,7 @@ data class SendInvoice(
|
||||
ChatRequest,
|
||||
DisableNotification,
|
||||
ReplyMessageId,
|
||||
ReplyMarkup,
|
||||
WithReplyMarkup,
|
||||
SendMessageRequest<ContentMessage<InvoiceContent>> {
|
||||
override fun method(): String = "sendInvoice"
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
||||
|
||||
@@ -11,6 +11,8 @@ import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
import kotlinx.serialization.json.longOrNull
|
||||
|
||||
const val internalLinkBeginning = "https://t.me"
|
||||
|
||||
@Serializable(ChatIdentifierSerializer::class)
|
||||
sealed class ChatIdentifier
|
||||
|
||||
@@ -26,16 +28,16 @@ data class ChatId(
|
||||
* https://core.telegram.org/bots/api#formatting-options
|
||||
*/
|
||||
@Warning("This API have restrictions in Telegram System")
|
||||
val Identifier.link: String
|
||||
val Identifier.userLink: String
|
||||
get() = "tg://user?id=$this"
|
||||
/**
|
||||
* https://core.telegram.org/bots/api#formatting-options
|
||||
*/
|
||||
@Warning("This API have restrictions in Telegram System")
|
||||
val UserId.link: String
|
||||
get() = chatId.link
|
||||
val UserId.userLink: String
|
||||
get() = chatId.userLink
|
||||
val User.link: String
|
||||
get() = id.link
|
||||
get() = id.userLink
|
||||
|
||||
typealias UserId = ChatId
|
||||
|
||||
|
||||
@@ -415,6 +415,7 @@ const val mediaField = "media"
|
||||
const val disableEditMessageField = "disable_edit_message"
|
||||
const val scoreField = "score"
|
||||
const val forceField = "force"
|
||||
const val forceReplyField = "force_reply"
|
||||
|
||||
const val regularPollType = "regular"
|
||||
const val quizPollType = "quiz"
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
||||
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(InlineQueryResultSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
interface InlineQueryResult {
|
||||
val type: String
|
||||
val id: InlineQueryIdentifier
|
||||
val replyMarkup: InlineKeyboardMarkup?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(InputMessageContentSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface InputMessageContent
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.actions
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -13,6 +14,7 @@ import kotlinx.serialization.encoding.Encoder
|
||||
* Use BotAction objects realisations to notify user about bot actions
|
||||
*/
|
||||
@Serializable(BotActionSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface BotAction {
|
||||
val actionName: String
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.games.CallbackGame
|
||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||
@@ -11,6 +12,7 @@ import kotlinx.serialization.json.*
|
||||
* https://core.telegram.org/bots/api#inlinekeyboardbutton for more info
|
||||
*/
|
||||
@Serializable(InlineKeyboardButtonSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface InlineKeyboardButton {
|
||||
val text: String
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(KeyboardMarkupSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface KeyboardMarkup
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.types.inputFieldPlaceholderField
|
||||
import dev.inmo.tgbotapi.types.inputFieldPlaceholderLimit
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@@ -10,14 +9,16 @@ data class ReplyForce(
|
||||
@SerialName(inputFieldPlaceholderField)
|
||||
val inputFieldPlaceholder: String? = null
|
||||
) : KeyboardMarkup {
|
||||
@SerialName("force_reply")
|
||||
@SerialName(forceReplyField)
|
||||
@Required
|
||||
val forceReply: Boolean = true
|
||||
|
||||
companion object {
|
||||
val ReplyForceSelective = ReplyForce(true)
|
||||
val ReplyForceNonSelective = ReplyForce(false)
|
||||
val ReplyForceDefault = ReplyForce()
|
||||
fun Selective(inputFieldPlaceholder: String? = null) = ReplyForce(true, inputFieldPlaceholder)
|
||||
fun NonSelective(inputFieldPlaceholder: String? = null) = ReplyForce(false, inputFieldPlaceholder)
|
||||
val Selective = Selective()
|
||||
val NonSelective = NonSelective()
|
||||
val Default = ReplyForce()
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -43,6 +44,7 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat {
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Chat {
|
||||
val id: ChatId
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ data class ChatJoinRequest(
|
||||
@SerialName(dateField)
|
||||
val date: TelegramDate,
|
||||
@SerialName(inviteLinkField)
|
||||
val inviteLink: ChatInviteLink,
|
||||
val inviteLink: ChatInviteLink? = null,
|
||||
@SerialName(bioField)
|
||||
val bio: String? = null
|
||||
) : FromUser {
|
||||
|
||||
@@ -22,7 +22,7 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
|
||||
override fun deserialize(decoder: Decoder): ChatMember {
|
||||
val json = JsonObject.serializer().deserialize(decoder)
|
||||
return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) {
|
||||
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.serializer(), json)
|
||||
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(OwnerChatMember.serializer(), json)
|
||||
"administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json)
|
||||
"member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMemberImpl.serializer(), json)
|
||||
"restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json)
|
||||
@@ -34,7 +34,7 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
|
||||
|
||||
override fun serialize(encoder: Encoder, value: ChatMember) {
|
||||
when (value) {
|
||||
is CreatorChatMember -> CreatorChatMember.serializer()
|
||||
is OwnerChatMember -> OwnerChatMember.serializer()
|
||||
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer()
|
||||
is MemberChatMember -> MemberChatMemberImpl.serializer()
|
||||
is RestrictedChatMember -> RestrictedChatMember.serializer()
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.chat.User
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class CreatorChatMember(
|
||||
data class OwnerChatMember(
|
||||
override val user: User,
|
||||
@SerialName(isAnonymousField)
|
||||
override val isAnonymous: Boolean = false,
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.dice
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.KSerializer
|
||||
@@ -9,6 +10,7 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(DiceAnimationTypeSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface DiceAnimationType {
|
||||
val emoji: String
|
||||
val valueLimits: IntRange
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types.files
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.FileUniqueId
|
||||
|
||||
/**
|
||||
* Declare common part of media files in Telegram. Note: it is not representation of JVM `File` type
|
||||
*/
|
||||
@ClassCastsIncluded
|
||||
sealed interface TelegramMediaFile {
|
||||
val fileId: FileId
|
||||
val fileUniqueId: FileUniqueId
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.location
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.*
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
@@ -18,6 +19,7 @@ import kotlinx.serialization.json.JsonObject
|
||||
* @see dev.inmo.tgbotapi.extensions.utils.asLiveLocation
|
||||
*/
|
||||
@Serializable(LocationSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Location : Locationed, HorizontallyAccured
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.media
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(TelegramMediaSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface TelegramMedia {
|
||||
val type: String
|
||||
val file: InputFile
|
||||
|
||||
@@ -4,6 +4,9 @@ import dev.inmo.tgbotapi.abstracts.WithUser
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||
|
||||
data class LeftChatMember(
|
||||
data class LeftChatMemberEvent(
|
||||
override val user: User
|
||||
) : PublicChatEvent, WithUser
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("dev.inmo.tgbotapi.types.message.ChatEvents", "LeftChatMemberEvent"))
|
||||
typealias LeftChatMember = LeftChatMemberEvent
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface ChatEvent
|
||||
|
||||
@@ -1,42 +1,74 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.FromUser
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.*
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
|
||||
sealed class ForwardInfo {
|
||||
@ClassCastsIncluded
|
||||
sealed interface ForwardInfo {
|
||||
abstract val dateOfOriginal: TelegramDate
|
||||
|
||||
data class ByAnonymous(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val senderName: String
|
||||
) : ForwardInfo
|
||||
|
||||
data class ByUser(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
override val from: User
|
||||
) : ForwardInfo, FromUser
|
||||
|
||||
sealed interface PublicChat : ForwardInfo {
|
||||
val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||
|
||||
/**
|
||||
* Represent forward info for the message sent by [channelChat] into some group
|
||||
*/
|
||||
data class SentByChannel(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val channelChat: ChannelChat,
|
||||
val signature: String? = null
|
||||
) : PublicChat {
|
||||
override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||
get() = channelChat
|
||||
}
|
||||
|
||||
/**
|
||||
* Represent forward info for the message sent by [channelChat] into that channel
|
||||
*/
|
||||
data class FromChannel(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val messageId: MessageIdentifier,
|
||||
val channelChat: ChannelChat,
|
||||
val signature: String? = null
|
||||
) : PublicChat {
|
||||
override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||
get() = channelChat
|
||||
}
|
||||
|
||||
data class FromSupergroup(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val group: SupergroupChat
|
||||
) : PublicChat {
|
||||
override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||
get() = group
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class AnonymousForwardInfo(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val senderName: String
|
||||
) : ForwardInfo()
|
||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByAnonymous", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||
typealias AnonymousForwardInfo = ForwardInfo.ByAnonymous
|
||||
|
||||
data class UserForwardInfo(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
override val from: User
|
||||
) : ForwardInfo(), FromUser
|
||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByUser", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||
typealias UserForwardInfo = ForwardInfo.ByUser
|
||||
|
||||
sealed class ForwardFromPublicChatInfo : ForwardInfo() {
|
||||
abstract val chat: PublicChat
|
||||
}
|
||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||
typealias ForwardFromPublicChatInfo = ForwardInfo.PublicChat
|
||||
|
||||
data class ForwardFromChannelInfo(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val messageId: MessageIdentifier,
|
||||
val channelChat: ChannelChat,
|
||||
val signature: String? = null
|
||||
) : ForwardFromPublicChatInfo() {
|
||||
override val chat: PublicChat
|
||||
get() = channelChat
|
||||
}
|
||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromChannel", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||
typealias ForwardFromChannelInfo = ForwardInfo.PublicChat.FromChannel
|
||||
|
||||
data class ForwardFromSupergroupInfo(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val group: SupergroupChat
|
||||
) : ForwardFromPublicChatInfo() {
|
||||
override val chat: PublicChat
|
||||
get() = group
|
||||
}
|
||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromSupergroup", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||
typealias ForwardFromSupergroupInfo = ForwardInfo.PublicChat.FromSupergroup
|
||||
|
||||
@@ -156,26 +156,39 @@ internal data class RawMessage(
|
||||
}
|
||||
|
||||
private val forwarded: ForwardInfo? by lazy {
|
||||
forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||
forward_date
|
||||
?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||
when {
|
||||
forward_sender_name != null -> AnonymousForwardInfo(
|
||||
forward_sender_name != null -> ForwardInfo.ByAnonymous(
|
||||
forward_date,
|
||||
forward_sender_name
|
||||
)
|
||||
forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
|
||||
forward_date,
|
||||
forward_from_message_id ?: error("Channel forwarded message must contain message id, but was not"),
|
||||
forward_from_chat,
|
||||
forward_signature
|
||||
)
|
||||
forward_from_chat is SupergroupChat -> ForwardFromSupergroupInfo(
|
||||
|
||||
forward_from_chat is ChannelChat -> if (forward_from_message_id == null) {
|
||||
ForwardInfo.PublicChat.SentByChannel(
|
||||
forward_date,
|
||||
forward_from_chat,
|
||||
forward_signature
|
||||
)
|
||||
} else {
|
||||
ForwardInfo.PublicChat.FromChannel(
|
||||
forward_date,
|
||||
forward_from_message_id,
|
||||
forward_from_chat,
|
||||
forward_signature
|
||||
)
|
||||
}
|
||||
|
||||
forward_from_chat is SupergroupChat -> ForwardInfo.PublicChat.FromSupergroup(
|
||||
forward_date,
|
||||
forward_from_chat
|
||||
)
|
||||
forward_from != null -> UserForwardInfo(
|
||||
|
||||
forward_from != null -> ForwardInfo.ByUser(
|
||||
forward_date,
|
||||
forward_from
|
||||
)
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
@@ -9,6 +10,7 @@ import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface Message {
|
||||
val messageId: MessageIdentifier
|
||||
val chat: Chat
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
@@ -108,6 +109,7 @@ sealed interface MediaContent: MessageContent {
|
||||
fun asTelegramMedia(): TelegramMedia
|
||||
}
|
||||
|
||||
@ClassCastsIncluded
|
||||
sealed interface ResendableContent {
|
||||
fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user