mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-29 02:45:44 +00:00
Compare commits
10 Commits
klassindex
...
0.35.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 762087fc09 | |||
| 142fae1ede | |||
| 95abc72bf3 | |||
| 1d37a7446c | |||
| 7d35114b5d | |||
| 75f4226772 | |||
| 96d980cb8a | |||
| ed077ae1bc | |||
| 9540797ffc | |||
| 217b01994e |
@@ -8,6 +8,8 @@
|
|||||||
* `Ktor`: `1.6.1` -> `1.6.2`
|
* `Ktor`: `1.6.1` -> `1.6.2`
|
||||||
* `MicroUtils`: `0.5.16` -> `0.5.18`
|
* `MicroUtils`: `0.5.16` -> `0.5.18`
|
||||||
* `Core`:
|
* `Core`:
|
||||||
|
* **`SimpleRequestCallFactory` and `MultipartRequestCallFactory` became a classes instead of objects to avoid
|
||||||
|
collisions in different bots**
|
||||||
* Support of strongly-typed ietf language codes has been added
|
* Support of strongly-typed ietf language codes has been added
|
||||||
* `API`:
|
* `API`:
|
||||||
* New extension `TelegramBot#downloadFile` for any `MediaContent`
|
* New extension `TelegramBot#downloadFile` for any `MediaContent`
|
||||||
@@ -18,6 +20,8 @@
|
|||||||
* New `TelegramBot#buildBehaviour` extension with `FlowUpdatesFilter` and `CoroutineScope` with
|
* New `TelegramBot#buildBehaviour` extension with `FlowUpdatesFilter` and `CoroutineScope` with
|
||||||
default `CoroutineScope`
|
default `CoroutineScope`
|
||||||
* New typealias `SimpleFilter` for unifying triggers filter signatures
|
* New typealias `SimpleFilter` for unifying triggers filter signatures
|
||||||
|
* All waiters got real filters (`SimpleFilter`) and rename old filters as mappers
|
||||||
|
* New extensions for `Any`: `as`/`when`/`require` for `WithOptionalLanguageCode` and `WithLanguageCode`
|
||||||
|
|
||||||
## 0.35.2
|
## 0.35.2
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,8 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.plugin.serialization" 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 {
|
allprojects {
|
||||||
repositories {
|
|
||||||
maven { url 'https://jitpack.io' }
|
|
||||||
if (it != rootProject.findProject("docs")) {
|
if (it != rootProject.findProject("docs")) {
|
||||||
tasks.whenTaskAdded { task ->
|
tasks.whenTaskAdded { task ->
|
||||||
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
||||||
@@ -29,7 +28,6 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private String getCurrentVersionChangelog() {
|
private String getCurrentVersionChangelog() {
|
||||||
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
||||||
|
|||||||
@@ -77,17 +77,17 @@ Object callback = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// named("commonMain") {
|
named("commonMain") {
|
||||||
// sourceRoots.setFrom(findSourcesWithName("commonMain"))
|
sourceRoots.setFrom(findSourcesWithName("commonMain"))
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// named("jsMain") {
|
named("jsMain") {
|
||||||
// sourceRoots.setFrom(findSourcesWithName("jsMain"))
|
sourceRoots.setFrom(findSourcesWithName("jsMain"))
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// named("jvmMain") {
|
named("jvmMain") {
|
||||||
// sourceRoots.setFrom(findSourcesWithName("jvmMain"))
|
sourceRoots.setFrom(findSourcesWithName("jvmMain"))
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ buildscript {
|
|||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url "https://plugins.gradle.org/m2/" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,7 +14,6 @@ buildscript {
|
|||||||
plugins {
|
plugins {
|
||||||
id "org.jetbrains.kotlin.multiplatform"
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
id "org.jetbrains.kotlin.kapt"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "$library_version"
|
project.version = "$library_version"
|
||||||
@@ -56,7 +54,6 @@ kotlin {
|
|||||||
api "dev.inmo:micro_utils.language_codes:$micro_utils_version"
|
api "dev.inmo:micro_utils.language_codes:$micro_utils_version"
|
||||||
|
|
||||||
api "io.ktor:ktor-client-core:$ktor_version"
|
api "io.ktor:ktor-client-core:$ktor_version"
|
||||||
api "com.github.matfax.klassindex:library:4.+"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commonTest {
|
commonTest {
|
||||||
@@ -98,35 +95,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
kapt "com.github.matfax.klassindex:processor:4.+"
|
|
||||||
}
|
|
||||||
|
|
||||||
kapt {
|
|
||||||
useBuildCache = false
|
|
||||||
arguments {
|
|
||||||
arg(
|
|
||||||
"com.github.matfax.klassindex.IndexSubclasses",
|
|
||||||
// "dev.inmo.tgbotapi.types.update.abstracts.Update",
|
|
||||||
// "dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent",
|
|
||||||
// "dev.inmo.tgbotapi.types.passport.decrypted.abstracts.SecureValue",
|
|
||||||
// "dev.inmo.tgbotapi.types.message.content.abstracts.ResendableContent",
|
|
||||||
"dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode",
|
|
||||||
// "dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.EncryptedPassportElement",
|
|
||||||
// "dev.inmo.tgbotapi.types.passport.PassportElementError",
|
|
||||||
// "dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery",
|
|
||||||
// "dev.inmo.tgbotapi.types.buttons.KeyboardMarkup",
|
|
||||||
// "dev.inmo.tgbotapi.types.actions.BotAction",
|
|
||||||
// "dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton",
|
|
||||||
// "dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember",
|
|
||||||
// "dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile",
|
|
||||||
// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery",
|
|
||||||
// "dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult",
|
|
||||||
// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent",
|
|
||||||
// "dev.inmo.tgbotapi.types.InputMedia.InputMedia",
|
|
||||||
// "dev.inmo.tgbotapi.types.polls.Poll",
|
|
||||||
// "dev.inmo.tgbotapi.types.update.abstracts.Update"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
|
||||||
|
|
||||||
interface WithOptionalLanguageCode {
|
|
||||||
val ietfLanguageCode: IetfLanguageCode?
|
|
||||||
|
|
||||||
val languageCode: String?
|
|
||||||
get() = ietfLanguageCode ?.code
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WithLanguageCode : WithOptionalLanguageCode {
|
|
||||||
override val ietfLanguageCode: IetfLanguageCode
|
|
||||||
|
|
||||||
override val languageCode: String
|
|
||||||
get() = ietfLanguageCode.code
|
|
||||||
}
|
|
||||||
@@ -52,7 +52,7 @@ class KtorRequestsExecutor(
|
|||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||||
if (!excludeDefaultFactories) {
|
if (!excludeDefaultFactories) {
|
||||||
this + listOf(SimpleRequestCallFactory, MultipartRequestCallFactory, DownloadFileRequestCallFactory)
|
this + listOf(SimpleRequestCallFactory(), MultipartRequestCallFactory(), DownloadFileRequestCallFactory)
|
||||||
} else {
|
} else {
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import dev.inmo.tgbotapi.utils.mapWithCommonValues
|
import dev.inmo.tgbotapi.utils.mapWithCommonValues
|
||||||
@@ -9,7 +10,7 @@ import io.ktor.client.request.forms.formData
|
|||||||
import io.ktor.http.Headers
|
import io.ktor.http.Headers
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
|
|
||||||
object MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||||
override fun <T : Any> prepareCallBody(
|
override fun <T : Any> prepareCallBody(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
@@ -35,4 +36,7 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Use class MultipartRequestCallFactory() constructor call instead of just MultipartRequestCallFactory")
|
||||||
|
companion object : KtorCallFactory by MultipartRequestCallFactory()
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.content.TextContent
|
import io.ktor.http.content.TextContent
|
||||||
|
|
||||||
object SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
class SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
||||||
override fun <T : Any> prepareCallBody(
|
override fun <T : Any> prepareCallBody(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
@@ -19,4 +20,7 @@ object SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
ContentType.Application.Json
|
ContentType.Application.Json
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Use class SimpleRequestCallFactory() constructor call instead of just SimpleRequestCallFactory")
|
||||||
|
companion object : KtorCallFactory by SimpleRequestCallFactory()
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
|
|
||||||
sealed interface MyCommandsRequest<T : Any> : SimpleRequest<T>, WithOptionalLanguageCode {
|
sealed interface MyCommandsRequest<T : Any> : SimpleRequest<T>, WithOptionalLanguageCode {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package dev.inmo.tgbotapi.requests.bot
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.commands.*
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
|
import dev.inmo.tgbotapi.types.languageCodeField
|
||||||
|
import dev.inmo.tgbotapi.types.scopeField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializ
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageCaptionMethod = "editMessageCaption"
|
const val editMessageCaptionMethod = "editMessageCaption"
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun EditInlineMessageCaption(
|
fun EditInlineMessageCaption(
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageTextMethod = "editMessageText"
|
const val editMessageTextMethod = "editMessageText"
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun EditInlineMessageText(
|
fun EditInlineMessageText(
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageReques
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun CopyMessage(
|
fun CopyMessage(
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AnimationContent
|
import dev.inmo.tgbotapi.types.message.content.media.AnimationContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioContent
|
import dev.inmo.tgbotapi.types.message.content.media.AudioContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
|
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.PhotoContent
|
import dev.inmo.tgbotapi.types.message.content.media.PhotoContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VideoContent
|
import dev.inmo.tgbotapi.types.message.content.media.VideoContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VoiceContent
|
import dev.inmo.tgbotapi.types.message.content.media.VoiceContent
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.PollContent
|
import dev.inmo.tgbotapi.types.message.content.PollContent
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
import dev.inmo.tgbotapi.types.polls.*
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult
|
package dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
|
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||||
|
|
||||||
sealed interface ChosenInlineResult : FromUser {
|
sealed interface ChosenInlineResult : FromUser {
|
||||||
val resultId: InlineQueryIdentifier //chosen temporary, can be changed
|
val resultId: InlineQueryIdentifier //chosen temporary, can be changed
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
|
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
|
||||||
import dev.inmo.tgbotapi.utils.MimeType
|
import dev.inmo.tgbotapi.utils.MimeType
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.utils.MimeType
|
import dev.inmo.tgbotapi.utils.MimeType
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.utils.MimeType
|
import dev.inmo.tgbotapi.utils.MimeType
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
|
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
|
||||||
import dev.inmo.tgbotapi.utils.MimeType
|
import dev.inmo.tgbotapi.utils.MimeType
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
internal const val audioInputMediaType = "audio"
|
internal const val audioInputMediaType = "audio"
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import dev.inmo.tgbotapi.requests.abstracts.*
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
import dev.inmo.tgbotapi.types.files.DocumentFile
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
internal const val documentInputMediaType = "document"
|
internal const val documentInputMediaType = "document"
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
import dev.inmo.tgbotapi.types.files.PhotoSize
|
import dev.inmo.tgbotapi.types.files.PhotoSize
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
internal const val photoInputMediaType = "photo"
|
internal const val photoInputMediaType = "photo"
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||||
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
internal const val videoInputMediaType = "video"
|
internal const val videoInputMediaType = "video"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat
|
import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat
|
||||||
import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl
|
import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl
|
||||||
import dev.inmo.tgbotapi.utils.*
|
import dev.inmo.tgbotapi.utils.*
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
|
||||||
|
interface WithOptionalLanguageCode {
|
||||||
|
val ietfLanguageCode: IetfLanguageCode?
|
||||||
|
|
||||||
|
val languageCode: String?
|
||||||
|
get() = ietfLanguageCode ?.code
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.utils.internal
|
package dev.inmo.tgbotapi.utils.internal
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
import dev.inmo.tgbotapi.types.link
|
import dev.inmo.tgbotapi.types.link
|
||||||
import dev.inmo.tgbotapi.utils.extensions.*
|
import dev.inmo.tgbotapi.utils.extensions.*
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.WithLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun IetfLanguageCode?.javaLocale() = this ?.code ?.let { Locale.forLanguageTag(it) }
|
fun IetfLanguageCode?.javaLocale() = this ?.code ?.let { Locale.forLanguageTag(it) }
|
||||||
fun WithLanguageCode?.javaLocale() = this ?.ietfLanguageCode.javaLocale()
|
fun WithOptionalLanguageCode?.javaLocale() = this ?.ietfLanguageCode ?.javaLocale()
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
import com.github.matfax.klassindex.KlassIndex
|
|
||||||
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
|
|
||||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent
|
|
||||||
import dev.inmo.tgbotapi.types.InputMedia.InputMedia
|
|
||||||
import dev.inmo.tgbotapi.types.actions.BotAction
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
|
|
||||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.ResendableContent
|
|
||||||
import dev.inmo.tgbotapi.types.passport.PassportElementError
|
|
||||||
import dev.inmo.tgbotapi.types.passport.decrypted.abstracts.SecureValue
|
|
||||||
import dev.inmo.tgbotapi.types.polls.Poll
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
fun printlnInstanceSubclassesFuns(kclass: KClass<*>) {
|
|
||||||
KlassIndex.getSubclasses(Message::class).forEach { subclass ->
|
|
||||||
println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun printlnInstancesSubclassesFuns(kclass: KClass<*>, subclasses: Set<KClass<*>>): List<Pair<String, String>> {
|
|
||||||
return subclasses.map { subclass ->
|
|
||||||
val typeUpperBounds = subclass.typeParameters.map { it.upperBounds.first() }
|
|
||||||
val imports = "import ${subclass.qualifiedName}" + if (typeUpperBounds.isEmpty()) "" else typeUpperBounds.joinToString("\nimport ", "\nimport ")
|
|
||||||
val subtype = "${subclass.simpleName}${if (typeUpperBounds.isEmpty()) "" else "<${typeUpperBounds.joinToString() { (it.classifier as KClass<*>).simpleName!! }}>"}"
|
|
||||||
val code = "@PreviewFeature\ninline fun ${kclass.simpleName}.as${subclass.simpleName}(): $subtype? = this as? $subtype\n" +
|
|
||||||
"@PreviewFeature\ninline fun ${kclass.simpleName}.require${subclass.simpleName}(): $subtype = this as $subtype\n" +
|
|
||||||
"@PreviewFeature\ninline fun <T> ${kclass.simpleName}.when${subclass.simpleName}(block: (${subclass.simpleName}) -> T): $subtype = as${subclass.simpleName}() ?.let(block)"
|
|
||||||
imports to code
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val result = mutableMapOf<KClass<*>, Set<KClass<*>>>()
|
|
||||||
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
result[Message::class] = KlassIndex.getSubclasses(dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode::class).toSet()
|
|
||||||
println("import dev.inmo.tgbotapi.utils.PreviewFeature")
|
|
||||||
val importsToFuns = result.keys.flatMap {
|
|
||||||
println("import ${it.qualifiedName}")
|
|
||||||
printlnInstancesSubclassesFuns(it, result.getValue(it))
|
|
||||||
}
|
|
||||||
importsToFuns.forEach { println(it.first) }
|
|
||||||
println()
|
|
||||||
importsToFuns.forEach { println(it.second) }
|
|
||||||
// printlnInstanceSubclassesFuns(Message::class)
|
|
||||||
// printlnInstanceSubclassesFuns(Chat::class)
|
|
||||||
// printlnInstanceSubclassesFuns(CallbackQuery::class)
|
|
||||||
// printlnInstanceSubclassesFuns(KeyboardMarkup::class)
|
|
||||||
// printlnInstanceSubclassesFuns(BotAction::class)
|
|
||||||
// printlnInstanceSubclassesFuns(InlineKeyboardButton::class)
|
|
||||||
// printlnInstanceSubclassesFuns(ChatMember::class)
|
|
||||||
// printlnInstanceSubclassesFuns(TelegramMediaFile::class)
|
|
||||||
// printlnInstanceSubclassesFuns(InlineQuery::class)
|
|
||||||
// printlnInstanceSubclassesFuns(InlineQueryResult::class)
|
|
||||||
// printlnInstanceSubclassesFuns(InputMessageContent::class)
|
|
||||||
// printlnInstanceSubclassesFuns(InputMedia::class)
|
|
||||||
// printlnInstanceSubclassesFuns(Poll::class)
|
|
||||||
// printlnInstanceSubclassesFuns(Update::class)
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.CallbackQuery.*
|
import dev.inmo.tgbotapi.types.CallbackQuery.*
|
||||||
@@ -14,13 +15,19 @@ private suspend fun <O> BehaviourContext.waitCallbackQueries(
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
filter: SimpleFilter<CallbackQuery>? = null,
|
||||||
mapper: suspend CallbackQuery.() -> O?
|
mapper: suspend CallbackQuery.() -> O?
|
||||||
): List<O> = expectFlow(
|
): List<O> = expectFlow(
|
||||||
initRequest,
|
initRequest,
|
||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
it.asCallbackQueryUpdate() ?.data ?.mapper().let(::listOfNotNull)
|
val data = it.asCallbackQueryUpdate() ?.data
|
||||||
|
if (data != null && (filter == null || filter(data))) {
|
||||||
|
data.mapper().let(::listOfNotNull)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
|
|
||||||
@@ -28,17 +35,23 @@ private suspend inline fun <reified T : CallbackQuery> BehaviourContext.waitCall
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: CallbackQueryMapper<T>? = null
|
noinline filter: SimpleFilter<T>? = null,
|
||||||
|
noinline mapper: CallbackQueryMapper<T>? = null
|
||||||
) : List<T> = waitCallbackQueries<T>(
|
) : List<T> = waitCallbackQueries<T>(
|
||||||
count,
|
count,
|
||||||
initRequest,
|
initRequest,
|
||||||
errorFactory
|
errorFactory,
|
||||||
|
filter ?.let {
|
||||||
|
{
|
||||||
|
(it as? T) ?.let { filter(it) } == true
|
||||||
|
}
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
if (this is T) {
|
if (this is T) {
|
||||||
if (filter == null) {
|
if (mapper == null) {
|
||||||
this
|
this
|
||||||
} else {
|
} else {
|
||||||
filter(this)
|
mapper(this)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@@ -50,53 +63,62 @@ suspend fun BehaviourContext.waitDataCallbackQuery(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<DataCallbackQuery>? = null
|
filter: SimpleFilter<DataCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<DataCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitGameShortNameCallbackQuery(
|
suspend fun BehaviourContext.waitGameShortNameCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<GameShortNameCallbackQuery>? = null
|
filter: SimpleFilter<GameShortNameCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<GameShortNameCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitInlineMessageIdCallbackQuery(
|
suspend fun BehaviourContext.waitInlineMessageIdCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<InlineMessageIdCallbackQuery>? = null
|
filter: SimpleFilter<InlineMessageIdCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<InlineMessageIdCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitInlineMessageIdDataCallbackQuery(
|
suspend fun BehaviourContext.waitInlineMessageIdDataCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<InlineMessageIdDataCallbackQuery>? = null
|
filter: SimpleFilter<InlineMessageIdDataCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<InlineMessageIdDataCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitInlineMessageIdGameShortNameCallbackQuery(
|
suspend fun BehaviourContext.waitInlineMessageIdGameShortNameCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<InlineMessageIdGameShortNameCallbackQuery>? = null
|
filter: SimpleFilter<InlineMessageIdGameShortNameCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<InlineMessageIdGameShortNameCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitMessageCallbackQuery(
|
suspend fun BehaviourContext.waitMessageCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<MessageCallbackQuery>? = null
|
filter: SimpleFilter<MessageCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<MessageCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitMessageDataCallbackQuery(
|
suspend fun BehaviourContext.waitMessageDataCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<MessageDataCallbackQuery>? = null
|
filter: SimpleFilter<MessageDataCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<MessageDataCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitMessageGameShortNameCallbackQuery(
|
suspend fun BehaviourContext.waitMessageGameShortNameCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<MessageGameShortNameCallbackQuery>? = null
|
filter: SimpleFilter<MessageGameShortNameCallbackQuery>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<MessageGameShortNameCallbackQuery>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitUnknownCallbackQuery(
|
suspend fun BehaviourContext.waitUnknownCallbackQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CallbackQueryMapper<UnknownCallbackQueryType>? = null
|
filter: SimpleFilter<UnknownCallbackQueryType>? = null,
|
||||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
mapper: CallbackQueryMapper<UnknownCallbackQueryType>? = null
|
||||||
|
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.ChatMemberUpdated
|
import dev.inmo.tgbotapi.types.ChatMemberUpdated
|
||||||
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
|
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
|
||||||
@@ -14,29 +15,37 @@ private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContex
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
noinline filter: SimpleFilter<T>? = null,
|
||||||
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>
|
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>
|
||||||
): List<ChatMemberUpdated> = expectFlow(
|
): List<ChatMemberUpdated> = expectFlow(
|
||||||
initRequest,
|
initRequest,
|
||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
(it as? T) ?.data.let(::listOfNotNull)
|
val casted = (it as? T) ?: return@expectFlow emptyList()
|
||||||
|
if (filter == null || filter(casted)) {
|
||||||
|
casted.data.mapper().let(::listOfNotNull)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContext.waitChatMemberUpdatedWithFilter(
|
private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContext.waitChatMemberUpdatedWithFilter(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
noinline filter: SimpleFilter<T>? = null,
|
||||||
|
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||||
) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>(
|
) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>(
|
||||||
count,
|
count,
|
||||||
initRequest,
|
initRequest,
|
||||||
errorFactory
|
errorFactory,
|
||||||
|
filter,
|
||||||
) {
|
) {
|
||||||
if (filter == null) {
|
if (mapper == null) {
|
||||||
this
|
this
|
||||||
} else {
|
} else {
|
||||||
filter(this)
|
mapper(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,19 +53,22 @@ suspend fun BehaviourContext.waitChatMemberUpdated(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
filter: SimpleFilter<ChatMemberUpdatedUpdate>? = null,
|
||||||
) = waitChatMemberUpdatedWithFilter<ChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter)
|
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||||
|
) = waitChatMemberUpdatedWithFilter<ChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitCommonChatMemberUpdated(
|
suspend fun BehaviourContext.waitCommonChatMemberUpdated(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
filter: SimpleFilter<CommonChatMemberUpdatedUpdate>? = null,
|
||||||
) = waitChatMemberUpdatedWithFilter<CommonChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter)
|
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||||
|
) = waitChatMemberUpdatedWithFilter<CommonChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitMyChatMemberUpdated(
|
suspend fun BehaviourContext.waitMyChatMemberUpdated(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
filter: SimpleFilter<MyChatMemberUpdatedUpdate>? = null,
|
||||||
) = waitChatMemberUpdatedWithFilter<MyChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter)
|
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||||
|
) = waitChatMemberUpdatedWithFilter<MyChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|||||||
@@ -4,13 +4,16 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.media.*
|
||||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
||||||
|
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|
||||||
typealias CommonMessageToContentMapper<T> = suspend CommonMessage<T>.() -> T?
|
typealias CommonMessageToContentMapper<T> = suspend CommonMessage<T>.() -> T?
|
||||||
@@ -20,18 +23,32 @@ private suspend fun <O> BehaviourContext.waitCommonMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||||
mapper: suspend CommonMessage<MessageContent>.() -> O?
|
mapper: suspend CommonMessage<MessageContent>.() -> O?
|
||||||
): List<O> = expectFlow(
|
): List<O> = expectFlow(
|
||||||
initRequest,
|
initRequest,
|
||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
|
val messages = when (it) {
|
||||||
|
is SentMediaGroupUpdate -> {
|
||||||
if (includeMediaGroups) {
|
if (includeMediaGroups) {
|
||||||
it.asSentMediaGroupUpdate() ?.data ?.mapNotNull {
|
it.data.map { it as CommonMessage<MessageContent> }
|
||||||
(it as CommonMessage<MessageContent>).mapper()
|
} else {
|
||||||
} ?.let { return@expectFlow it }
|
emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is BaseSentMessageUpdate -> listOf(it.data)
|
||||||
|
else -> return@expectFlow emptyList()
|
||||||
|
}
|
||||||
|
messages.mapNotNull { message ->
|
||||||
|
val asCommonMessage = message as CommonMessage<MessageContent>
|
||||||
|
if (filter == null || filter(asCommonMessage)) {
|
||||||
|
asCommonMessage.mapper()
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
it.asBaseSentMessageUpdate() ?.data ?.asCommonMessage() ?.mapper().let(::listOfNotNull)
|
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContent(
|
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContent(
|
||||||
@@ -39,20 +56,26 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitCon
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: CommonMessageToContentMapper<T>? = null
|
noinline filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||||
|
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||||
) : List<T> = waitCommonMessage<T>(
|
) : List<T> = waitCommonMessage<T>(
|
||||||
count,
|
count,
|
||||||
initRequest,
|
initRequest,
|
||||||
includeMediaGroups,
|
includeMediaGroups,
|
||||||
errorFactory
|
errorFactory,
|
||||||
|
filter ?.let {
|
||||||
|
{
|
||||||
|
it.withContent<T>() ?.let { filter(it) } == true
|
||||||
|
}
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
if (content is T) {
|
if (content is T) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val message = (this as CommonMessage<T>)
|
val message = (this as CommonMessage<T>)
|
||||||
if (filter == null) {
|
if (mapper == null) {
|
||||||
message.content
|
message.content
|
||||||
} else {
|
} else {
|
||||||
safelyWithoutExceptions { filter(message) }
|
safelyWithoutExceptions { mapper(message) }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@@ -64,140 +87,162 @@ suspend fun BehaviourContext.waitContentMessage(
|
|||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
filter: CommonMessageToContentMapper<MessageContent>? = null
|
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<MessageContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitContact(
|
suspend fun BehaviourContext.waitContact(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<ContactContent>? = null
|
filter: SimpleFilter<CommonMessage<ContactContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<ContactContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitDice(
|
suspend fun BehaviourContext.waitDice(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<DiceContent>? = null
|
filter: SimpleFilter<CommonMessage<DiceContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<DiceContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitGame(
|
suspend fun BehaviourContext.waitGame(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<GameContent>? = null
|
filter: SimpleFilter<CommonMessage<GameContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<GameContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitLocation(
|
suspend fun BehaviourContext.waitLocation(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<LocationContent>? = null
|
filter: SimpleFilter<CommonMessage<LocationContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<LocationContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitPoll(
|
suspend fun BehaviourContext.waitPoll(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<PollContent>? = null
|
filter: SimpleFilter<CommonMessage<PollContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<PollContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitText(
|
suspend fun BehaviourContext.waitText(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<TextContent>? = null
|
filter: SimpleFilter<CommonMessage<TextContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<TextContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVenue(
|
suspend fun BehaviourContext.waitVenue(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<VenueContent>? = null
|
filter: SimpleFilter<CommonMessage<VenueContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<VenueContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
filter: CommonMessageToContentMapper<AudioMediaGroupContent>? = null
|
filter: SimpleFilter<CommonMessage<AudioMediaGroupContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<AudioMediaGroupContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
filter: CommonMessageToContentMapper<DocumentMediaGroupContent>? = null
|
filter: SimpleFilter<CommonMessage<DocumentMediaGroupContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<DocumentMediaGroupContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitMedia(
|
suspend fun BehaviourContext.waitMedia(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = false,
|
includeMediaGroups: Boolean = false,
|
||||||
filter: CommonMessageToContentMapper<MediaContent>? = null
|
filter: SimpleFilter<CommonMessage<MediaContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<MediaContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
filter: CommonMessageToContentMapper<MediaGroupContent>? = null
|
filter: SimpleFilter<CommonMessage<MediaGroupContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<MediaGroupContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
filter: CommonMessageToContentMapper<VisualMediaGroupContent>? = null
|
filter: SimpleFilter<CommonMessage<VisualMediaGroupContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<VisualMediaGroupContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitAnimation(
|
suspend fun BehaviourContext.waitAnimation(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<AnimationContent>? = null
|
filter: SimpleFilter<CommonMessage<AnimationContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<AnimationContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitAudio(
|
suspend fun BehaviourContext.waitAudio(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = false,
|
includeMediaGroups: Boolean = false,
|
||||||
filter: CommonMessageToContentMapper<AudioContent>? = null
|
filter: SimpleFilter<CommonMessage<AudioContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<AudioContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitDocument(
|
suspend fun BehaviourContext.waitDocument(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = false,
|
includeMediaGroups: Boolean = false,
|
||||||
filter: CommonMessageToContentMapper<DocumentContent>? = null
|
filter: SimpleFilter<CommonMessage<DocumentContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<DocumentContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitPhoto(
|
suspend fun BehaviourContext.waitPhoto(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = false,
|
includeMediaGroups: Boolean = false,
|
||||||
filter: CommonMessageToContentMapper<PhotoContent>? = null
|
filter: SimpleFilter<CommonMessage<PhotoContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<PhotoContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitSticker(
|
suspend fun BehaviourContext.waitSticker(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<StickerContent>? = null
|
filter: SimpleFilter<CommonMessage<StickerContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<StickerContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVideo(
|
suspend fun BehaviourContext.waitVideo(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
includeMediaGroups: Boolean = false,
|
includeMediaGroups: Boolean = false,
|
||||||
filter: CommonMessageToContentMapper<VideoContent>? = null
|
filter: SimpleFilter<CommonMessage<VideoContent>>? = null,
|
||||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<VideoContent>? = null
|
||||||
|
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVideoNote(
|
suspend fun BehaviourContext.waitVideoNote(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<VideoNoteContent>? = null
|
filter: SimpleFilter<CommonMessage<VideoNoteContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<VideoNoteContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVoice(
|
suspend fun BehaviourContext.waitVoice(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<VoiceContent>? = null
|
filter: SimpleFilter<CommonMessage<VoiceContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<VoiceContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitInvoice(
|
suspend fun BehaviourContext.waitInvoice(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: CommonMessageToContentMapper<InvoiceContent>? = null
|
filter: SimpleFilter<CommonMessage<InvoiceContent>>? = null,
|
||||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
mapper: CommonMessageToContentMapper<InvoiceContent>? = null
|
||||||
|
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asBaseSentMessageUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asBaseSentMessageUpdate
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage
|
import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
@@ -18,13 +19,19 @@ private suspend fun <O> BehaviourContext.waitEventMessages(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
|
filter: SimpleFilter<ChatEventMessage<ChatEvent>>? = null,
|
||||||
mapper: suspend ChatEventMessage<ChatEvent>.() -> O?
|
mapper: suspend ChatEventMessage<ChatEvent>.() -> O?
|
||||||
): List<O> = expectFlow(
|
): List<O> = expectFlow(
|
||||||
initRequest,
|
initRequest,
|
||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull)
|
val data = it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage()
|
||||||
|
if (data != null && (filter == null || filter(data))) {
|
||||||
|
data.mapper().let(::listOfNotNull)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
|
|
||||||
@@ -32,19 +39,25 @@ private suspend inline fun <reified T : ChatEvent> BehaviourContext.waitEvents(
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: EventMessageToEventMapper<T>? = null
|
noinline filter: SimpleFilter<ChatEventMessage<T>>? = null,
|
||||||
|
noinline mapper: EventMessageToEventMapper<T>? = null
|
||||||
) : List<T> = waitEventMessages<T>(
|
) : List<T> = waitEventMessages<T>(
|
||||||
initRequest,
|
initRequest,
|
||||||
errorFactory,
|
errorFactory,
|
||||||
count
|
count,
|
||||||
|
filter ?.let {
|
||||||
|
{
|
||||||
|
(it.chatEvent as? T) ?.let { filter(it as ChatEventMessage<T>) } == true
|
||||||
|
}
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
if (chatEvent is T) {
|
if (chatEvent is T) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val message = (this as ChatEventMessage<T>)
|
val message = (this as ChatEventMessage<T>)
|
||||||
if (filter == null) {
|
if (mapper == null) {
|
||||||
message.chatEvent
|
message.chatEvent
|
||||||
} else {
|
} else {
|
||||||
filter(message)
|
mapper(message)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@@ -55,124 +68,144 @@ suspend fun BehaviourContext.waitChannelEvents(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<ChannelEvent>? = null
|
filter: SimpleFilter<ChatEventMessage<ChannelEvent>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<ChannelEvent>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatEvents(
|
suspend fun BehaviourContext.waitChatEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<ChatEvent>? = null
|
filter: SimpleFilter<ChatEventMessage<ChatEvent>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<ChatEvent>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitVoiceChatEvents(
|
suspend fun BehaviourContext.waitVoiceChatEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<VoiceChatEvent>? = null
|
filter: SimpleFilter<ChatEventMessage<VoiceChatEvent>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<VoiceChatEvent>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVoiceChatStartedEvents(
|
suspend fun BehaviourContext.waitVoiceChatStartedEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<VoiceChatStarted>? = null
|
filter: SimpleFilter<ChatEventMessage<VoiceChatStarted>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<VoiceChatStarted>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVoiceChatEndedEvents(
|
suspend fun BehaviourContext.waitVoiceChatEndedEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<VoiceChatEnded>? = null
|
filter: SimpleFilter<ChatEventMessage<VoiceChatEnded>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<VoiceChatEnded>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents(
|
suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<VoiceChatParticipantsInvited>? = null
|
filter: SimpleFilter<ChatEventMessage<VoiceChatParticipantsInvited>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<VoiceChatParticipantsInvited>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents(
|
suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<MessageAutoDeleteTimerChanged>? = null
|
filter: SimpleFilter<ChatEventMessage<MessageAutoDeleteTimerChanged>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<MessageAutoDeleteTimerChanged>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitCommonEvents(
|
suspend fun BehaviourContext.waitCommonEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<CommonEvent>? = null
|
filter: SimpleFilter<ChatEventMessage<CommonEvent>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<CommonEvent>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitGroupEvents(
|
suspend fun BehaviourContext.waitGroupEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<GroupEvent>? = null
|
filter: SimpleFilter<ChatEventMessage<GroupEvent>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<GroupEvent>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitSupergroupEvents(
|
suspend fun BehaviourContext.waitSupergroupEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<SupergroupEvent>? = null
|
filter: SimpleFilter<ChatEventMessage<SupergroupEvent>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<SupergroupEvent>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChannelChatCreatedEvents(
|
suspend fun BehaviourContext.waitChannelChatCreatedEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<ChannelChatCreated>? = null
|
filter: SimpleFilter<ChatEventMessage<ChannelChatCreated>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<ChannelChatCreated>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitDeleteChatPhotoEvents(
|
suspend fun BehaviourContext.waitDeleteChatPhotoEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<DeleteChatPhoto>? = null
|
filter: SimpleFilter<ChatEventMessage<DeleteChatPhoto>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<DeleteChatPhoto>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitGroupChatCreatedEvents(
|
suspend fun BehaviourContext.waitGroupChatCreatedEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<GroupChatCreated>? = null
|
filter: SimpleFilter<ChatEventMessage<GroupChatCreated>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<GroupChatCreated>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<LeftChatMember>? = null
|
filter: SimpleFilter<ChatEventMessage<LeftChatMember>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<LeftChatMember>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<NewChatPhoto>? = null
|
filter: SimpleFilter<ChatEventMessage<NewChatPhoto>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<NewChatPhoto>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitNewChatMembersEvents(
|
suspend fun BehaviourContext.waitNewChatMembersEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<NewChatMembers>? = null
|
filter: SimpleFilter<ChatEventMessage<NewChatMembers>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<NewChatMembers>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitNewChatTitleEvents(
|
suspend fun BehaviourContext.waitNewChatTitleEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<NewChatTitle>? = null
|
filter: SimpleFilter<ChatEventMessage<NewChatTitle>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<NewChatTitle>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitPinnedMessageEvents(
|
suspend fun BehaviourContext.waitPinnedMessageEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<PinnedMessage>? = null
|
filter: SimpleFilter<ChatEventMessage<PinnedMessage>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<PinnedMessage>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitProximityAlertTriggeredEvents(
|
suspend fun BehaviourContext.waitProximityAlertTriggeredEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<ProximityAlertTriggered>? = null
|
filter: SimpleFilter<ChatEventMessage<ProximityAlertTriggered>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<ProximityAlertTriggered>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitSupergroupChatCreatedEvents(
|
suspend fun BehaviourContext.waitSupergroupChatCreatedEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<SupergroupChatCreated>? = null
|
filter: SimpleFilter<ChatEventMessage<SupergroupChatCreated>>? = null,
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
mapper: EventMessageToEventMapper<SupergroupChatCreated>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||||
@@ -12,13 +13,19 @@ private suspend fun <O> BehaviourContext.waitInlineQueries(
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
filter: SimpleFilter<InlineQuery>? = null,
|
||||||
mapper: suspend InlineQuery.() -> O?
|
mapper: suspend InlineQuery.() -> O?
|
||||||
): List<O> = expectFlow(
|
): List<O> = expectFlow(
|
||||||
initRequest,
|
initRequest,
|
||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
it.asInlineQueryUpdate() ?.data ?.mapper().let(::listOfNotNull)
|
val data = it.asInlineQueryUpdate() ?.data
|
||||||
|
if (data != null && (filter == null || filter(data))) {
|
||||||
|
data.mapper().let(::listOfNotNull)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
|
|
||||||
@@ -26,17 +33,23 @@ private suspend inline fun <reified T : InlineQuery> BehaviourContext.waitInline
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: InlineQueryMapper<T>? = null
|
noinline filter: SimpleFilter<T>? = null,
|
||||||
|
noinline mapper: InlineQueryMapper<T>? = null
|
||||||
) : List<T> = waitInlineQueries<T>(
|
) : List<T> = waitInlineQueries<T>(
|
||||||
count,
|
count,
|
||||||
initRequest,
|
initRequest,
|
||||||
errorFactory
|
errorFactory,
|
||||||
|
filter ?.let {
|
||||||
|
{
|
||||||
|
(it as? T) ?.let { casted -> filter(casted) } == true
|
||||||
|
}
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
if (this is T) {
|
if (this is T) {
|
||||||
if (filter == null) {
|
if (mapper == null) {
|
||||||
this
|
this
|
||||||
} else {
|
} else {
|
||||||
filter(this)
|
mapper(this)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@@ -47,18 +60,21 @@ suspend fun BehaviourContext.waitAnyInlineQuery(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: InlineQueryMapper<InlineQuery>? = null
|
filter: SimpleFilter<InlineQuery>? = null,
|
||||||
) = waitInlines(count, initRequest, errorFactory, filter)
|
mapper: InlineQueryMapper<InlineQuery>? = null
|
||||||
|
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitBaseInlineQuery(
|
suspend fun BehaviourContext.waitBaseInlineQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: InlineQueryMapper<BaseInlineQuery>? = null
|
filter: SimpleFilter<BaseInlineQuery>? = null,
|
||||||
) = waitInlines(count, initRequest, errorFactory, filter)
|
mapper: InlineQueryMapper<BaseInlineQuery>? = null
|
||||||
|
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||||
suspend fun BehaviourContext.waitLocationInlineQuery(
|
suspend fun BehaviourContext.waitLocationInlineQuery(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: InlineQueryMapper<LocationInlineQuery>? = null
|
filter: SimpleFilter<LocationInlineQuery>? = null,
|
||||||
) = waitInlines(count, initRequest, errorFactory, filter)
|
mapper: InlineQueryMapper<LocationInlineQuery>? = null
|
||||||
|
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
|
import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
@@ -17,30 +18,38 @@ suspend fun <O> BehaviourContext.waitPassportMessages(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
|
filter: SimpleFilter<PassportMessage>? = null,
|
||||||
mapper: suspend PassportMessage.() -> O?
|
mapper: suspend PassportMessage.() -> O?
|
||||||
): List<O> = expectFlow(
|
): List<O> = expectFlow(
|
||||||
initRequest,
|
initRequest,
|
||||||
count,
|
count,
|
||||||
errorFactory
|
errorFactory
|
||||||
) {
|
) {
|
||||||
it.asMessageUpdate() ?.data ?.asPassportMessage() ?.mapper().let(::listOfNotNull)
|
val data = it.asMessageUpdate() ?.data ?.asPassportMessage() ?: return@expectFlow emptyList()
|
||||||
|
if (filter == null || filter(data)) {
|
||||||
|
data.mapper().let(::listOfNotNull)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
}.toList().toList()
|
}.toList().toList()
|
||||||
|
|
||||||
suspend inline fun <reified T : EncryptedPassportElement> BehaviourContext.waitPassportMessagesWith(
|
suspend inline fun <reified T : EncryptedPassportElement> BehaviourContext.waitPassportMessagesWith(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: PassportMessageMapper? = null
|
noinline filter: SimpleFilter<PassportMessage>? = null,
|
||||||
|
noinline mapper: PassportMessageMapper? = null
|
||||||
) : List<PassportData> = waitPassportMessages(
|
) : List<PassportData> = waitPassportMessages(
|
||||||
initRequest,
|
initRequest,
|
||||||
errorFactory,
|
errorFactory,
|
||||||
count
|
count,
|
||||||
|
filter
|
||||||
) {
|
) {
|
||||||
if (passportData.data.any { it is T }) {
|
if (passportData.data.any { it is T }) {
|
||||||
if (filter == null) {
|
if (mapper == null) {
|
||||||
passportData
|
passportData
|
||||||
} else {
|
} else {
|
||||||
filter(this)
|
mapper(this)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@@ -51,5 +60,6 @@ suspend fun BehaviourContext.waitAnyPassportMessages(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: PassportMessageMapper? = null
|
filter: SimpleFilter<PassportMessage>? = null,
|
||||||
) = waitPassportMessagesWith<EncryptedPassportElement>(count, initRequest, errorFactory, filter)
|
mapper: PassportMessageMapper? = null
|
||||||
|
) = waitPassportMessagesWith<EncryptedPassportElement>(count, initRequest, errorFactory, filter, mapper)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.*
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||||
import dev.inmo.tgbotapi.types.InputMedia.*
|
import dev.inmo.tgbotapi.types.InputMedia.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.types.actions.*
|
import dev.inmo.tgbotapi.types.actions.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.*
|
import dev.inmo.tgbotapi.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
||||||
@@ -3106,3 +3107,12 @@ inline fun Any.asFromUser(): FromUser? = this as? FromUser
|
|||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun Any.requireFromUser(): FromUser = this as FromUser
|
inline fun Any.requireFromUser(): FromUser = this as FromUser
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun <T> Any.whenWithOptionalLanguageCode(block: (WithOptionalLanguageCode) -> T) = asWithOptionalLanguageCode() ?.let(block)
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun Any.asWithOptionalLanguageCode(): WithOptionalLanguageCode? = this as? WithOptionalLanguageCode
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun Any.requireWithOptionalLanguageCode(): WithOptionalLanguageCode = this as WithOptionalLanguageCode
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.utils.extensions
|
package dev.inmo.tgbotapi.extensions.utils.extensions
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asFromUser
|
import dev.inmo.tgbotapi.extensions.utils.asFromUser
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asFromUserMessage
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asUser
|
import dev.inmo.tgbotapi.extensions.utils.asUser
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat
|
||||||
import dev.inmo.tgbotapi.types.User
|
import dev.inmo.tgbotapi.types.User
|
||||||
|
|||||||
Reference in New Issue
Block a user