mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 12:00:18 +00:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| d20b94e52c | |||
| 9f3cc6eafb | |||
| f86a095421 | |||
| b0c6b80d8b | |||
| 1df653f428 | |||
| 8dfaca7648 | |||
| 04db76831f | |||
| f2e9bf6bd8 | |||
| cde8fdeffd | |||
| e74f339ae2 |
76
CHANGELOG.md
76
CHANGELOG.md
@@ -1,5 +1,81 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 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)__
|
||||
|
||||
* Add support of functionality for `WebApp`s from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of functionality for premium feature from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of `addedToAttachmentMenu` in `CommonUser` from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of `secret_token` in `SetWebhook` request from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
* Add support of `createInvoiceLink` request from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||
|
||||
## 2.0.3
|
||||
|
||||
* `Core`:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-16-2022)
|
||||
# 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) |
|
||||
| [](https://t.me/InMoTelegramBotAPI) |
|
||||
|
||||
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||
|
||||
|
||||
20
build.gradle
20
build.gradle
@@ -6,19 +6,20 @@ 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.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 +28,7 @@ allprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
apply from: "./extensions.gradle"
|
||||
|
||||
private String getCurrentVersionChangelog() {
|
||||
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
||||
@@ -48,7 +50,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")
|
||||
@@ -103,8 +75,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.0.3
|
||||
|
||||
github_release_plugin_version=2.4.1
|
||||
library_version=2.2.2
|
||||
|
||||
59
gradle/libs.versions.toml
Normal file
59
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,59 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "1.6.21"
|
||||
kotlin-serialization = "1.3.3"
|
||||
kotlin-coroutines = "1.6.4"
|
||||
kotlin-gradle-plugin = "7.0.4"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "2.7.0"
|
||||
uuid = "0.4.1"
|
||||
ktor = "2.0.3"
|
||||
|
||||
microutils = "0.11.13"
|
||||
|
||||
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" }
|
||||
|
||||
# buildscript classpaths
|
||||
|
||||
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
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-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 |
@@ -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,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,8 +16,8 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -26,7 +26,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
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -35,8 +46,8 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -44,7 +55,7 @@ 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(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
|
||||
@@ -52,8 +63,8 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
toChat: Chat,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
@@ -61,7 +72,7 @@ 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(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
|
||||
@@ -69,40 +80,8 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChat.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(
|
||||
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,
|
||||
@@ -110,7 +89,7 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChat, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -119,8 +98,8 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -128,7 +107,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
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -137,15 +126,15 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = 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
|
||||
@@ -153,15 +142,15 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
toChat: Chat,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = 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
|
||||
@@ -169,15 +158,47 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChat: 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, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = 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
|
||||
@@ -192,7 +213,7 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChatId, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = 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
|
||||
@@ -207,4 +228,4 @@ suspend inline fun TelegramBot.copyMessage(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(message.chat, toChat, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
||||
import dev.inmo.tgbotapi.requests.send.OrderChangingDeprecationWarn
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
// TODO:: Swap fromChatId and toChatId for more correct order of parameters
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChatId, 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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, toChat.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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChat.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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChatId, 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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChatId, 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
|
||||
*/
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
suspend inline fun TelegramBot.copyMessage(
|
||||
fromChat: Chat,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
@@ -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 {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.payments
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink
|
||||
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||
|
||||
suspend fun TelegramBot.createInvoiceLink(
|
||||
title: String,
|
||||
description: String,
|
||||
payload: String,
|
||||
providerToken: String,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
maxTipAmount: Int? = null,
|
||||
suggestedTipAmounts: List<Int>? = null,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
requirePhoneNumber: Boolean = false,
|
||||
requireEmail: Boolean = false,
|
||||
requireShippingAddress: Boolean = false,
|
||||
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||
shouldSendEmailToProvider: Boolean = false,
|
||||
priceDependOnShipAddress: Boolean = false
|
||||
) = execute(
|
||||
CreateInvoiceLink(title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress)
|
||||
)
|
||||
@@ -13,10 +13,11 @@ suspend fun TelegramBot.setWebhookInfo(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
|
||||
url, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
|
||||
)
|
||||
)
|
||||
|
||||
@@ -29,10 +30,11 @@ suspend fun TelegramBot.setWebhookInfo(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
|
||||
)
|
||||
)
|
||||
|
||||
@@ -45,9 +47,10 @@ suspend fun TelegramBot.setWebhookInfo(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates
|
||||
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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,10 +6,9 @@ import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilterByUser
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.*
|
||||
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.types.queries.callback.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
@@ -111,7 +110,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 +238,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 +366,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,
|
||||
|
||||
@@ -14,6 +14,7 @@ import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
|
||||
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 +22,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
|
||||
@@ -48,9 +49,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 +78,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 +124,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 +138,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)
|
||||
|
||||
@@ -10,20 +10,19 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.Mar
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
||||
import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
|
||||
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
|
||||
@@ -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)
|
||||
|
||||
@@ -75,9 +75,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 +99,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 +123,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 +147,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 +171,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 +195,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 +219,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 +243,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 +267,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 +291,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 +315,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 +339,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 +363,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 +387,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 +411,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 +435,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 +459,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 +483,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 +507,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 +531,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 +555,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 +579,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 +603,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,
|
||||
|
||||
@@ -85,9 +85,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 +109,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 +133,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 +157,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 +181,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 +205,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 +229,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 +253,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 +277,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 +301,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 +325,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 +349,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 +373,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 +397,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 +421,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 +445,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 +469,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 +493,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 +517,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 +541,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,
|
||||
|
||||
@@ -1,107 +1,57 @@
|
||||
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 = "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
|
||||
}
|
||||
}
|
||||
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')
|
||||
api libs.javax.activation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targets.all {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
// targets.all {
|
||||
// compilations.all {
|
||||
// kotlinOptions {
|
||||
// freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"]
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ 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"
|
||||
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
fun CopyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
@@ -27,8 +32,21 @@ 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
|
||||
)
|
||||
|
||||
@Deprecated(OrderChangingDeprecationWarn)
|
||||
fun CopyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
@@ -40,8 +58,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 +122,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)
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package dev.inmo.tgbotapi.requests.send.payments
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData
|
||||
import dev.inmo.tgbotapi.abstracts.types.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPricesSerializer
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
/**
|
||||
* @param providerData - JSON-ENCODED FIELD
|
||||
*/
|
||||
@Serializable
|
||||
data class CreateInvoiceLink(
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(descriptionField)
|
||||
override val description: String,
|
||||
@SerialName(payloadField)
|
||||
override val payload: String,
|
||||
@SerialName(providerTokenField)
|
||||
override val providerToken: String,
|
||||
@SerialName(currencyField)
|
||||
override val currency: Currency,
|
||||
@Serializable(LabeledPricesSerializer::class)
|
||||
@SerialName(pricesField)
|
||||
override val prices: List<LabeledPrice>,
|
||||
@SerialName(maxTipAmountField)
|
||||
override val maxTipAmount: Int? = null,
|
||||
@SerialName(suggestedTipAmountsField)
|
||||
override val suggestedTipAmounts: List<Int>? = null,
|
||||
@SerialName(providerDataField)
|
||||
override val providerData: String? = null,
|
||||
@SerialName(requireNameField)
|
||||
override val requireName: Boolean = false,
|
||||
@SerialName(requirePhoneNumberField)
|
||||
override val requirePhoneNumber: Boolean = false,
|
||||
@SerialName(requireEmailField)
|
||||
override val requireEmail: Boolean = false,
|
||||
@SerialName(requireShippingAddressField)
|
||||
override val requireShippingAddress: Boolean = false,
|
||||
@SerialName(shouldSendPhoneNumberToProviderField)
|
||||
override val shouldSendPhoneNumberToProvider: Boolean = false,
|
||||
@SerialName(shouldSendEmailToProviderField)
|
||||
override val shouldSendEmailToProvider: Boolean = false,
|
||||
@SerialName(priceDependOnShipAddressField)
|
||||
override val priceDependOnShipAddress: Boolean = false
|
||||
) : CommonSendInvoiceData, SimpleRequest<String> {
|
||||
override fun method(): String = "sendInvoice"
|
||||
override val resultDeserializer: DeserializationStrategy<String>
|
||||
get() = String.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
@SerialName(photoUrlField)
|
||||
override var photoUrl: String? = null
|
||||
private set
|
||||
@SerialName(photoSizeField)
|
||||
override var photoSize: Long? = null
|
||||
private set
|
||||
|
||||
@SerialName(photoWidthField)
|
||||
override var photoWidth: Int? = null
|
||||
private set
|
||||
@SerialName(photoHeightField)
|
||||
override var photoHeight: Int? = null
|
||||
private set
|
||||
|
||||
init {
|
||||
suggestedTipAmounts ?.let { _ ->
|
||||
require(suggestedTipAmounts.size in suggestedTipAmountsLimit)
|
||||
maxTipAmount ?.let { _ ->
|
||||
require(
|
||||
suggestedTipAmounts.none { it > maxTipAmount }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setPhoto(
|
||||
photoUrl: String,
|
||||
photoSize: Long?,
|
||||
photoWidth: Int?,
|
||||
photoHeight: Int?
|
||||
) {
|
||||
this.photoUrl = photoUrl
|
||||
this.photoSize = photoSize
|
||||
this.photoWidth = photoWidth
|
||||
this.photoHeight = photoHeight
|
||||
}
|
||||
|
||||
override fun unsetPhoto() {
|
||||
photoUrl = null
|
||||
photoSize = null
|
||||
photoWidth = null
|
||||
photoHeight = null
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ class MultipartSetWebhookRequest(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) : SetWebhookRequest(), MultipartRequest<Boolean> by MultipartRequestImpl(
|
||||
SetWebhook(
|
||||
correctWebhookUrl(url),
|
||||
@@ -28,7 +29,8 @@ class MultipartSetWebhookRequest(
|
||||
ipAddress,
|
||||
maxAllowedConnections,
|
||||
allowedUpdates,
|
||||
dropPendingUpdates
|
||||
dropPendingUpdates,
|
||||
secretToken
|
||||
),
|
||||
mapOf(certificateField to certificate)
|
||||
)
|
||||
@@ -39,14 +41,16 @@ fun SetWebhook(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
): MultipartSetWebhookRequest = MultipartSetWebhookRequest(
|
||||
correctWebhookUrl(url),
|
||||
certificate,
|
||||
ipAddress,
|
||||
maxAllowedConnections,
|
||||
allowedUpdates,
|
||||
dropPendingUpdates
|
||||
dropPendingUpdates,
|
||||
secretToken
|
||||
)
|
||||
|
||||
fun SetWebhook(
|
||||
@@ -55,14 +59,16 @@ fun SetWebhook(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
): SetWebhook = SetWebhook(
|
||||
correctWebhookUrl(url),
|
||||
certificate.fileId,
|
||||
ipAddress,
|
||||
maxAllowedConnections,
|
||||
allowedUpdates,
|
||||
dropPendingUpdates
|
||||
dropPendingUpdates,
|
||||
secretToken
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -79,10 +85,11 @@ fun SetWebhook(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = when (certificate) {
|
||||
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
||||
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
|
||||
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken)
|
||||
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,14 +105,16 @@ fun SetWebhook(
|
||||
ipAddress: String? = null,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null,
|
||||
dropPendingUpdates: Boolean? = null
|
||||
dropPendingUpdates: Boolean? = null,
|
||||
secretToken: String? = null
|
||||
) = SetWebhook(
|
||||
correctWebhookUrl(url),
|
||||
null,
|
||||
ipAddress,
|
||||
maxAllowedConnections,
|
||||
allowedUpdates,
|
||||
dropPendingUpdates
|
||||
dropPendingUpdates,
|
||||
secretToken
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -128,7 +137,9 @@ data class SetWebhook internal constructor(
|
||||
@SerialName(allowedUpdatesField)
|
||||
val allowedUpdates: List<String>? = null,
|
||||
@SerialName(dropPendingUpdatesField)
|
||||
val dropPendingUpdates: Boolean? = null
|
||||
val dropPendingUpdates: Boolean? = null,
|
||||
@SerialName(secretTokenField)
|
||||
val secretToken: String? = null
|
||||
) : SetWebhookRequest(), DataRequest<Boolean> {
|
||||
override fun method(): String = "setWebhook"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
|
||||
@@ -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,29 @@ 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
|
||||
|
||||
/**
|
||||
* https://core.telegram.org/bots/api#formatting-options
|
||||
*/
|
||||
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
||||
val Identifier.link: String
|
||||
get() = "tg://user?id=$this"
|
||||
/**
|
||||
* https://core.telegram.org/bots/api#formatting-options
|
||||
*/
|
||||
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
||||
val ChatId.link: String
|
||||
get() = chatId.link
|
||||
|
||||
typealias UserId = ChatId
|
||||
|
||||
|
||||
@@ -117,6 +117,8 @@ const val isBotField = "is_bot"
|
||||
const val firstNameField = "first_name"
|
||||
const val lastNameField = "last_name"
|
||||
const val languageCodeField = "language_code"
|
||||
const val addedToAttachmentMenuField = "added_to_attachment_menu"
|
||||
const val isPremiumField = "is_premium"
|
||||
const val hasPrivateForwardsField = "has_private_forwards"
|
||||
const val canJoinGroupsField = "can_join_groups"
|
||||
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
||||
@@ -124,6 +126,7 @@ const val supportInlineQueriesField = "supports_inline_queries"
|
||||
const val textEntitiesField = "text_entities"
|
||||
const val entitiesField = "entities"
|
||||
const val stickerSetNameField = "set_name"
|
||||
const val premiumAnimationField = "premium_animation"
|
||||
const val stickerSetNameFullField = "sticker_set_name"
|
||||
const val slowModeDelayField = "slow_mode_delay"
|
||||
const val maskPositionField = "mask_position"
|
||||
@@ -155,6 +158,7 @@ const val switchPmParameterField = "switch_pm_parameter"
|
||||
const val maxAllowedConnectionsField = "max_connections"
|
||||
const val allowedUpdatesField = "allowed_updates"
|
||||
const val dropPendingUpdatesField = "drop_pending_updates"
|
||||
const val secretTokenField = "secret_token"
|
||||
const val hasCustomCertificateField = "has_custom_certificate"
|
||||
const val pendingUpdateCountField = "pending_update_count"
|
||||
const val lastErrorDateField = "last_error_date"
|
||||
@@ -180,6 +184,8 @@ const val customTitleField = "custom_title"
|
||||
const val optionIdsField = "option_ids"
|
||||
const val ipAddressField = "ip_address"
|
||||
const val linkedChatIdField = "linked_chat_id"
|
||||
const val joinToSendMessagesField = "join_to_send_messages"
|
||||
const val joinByRequestField = "join_by_request"
|
||||
const val horizontalAccuracyField = "horizontal_accuracy"
|
||||
const val revokeMessagesField = "revoke_messages"
|
||||
const val messageAutoDeleteTimeField = "message_auto_delete_time"
|
||||
@@ -409,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,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,13 +9,24 @@ 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)
|
||||
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()
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("ReplyForce.Selective"))
|
||||
inline val ReplyForceSelective
|
||||
get() = Selective
|
||||
@Deprecated("Renamed", ReplaceWith("ReplyForce.NonSelective"))
|
||||
inline val ReplyForceNonSelective
|
||||
get() = NonSelective
|
||||
@Deprecated("Renamed", ReplaceWith("ReplyForce.Default"))
|
||||
val ReplyForceDefault = ReplyForce()
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,16 @@ sealed interface UsernameChat : Chat {
|
||||
val username: Username?
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface PossiblyPremiumChat : Chat {
|
||||
val isPremium: Boolean
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface AbleToAddInAttachmentMenuChat : Chat {
|
||||
val addedToAttachmentMenu: Boolean
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
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 {
|
||||
|
||||
@@ -65,7 +65,8 @@ object PreviewChatSerializer : KSerializer<Chat> {
|
||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.UnknownChatType -> UnknownChatType(
|
||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||
decodedJson.toString()
|
||||
decodedJson.toString(),
|
||||
decodedJson
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -77,6 +78,10 @@ object PreviewChatSerializer : KSerializer<Chat> {
|
||||
is GroupChatImpl -> GroupChatImpl.serializer().serialize(encoder, value)
|
||||
is SupergroupChatImpl -> SupergroupChatImpl.serializer().serialize(encoder, value)
|
||||
is ChannelChatImpl -> ChannelChatImpl.serializer().serialize(encoder, value)
|
||||
is CommonBot -> CommonBot.serializer().serialize(encoder, value)
|
||||
is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, value)
|
||||
is CommonUser -> CommonUser.serializer().serialize(encoder, value)
|
||||
is UnknownChatType -> JsonObject.serializer().serialize(encoder, value.rawJson)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +104,8 @@ object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.UnknownChatType -> UnknownExtendedChat(
|
||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||
decodedJson.toString()
|
||||
decodedJson.toString(),
|
||||
decodedJson
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -110,6 +116,7 @@ object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||
is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, value)
|
||||
is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, value)
|
||||
is ExtendedChannelChatImpl -> ExtendedChannelChatImpl.serializer().serialize(encoder, value)
|
||||
is UnknownExtendedChat -> JsonObject.serializer().serialize(encoder, value.rawJson)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@Serializable
|
||||
data class ExtendedChannelChatImpl(
|
||||
@@ -94,7 +95,11 @@ data class ExtendedSupergroupChatImpl(
|
||||
@SerialName(linkedChatIdField)
|
||||
override val linkedChannelChatId: ChatId? = null,
|
||||
@SerialName(locationField)
|
||||
override val location: ChatLocation? = null
|
||||
override val location: ChatLocation? = null,
|
||||
@SerialName(joinToSendMessagesField)
|
||||
override val requiresJoinForMessaging: Boolean = false,
|
||||
@SerialName(joinByRequestField)
|
||||
override val requireAdminApproveToJoin: Boolean = false
|
||||
) : ExtendedSupergroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -119,7 +124,8 @@ data class ExtendedBot(
|
||||
|
||||
data class UnknownExtendedChat(
|
||||
override val id: ChatId,
|
||||
val raw: String
|
||||
val raw: String,
|
||||
val rawJson: JsonObject
|
||||
) : ExtendedChat {
|
||||
override val chatPhoto: ChatPhoto? = null
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -39,6 +38,16 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat {
|
||||
val canSetStickerSet: Boolean
|
||||
val linkedChannelChatId: ChatId?
|
||||
val location: ChatLocation?
|
||||
|
||||
/**
|
||||
* This field represents field "join_to_send_messages" from API
|
||||
*/
|
||||
val requiresJoinForMessaging: Boolean
|
||||
|
||||
/**
|
||||
* This field represents field "join_by_request" from API
|
||||
*/
|
||||
val requireAdminApproveToJoin: Boolean
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer::class)
|
||||
|
||||
@@ -80,8 +80,12 @@ data class CommonUser(
|
||||
override val username: Username? = null,
|
||||
@SerialName(languageCodeField)
|
||||
@Serializable(IetfLanguageCodeSerializer::class)
|
||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||
) : User(), WithOptionalLanguageCode {
|
||||
override val ietfLanguageCode: IetfLanguageCode? = null,
|
||||
@SerialName(isPremiumField)
|
||||
override val isPremium: Boolean = false,
|
||||
@SerialName(addedToAttachmentMenuField)
|
||||
override val addedToAttachmentMenu: Boolean = false
|
||||
) : User(), WithOptionalLanguageCode, PossiblyPremiumChat, AbleToAddInAttachmentMenuChat {
|
||||
constructor(
|
||||
id: UserId,
|
||||
firstName: String,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
data class UnknownChatType(
|
||||
override val id: ChatId,
|
||||
val raw: String
|
||||
val raw: String,
|
||||
val rawJson: JsonObject
|
||||
) : Chat
|
||||
|
||||
@@ -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,
|
||||
@@ -38,3 +38,6 @@ data class CreatorChatMember(
|
||||
@Required
|
||||
private val type: String = "creator"
|
||||
}
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("OwnerChatMember", "dev.inmo.tgbotapi.types.chat.member.OwnerChatMember"))
|
||||
typealias CreatorChatMember = OwnerChatMember
|
||||
@@ -22,7 +22,8 @@ data class StickerSurrogate(
|
||||
val emoji: String? = null,
|
||||
val set_name: StickerSetName? = null,
|
||||
val mask_position: MaskPosition? = null,
|
||||
val file_size: Long? = null
|
||||
val file_size: Long? = null,
|
||||
val premium_animation: File? = null
|
||||
)
|
||||
|
||||
// TODO:: Serializer
|
||||
@@ -31,6 +32,7 @@ sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
|
||||
val emoji: String?
|
||||
val maskPosition: MaskPosition?
|
||||
val stickerSetName: StickerSetName?
|
||||
val premiumAnimationFile: File?
|
||||
|
||||
val isAnimated
|
||||
get() = this is AnimatedSticker
|
||||
@@ -53,6 +55,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.mask_position,
|
||||
surrogate.file_size
|
||||
)
|
||||
@@ -64,6 +67,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.mask_position,
|
||||
surrogate.file_size
|
||||
)
|
||||
@@ -75,6 +79,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.mask_position,
|
||||
surrogate.file_size
|
||||
)
|
||||
@@ -103,6 +108,8 @@ data class SimpleSticker(
|
||||
override val emoji: String? = null,
|
||||
@SerialName(stickerSetNameField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(premiumAnimationField)
|
||||
override val premiumAnimationFile: File?,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null,
|
||||
@SerialName(fileSizeField)
|
||||
@@ -124,6 +131,8 @@ data class AnimatedSticker(
|
||||
override val emoji: String? = null,
|
||||
@SerialName(stickerSetNameField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(premiumAnimationField)
|
||||
override val premiumAnimationFile: File?,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null,
|
||||
@SerialName(fileSizeField)
|
||||
@@ -145,6 +154,8 @@ data class VideoSticker(
|
||||
override val emoji: String? = null,
|
||||
@SerialName(stickerSetNameField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(premiumAnimationField)
|
||||
override val premiumAnimationFile: File?,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null,
|
||||
@SerialName(fileSizeField)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
|
||||
typealias InvoiceMessage = CommonMessage<InvoiceContent>
|
||||
typealias VenueMessage = CommonMessage<VenueContent>
|
||||
typealias GameMessage = CommonMessage<GameContent>
|
||||
typealias DiceMessage = CommonMessage<DiceContent>
|
||||
typealias ContactMessage = CommonMessage<ContactContent>
|
||||
typealias PollMessage = CommonMessage<PollContent>
|
||||
typealias TextMessage = CommonMessage<TextContent>
|
||||
|
||||
typealias LocationMessage = CommonMessage<LocationContent>
|
||||
typealias LiveLocationMessage = CommonMessage<LiveLocationContent>
|
||||
typealias StaticLocationMessage = CommonMessage<StaticLocationContent>
|
||||
|
||||
typealias MediaCollectionMessage<T> = CommonMessage<MediaCollectionContent<T>>
|
||||
typealias MediaMessage = CommonMessage<MediaContent>
|
||||
typealias VideoNoteMessage = CommonMessage<VideoNoteContent>
|
||||
typealias StickerMessage = CommonMessage<StickerContent>
|
||||
typealias TextedMediaMessage = CommonMessage<TextedMediaContent>
|
||||
typealias VoiceMessage = CommonMessage<VoiceContent>
|
||||
typealias MediaGroupMessage = CommonMessage<MediaGroupContent>
|
||||
typealias AudioMediaGroupMessage = CommonMessage<AudioMediaGroupContent>
|
||||
typealias AudioMessage = CommonMessage<AudioContent>
|
||||
typealias DocumentMediaGroupMessage = CommonMessage<DocumentMediaGroupContent>
|
||||
typealias DocumentMessage = CommonMessage<DocumentContent>
|
||||
typealias VisualMediaGroupMessage = CommonMessage<VisualMediaGroupContent>
|
||||
typealias VideoMessage = CommonMessage<VideoContent>
|
||||
typealias PhotoMessage = CommonMessage<PhotoContent>
|
||||
typealias AnimationMessage = CommonMessage<AnimationContent>
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class ChatIdentifierTests {
|
||||
@Test
|
||||
fun `Creating_link_from_ChatId_is_correct`() {
|
||||
val chatId = chatIdentifierChatId.toChatId()
|
||||
assertEquals(chatIdentifierLink, chatId.link)
|
||||
assertEquals(chatIdentifierLink, chatId.userLink)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,73 +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 = "Additional extensions for core part of tgbotapi"
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-common')
|
||||
implementation kotlin('test-annotations-common')
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
implementation kotlin('test-js')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink
|
||||
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.queries.callback.*
|
||||
@@ -45,6 +46,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMember
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
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
|
||||
@@ -235,6 +237,24 @@ inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? E
|
||||
@PreviewFeature
|
||||
inline fun Chat.requireExtendedSupergroupChat(): ExtendedSupergroupChat = this as ExtendedSupergroupChat
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Chat.whenPossiblyPremiumChat(block: (PossiblyPremiumChat) -> T) = asPossiblyPremiumChat() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Chat.asPossiblyPremiumChat(): PossiblyPremiumChat? = this as? PossiblyPremiumChat
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Chat.requirePossiblyPremiumChat(): PossiblyPremiumChat = this as PossiblyPremiumChat
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Chat.whenAbleToAddInAttachmentMenuChat(block: (AbleToAddInAttachmentMenuChat) -> T) = asAbleToAddInAttachmentMenuChat() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Chat.asAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat? = this as? AbleToAddInAttachmentMenuChat
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Chat.requireAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat = this as AbleToAddInAttachmentMenuChat
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> CallbackQuery.whenDataCallbackQuery(block: (DataCallbackQuery) -> T) = asDataCallbackQuery() ?.let(block)
|
||||
|
||||
@@ -1809,14 +1829,26 @@ inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryR
|
||||
this as InlineQueryResultVoiceCommon
|
||||
|
||||
@PreviewFeature
|
||||
@Deprecated("Renamed", ReplaceWith("whenOwnerChatMember", "dev.inmo.tgbotapi.extensions.utils.whenOwnerChatMember"))
|
||||
inline fun <T> ChatMember.whenCreatorChatMember(block: (CreatorChatMember) -> T) = asCreatorChatMember() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
@Deprecated("Renamed", ReplaceWith("asOwnerChatMember", "dev.inmo.tgbotapi.extensions.utils.asOwnerChatMember"))
|
||||
inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember
|
||||
|
||||
@PreviewFeature
|
||||
@Deprecated("Renamed", ReplaceWith("requireOwnerChatMember", "dev.inmo.tgbotapi.extensions.utils.requireOwnerChatMember"))
|
||||
inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> ChatMember.whenOwnerChatMember(block: (OwnerChatMember) -> T) = asOwnerChatMember() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun ChatMember.asOwnerChatMember(): OwnerChatMember? = this as? OwnerChatMember
|
||||
|
||||
@PreviewFeature
|
||||
inline fun ChatMember.requireOwnerChatMember(): OwnerChatMember = this as OwnerChatMember
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> ChatMember.whenKickedChatMember(block: (KickedChatMember) -> T) = asKickedChatMember() ?.let(block)
|
||||
|
||||
@@ -3255,7 +3287,16 @@ inline fun <T> CommonSendInvoiceData.whenSendInvoice(block: (SendInvoice) -> T)
|
||||
inline fun CommonSendInvoiceData.asSendInvoice(): SendInvoice? = this as? SendInvoice
|
||||
|
||||
@PreviewFeature
|
||||
inline fun CommonSendInvoiceData.requireVoiceChatParticipantsInvited(): SendInvoice = this as SendInvoice
|
||||
inline fun CommonSendInvoiceData.requireSendInvoice(): SendInvoice = this as SendInvoice
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> CommonSendInvoiceData.whenCreateInvoiceLink(block: (CreateInvoiceLink) -> T) = asCreateInvoiceLink() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun CommonSendInvoiceData.asCreateInvoiceLink(): CreateInvoiceLink? = this as? CreateInvoiceLink
|
||||
|
||||
@PreviewFeature
|
||||
inline fun CommonSendInvoiceData.requireCreateInvoiceLink(): CreateInvoiceLink = this as CreateInvoiceLink
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> CommonSendInvoiceData.whenInputInvoiceMessageContent(block: (InputInvoiceMessageContent) -> T) = asInputInvoiceMessageContent() ?.let(block)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,42 @@
|
||||
@file:Suppress("UNCHECKED_CAST")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.utils
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||
|
||||
inline fun <reified T : MessageContent> ContentMessage<*>.withContentOrNull() = if (content is T) { this as ContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> ContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> CommonMessage<*>.withContentOrNull() = if (content is T) { this as CommonMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> CommonMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> PossiblySentViaBotCommonMessage<*>.withContentOrNull() = if (content is T) { this as PossiblySentViaBotCommonMessage<T>
|
||||
} else { null }
|
||||
inline fun <reified T : MessageContent> PossiblySentViaBotCommonMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> ChannelContentMessage<*>.withContentOrNull() = if (content is T) { this as ChannelContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> ChannelContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> PrivateContentMessage<*>.withContentOrNull() = if (content is T) { this as PrivateContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> PrivateContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> PublicContentMessage<*>.withContentOrNull() = if (content is T) { this as PublicContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> PublicContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> GroupContentMessage<*>.withContentOrNull() = if (content is T) { this as GroupContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> GroupContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> FromChannelGroupContentMessage<*>.withContentOrNull() = if (content is T) { this as FromChannelGroupContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> FromChannelGroupContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> AnonymousGroupContentMessage<*>.withContentOrNull() = if (content is T) { this as AnonymousGroupContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> AnonymousGroupContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MessageContent> CommonGroupContentMessage<*>.withContentOrNull() = if (content is T) { this as CommonGroupContentMessage<T> } else { null }
|
||||
inline fun <reified T : MessageContent> CommonGroupContentMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
|
||||
inline fun <reified T : MediaGroupContent> MediaGroupMessage<*>.withContentOrNull() = if (content is T) { this as MediaGroupMessage<T> } else { null }
|
||||
inline fun <reified T : MediaGroupContent> MediaGroupMessage<*>.withContentOrThrow() = withContentOrNull<T>()!!
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils.extensions
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
/**
|
||||
* @return true in case if [this] message is placed in the same chat that [other]
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun Message.sameChat(other: Message) = chat.id == other.chat.id
|
||||
|
||||
/**
|
||||
* @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat
|
||||
* and have equal [Message.messageId] identifier
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun Message.sameMessage(other: Message) = sameChat(other) && messageId == other.messageId
|
||||
@@ -5,5 +5,5 @@ import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
|
||||
@RiskFeature(RawFieldsUsageWarning)
|
||||
val ChatJoinRequest.invite_link: ChatInviteLink
|
||||
val ChatJoinRequest.invite_link: ChatInviteLink?
|
||||
get() = inviteLink
|
||||
|
||||
@@ -19,3 +19,5 @@ inline val Sticker.mask_position: MaskPosition?
|
||||
get() = maskPosition
|
||||
inline val Sticker.file_size: Long?
|
||||
get() = fileSize
|
||||
inline val Sticker.premium_animation: File?
|
||||
get() = premiumAnimationFile
|
||||
|
||||
@@ -5,19 +5,20 @@ package dev.inmo.tgbotapi.extensions.utils.formatting
|
||||
import dev.inmo.micro_utils.common.joinTo
|
||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
|
||||
typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit
|
||||
val newLine = regular("\n")
|
||||
|
||||
fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build()
|
||||
fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init)
|
||||
inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build()
|
||||
inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init)
|
||||
|
||||
/**
|
||||
* This builder can be used to provide building of [TextSource]s [List]
|
||||
*
|
||||
* @see buildEntities
|
||||
*/
|
||||
class EntitiesBuilder internal constructor(
|
||||
class EntitiesBuilder @RiskFeature constructor(
|
||||
val separator: TextSource? = null
|
||||
) {
|
||||
private val entitiesList: MutableTextSourcesList = mutableListOf()
|
||||
|
||||
@@ -5,8 +5,6 @@ import dev.inmo.tgbotapi.types.message.textsources.link
|
||||
import dev.inmo.tgbotapi.types.chat.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
private const val internalLinkBeginning = "https://t.me"
|
||||
|
||||
fun makeUsernameLink(username: String) = "$internalLinkBeginning/$username"
|
||||
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
|
||||
inline val Username.link
|
||||
@@ -73,7 +71,7 @@ val Message.link: String?
|
||||
val Chat.link: String?
|
||||
get() {
|
||||
if (this is UsernameChat) {
|
||||
username ?.username ?.let { return it }
|
||||
username ?.link
|
||||
}
|
||||
if (this is ExtendedPublicChat) {
|
||||
inviteLink ?.let { return it }
|
||||
|
||||
@@ -40,6 +40,16 @@ inline fun inlineKeyboard(
|
||||
block: InlineKeyboardBuilder.() -> Unit
|
||||
) = InlineKeyboardBuilder().apply(block).build()
|
||||
|
||||
/**
|
||||
* Factory-function for [InlineKeyboardBuilder], but in difference with [inlineKeyboard] this function will create single-row
|
||||
* inline keyboard
|
||||
*
|
||||
* @see InlineKeyboardBuilder.row
|
||||
*/
|
||||
inline fun flatInlineKeyboard(
|
||||
block: InlineKeyboardRowBuilder.() -> Unit
|
||||
) = inlineKeyboard { row(block) }
|
||||
|
||||
/**
|
||||
* Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder
|
||||
*
|
||||
|
||||
@@ -47,6 +47,20 @@ inline fun replyKeyboard(
|
||||
block: ReplyKeyboardBuilder.() -> Unit
|
||||
) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
|
||||
|
||||
/**
|
||||
* Factory-function for [ReplyKeyboardBuilder], but in difference with [replyKeyboard] this method will create single-row
|
||||
* keyboard
|
||||
*/
|
||||
inline fun flatReplyKeyboard(
|
||||
resizeKeyboard: Boolean? = null,
|
||||
oneTimeKeyboard: Boolean? = null,
|
||||
inputFieldPlaceholder: String? = null,
|
||||
selective: Boolean? = null,
|
||||
block: ReplyKeyboardRowBuilder.() -> Unit
|
||||
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) {
|
||||
row(block)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an [ReplyKeyboardRowBuilder] and [apply] [block] with this builder
|
||||
*
|
||||
|
||||
@@ -1,56 +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 = "Web App bindings for the Telegram Web Apps 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 project(":tgbotapi.core")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.tgbotapi.webapps
|
||||
|
||||
external interface BackButton {
|
||||
val isVisible: Boolean
|
||||
|
||||
fun onClick(callback: () -> Unit)
|
||||
fun offClick(callback: () -> Unit)
|
||||
|
||||
fun show()
|
||||
fun hide()
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.inmo.tgbotapi.webapps
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
sealed interface Color {
|
||||
val value: String
|
||||
@Serializable
|
||||
value class BackgroundColor(override val value: String) : Color
|
||||
|
||||
@Serializable
|
||||
value class Hex(override val value: String) : Color
|
||||
|
||||
companion object {
|
||||
val BackgroundColor = BackgroundColor("bg_color")
|
||||
val SecondaryBackgroundColor = BackgroundColor("secondary_bg_color")
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline operator fun invoke(value: String) = Hex(value)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package dev.inmo.tgbotapi.webapps
|
||||
|
||||
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
|
||||
|
||||
typealias EventHandler = WebApp.() -> Unit
|
||||
typealias ViewportChangedEventHandler = WebApp.(ViewportChangedData) -> Unit
|
||||
typealias InvoiceClosedEventHandler = WebApp.(InvoiceClosedInfo) -> Unit
|
||||
|
||||
@@ -4,4 +4,7 @@ sealed class EventType(val typeName: String) {
|
||||
object ThemeChanged : EventType("themeChanged")
|
||||
object ViewportChanged : EventType("viewportChanged")
|
||||
object MainButtonClicked : EventType("mainButtonClicked")
|
||||
object BackButtonClicked : EventType("backButtonClicked")
|
||||
object SettingsButtonClicked : EventType("settingsButtonClicked")
|
||||
object InvoiceClosed : EventType("invoiceClosed")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package dev.inmo.tgbotapi.webapps
|
||||
|
||||
typealias HEXColor = String
|
||||
@@ -23,6 +23,7 @@ external class MainButton {
|
||||
fun hideProgress(): MainButton
|
||||
|
||||
internal fun onClick(eventHandler: () -> Unit): MainButton
|
||||
internal fun offClick(eventHandler: () -> Unit): MainButton
|
||||
|
||||
internal fun setParams(params: Json): MainButton
|
||||
}
|
||||
|
||||
@@ -2,15 +2,32 @@ package dev.inmo.tgbotapi.webapps
|
||||
|
||||
external interface ThemeParams {
|
||||
@JsName("bg_color")
|
||||
val backgroundColor: String?
|
||||
val backgroundColor: HEXColor?
|
||||
@JsName("secondary_bg_color")
|
||||
val secondaryBackgroundColor: HEXColor?
|
||||
@JsName("text_color")
|
||||
val textColor: String?
|
||||
val textColor: HEXColor?
|
||||
@JsName("hint_color")
|
||||
val hintColor: String?
|
||||
val hintColor: HEXColor?
|
||||
@JsName("link_color")
|
||||
val linkColor: String?
|
||||
val linkColor: HEXColor?
|
||||
@JsName("button_color")
|
||||
val buttonColor: String?
|
||||
val buttonColor: HEXColor?
|
||||
@JsName("button_text_color")
|
||||
val buttonTextColor: String?
|
||||
val buttonTextColor: HEXColor?
|
||||
|
||||
@JsName("bg_color")
|
||||
val backgroundColorHex: Color.Hex?
|
||||
@JsName("secondary_bg_color")
|
||||
val secondaryBackgroundColorHex: Color.Hex?
|
||||
@JsName("text_color")
|
||||
val textColorHex: Color.Hex?
|
||||
@JsName("hint_color")
|
||||
val hintColorHex: Color.Hex?
|
||||
@JsName("link_color")
|
||||
val linkColorHex: Color.Hex?
|
||||
@JsName("button_color")
|
||||
val buttonColorHex: Color.Hex?
|
||||
@JsName("button_text_color")
|
||||
val buttonTextColorHex: Color.Hex?
|
||||
}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
package dev.inmo.tgbotapi.webapps
|
||||
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedback
|
||||
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
|
||||
|
||||
external class WebApp {
|
||||
val version: String
|
||||
|
||||
val initData: String
|
||||
val initDataUnsafe: WebAppInitData
|
||||
|
||||
val headerColor: HEXColor?
|
||||
fun setHeaderColor(color: Color.BackgroundColor)
|
||||
val backgroundColor: HEXColor?
|
||||
fun setBackgroundColor(color: Color.Hex)
|
||||
fun setBackgroundColor(color: Color.BackgroundColor)
|
||||
|
||||
@JsName("colorScheme")
|
||||
val colorSchemeRaw: String
|
||||
val themeParams: ThemeParams
|
||||
@@ -17,19 +27,34 @@ external class WebApp {
|
||||
@JsName("MainButton")
|
||||
val mainButton: MainButton
|
||||
|
||||
@JsName("BackButton")
|
||||
val backButton: BackButton
|
||||
|
||||
@JsName("HapticFeedback")
|
||||
val hapticFeedback: HapticFeedback
|
||||
|
||||
internal fun onEvent(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithBoolean(type: String, callback: (ViewportChangedData) -> Unit)
|
||||
internal fun onEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithInvoiceClosedInfo(type: String, callback: (InvoiceClosedInfo) -> Unit)
|
||||
|
||||
fun offEvent(type: String, callback: () -> Unit)
|
||||
@JsName("offEvent")
|
||||
fun offEventWithBoolean(type: String, callback: (ViewportChangedData) -> Unit)
|
||||
fun offEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit)
|
||||
@JsName("offEvent")
|
||||
fun offEventWithInvoiceClosedInfo(type: String, callback: (InvoiceClosedInfo) -> Unit)
|
||||
|
||||
fun sendData(data: String)
|
||||
|
||||
fun ready()
|
||||
fun expand()
|
||||
fun close()
|
||||
|
||||
fun isVersionAtLeast(version: String): Boolean
|
||||
fun openLink(url: String)
|
||||
fun openTelegramLink(url: String)
|
||||
fun openInvoice(url: String, callback: (InvoiceClosedInfo) -> Unit = definedExternally)
|
||||
}
|
||||
|
||||
val WebApp.colorScheme: ColorScheme
|
||||
@@ -57,7 +82,19 @@ fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = {
|
||||
fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: ViewportChangedData ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
onEventWithBoolean(
|
||||
onEventWithViewportChangedData(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { it: InvoiceClosedInfo ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
onEventWithInvoiceClosedInfo(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
@@ -75,6 +112,18 @@ fun WebApp.onMainButtonClicked(eventHandler: EventHandler) = onEvent(EventType.M
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onViewportChanged(eventHandler: ViewportChangedEventHandler) = onEvent(EventType.ViewportChanged, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onBackButtonClicked(eventHandler: EventHandler) = onEvent(EventType.BackButtonClicked, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onSettingsButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SettingsButtonClicked, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(EventType.InvoiceClosed, eventHandler)
|
||||
|
||||
fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData(
|
||||
initData,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.webapps
|
||||
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||
|
||||
external interface WebAppChat {
|
||||
val id: ChatIdentifier
|
||||
val type: String
|
||||
val title: String
|
||||
val username: Username?
|
||||
@JsName("photo_url")
|
||||
val photoUrl: String?
|
||||
}
|
||||
@@ -15,5 +15,10 @@ external interface WebAppInitData {
|
||||
@JsName("auth_date")
|
||||
val authDate: MilliSeconds
|
||||
|
||||
@JsName("can_send_after")
|
||||
val canSendAfter: MilliSeconds
|
||||
|
||||
val chat: WebAppChat
|
||||
|
||||
val hash: String
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.inmo.tgbotapi.webapps.haptic
|
||||
|
||||
external interface HapticFeedback {
|
||||
fun impactOccurred(style: HapticFeedbackStyle)
|
||||
fun notificationOccurred(type: HapticFeedbackType)
|
||||
fun selectionChanged()
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.webapps.haptic
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
value class HapticFeedbackStyle @Warning("Do not use this constructor if available objects from companion cover your needs") constructor(
|
||||
val name: String
|
||||
) {
|
||||
companion object {
|
||||
val Light = HapticFeedbackStyle("light")
|
||||
val Medium = HapticFeedbackStyle("medium")
|
||||
val Heavy = HapticFeedbackStyle("heavy")
|
||||
val Rigid = HapticFeedbackStyle("rigid")
|
||||
val Soft = HapticFeedbackStyle("soft")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.webapps.haptic
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
value class HapticFeedbackType @Warning("Do not use this constructor if available objects from companion cover your needs") constructor(
|
||||
val name: String
|
||||
) {
|
||||
companion object {
|
||||
val Error = HapticFeedbackType("error")
|
||||
val Success = HapticFeedbackType("success")
|
||||
val Warning = HapticFeedbackType("warning")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.webapps.invoice
|
||||
|
||||
external interface InvoiceClosedInfo {
|
||||
val url: String
|
||||
val status: String
|
||||
}
|
||||
|
||||
val InvoiceClosedInfo.statusTyped
|
||||
get() = when (status) {
|
||||
InvoiceStatus.Paid.name -> InvoiceStatus.Paid
|
||||
InvoiceStatus.Cancelled.name -> InvoiceStatus.Cancelled
|
||||
InvoiceStatus.Failed.name -> InvoiceStatus.Failed
|
||||
InvoiceStatus.Pending.name -> InvoiceStatus.Pending
|
||||
else -> InvoiceStatus.Unknown(status)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.webapps.invoice
|
||||
|
||||
sealed interface InvoiceStatus {
|
||||
val name: String
|
||||
object Paid : InvoiceStatus { override val name: String = "paid" }
|
||||
object Cancelled : InvoiceStatus { override val name: String = "cancelled" }
|
||||
object Failed : InvoiceStatus { override val name: String = "failed" }
|
||||
object Pending : InvoiceStatus { override val name: String = "pending" }
|
||||
value class Unknown(override val name: String) : InvoiceStatus
|
||||
}
|
||||
@@ -1,48 +1,17 @@
|
||||
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 = "Full collection of all built-in tgbotapi tools"
|
||||
|
||||
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")
|
||||
api project(":tgbotapi.api")
|
||||
api project(":tgbotapi.utils")
|
||||
@@ -52,9 +21,3 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user