diff --git a/CHANGELOG.md b/CHANGELOG.md index 64ffa63f2e..2f18ad2b52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # TelegramBotAPI changelog +## 0.25.0 + +* Common: + * Versions updates: + * `Kotlin`: `1.3.61` -> `1.3.70` + * `Kotlin coroutines`: `1.3.3` -> `1.3.5` + * `Kotlin serialization`: `0.14.0` -> `0.20.0` + * `Ktor`: `1.3.1` -> `1.3.2` + * `Klock`: `1.8.7` -> `1.10.0` + * `UUID`: `0.0.7` -> `0.1.0` +* `TelegramBotAPI`: + * `Bot` implementations (as and `Bot` itself) now have not nullable `username` + * `File#toInputFile` extension now will throw error when file does not exists + * `InlineKeyboardMarkup` will check that `PayInlineKeyboardButton` is the first in case if it is exists in + `keyboard` + * `makeLinkToMessage` now is not `PreviewFeature` + * All deprecations was removed + * `RequestException` now extends `io.ktor.utils.io.errors.IOException` instead of `kotlinx.io.IOException` + * `Any#toJson` now is NOT `inline` + * `FlowsUpdatesFilter` now as marked my annotation `FlowPreview` + * `PathedFile#fullUrl` now is not `inline` function + * `SimpleRequest#json` now is not `inline` and `internal` function + ## 0.24.0 * `TelegramBotAPI`: diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt index 26aabea908..28a3471007 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt @@ -1,14 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize suspend fun RequestsExecutor.sendAnimation( chatId: ChatIdentifier, diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt index 49c3599d3f..afcbd0983d 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt @@ -1,14 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize suspend fun RequestsExecutor.sendAudio( chatId: ChatIdentifier, diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt index a59bfcc7b0..0e583adabc 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt @@ -1,14 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize suspend fun RequestsExecutor.sendDocument( chatId: ChatIdentifier, diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt index 0d3d93311b..c42d4d8a0d 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt @@ -1,14 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.files.* suspend fun RequestsExecutor.sendPhoto( chatId: ChatIdentifier, diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt index 031c6d99bf..2235b2a960 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticker import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker suspend fun RequestsExecutor.sendSticker( chatId: ChatIdentifier, diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt index dab5fb8eb9..38c9062991 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt @@ -1,13 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideo import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile suspend fun RequestsExecutor.sendVideo( diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt index 15c6e16a97..21b3060189 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt @@ -1,13 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideoNote import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile suspend fun RequestsExecutor.sendVideoNote( diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt index c837c19128..91e8e70ed2 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt @@ -1,14 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize suspend fun RequestsExecutor.sendVoice( chatId: ChatIdentifier, diff --git a/TelegramBotAPI/build.gradle b/TelegramBotAPI/build.gradle index 85296ef5fe..d42e420763 100644 --- a/TelegramBotAPI/build.gradle +++ b/TelegramBotAPI/build.gradle @@ -39,6 +39,7 @@ kotlin { implementation kotlin('stdlib') api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version" api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version" + api "org.jetbrains.kotlinx:kotlinx-serialization-properties-common:$kotlin_serialisation_runtime_version" api "com.soywiz.korlibs.klock:klock:$klock_version" api "com.benasher44:uuid:$uuid_version" @@ -56,6 +57,7 @@ kotlin { jvmMain { dependencies { api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version" + api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version" api "io.ktor:ktor-client:$ktor_version" api "io.ktor:ktor-server:$ktor_version" @@ -73,9 +75,19 @@ kotlin { jsMain { dependencies { api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version" + api "org.jetbrains.kotlinx:kotlinx-serialization-properties-js:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version" api "io.ktor:ktor-client-js:$ktor_version" } } } + + + targets.all { + compilations.all { + kotlinOptions { + freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"] + } + } + } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt index 33d33a6bcc..ae1f2a4407 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt @@ -10,6 +10,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.types.Response import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import io.ktor.client.HttpClient import io.ktor.client.call.receive import io.ktor.client.features.* @@ -25,7 +26,7 @@ class KtorRequestsExecutor( callsFactories: List = emptyList(), excludeDefaultFactories: Boolean = false, private val requestsLimiter: RequestLimiter = EmptyLimiter, - private val jsonFormatter: Json = Json.nonstrict + private val jsonFormatter: Json = nonstrictJsonFormat ) : BaseRequestsExecutor(telegramAPIUrlsKeeper) { private val callsFactories: List = callsFactories.run { if (!excludeDefaultFactories) { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/UpdatesPoller.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/UpdatesPoller.kt deleted file mode 100644 index f2fb0a61ec..0000000000 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/UpdatesPoller.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.github.insanusmokrassar.TelegramBotAPI.bot - -import io.ktor.utils.io.core.Closeable -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers - -@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api") -interface UpdatesPoller : Closeable { - fun start(scope: CoroutineScope = CoroutineScope(Dispatchers.Default)) -} \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt index 4ec766ec53..4db320d4c0 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions import com.github.insanusmokrassar.TelegramBotAPI.types.Response -import kotlinx.io.IOException +import io.ktor.utils.io.errors.IOException fun newRequestException( response: Response, diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt index d5280dabae..42a12caa77 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt @@ -1,13 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class DeleteMessage( @@ -19,7 +16,7 @@ data class DeleteMessage( override fun method(): String = "deleteMessage" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt index 807c0226a8..21c92f71cd 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt @@ -1,11 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblyForwardedMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import kotlinx.serialization.* private val AbleToBeForwardedMessageDeserializer = TelegramBotAPIMessageDeserializationStrategyClass() diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt index 03c8fe5407..b0cd428c8c 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ExtendedBot import kotlinx.serialization.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt index 4c5a4547c4..5f89bcc368 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt @@ -5,9 +5,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer -private val updatesListSerializer = ArrayListSerializer( +private val updatesListSerializer = ListSerializer( UpdateSerializerWithoutDeserialization ) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/StopPoll.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/StopPoll.kt index b203433871..9b8b83166b 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/StopPoll.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/StopPoll.kt @@ -2,12 +2,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll import kotlinx.serialization.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFile.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFile.kt index 4a7cebba14..03065c533b 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFile.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFile.kt @@ -2,7 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor @Serializable(InputFileSerializer::class) sealed class InputFile { @@ -22,8 +21,8 @@ fun String.toInputFile() = FileId(this) @Serializer(InputFile::class) internal object InputFileSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName(FileId::class.toString()) - override fun serialize(encoder: Encoder, obj: InputFile) = encoder.encodeString(obj.fileId) + override val descriptor: SerialDescriptor = PrimitiveDescriptor(FileId::class.toString(), PrimitiveKind.STRING) + override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId) override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString()) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/SimpleRequest.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/SimpleRequest.kt index 523b1c069d..89ba8af5b5 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/SimpleRequest.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/SimpleRequest.kt @@ -9,4 +9,4 @@ interface SimpleRequest : Request { } @Suppress("UNCHECKED_CAST") -inline fun > K.json(): JsonObject = toJsonWithoutNulls(requestSerializer as SerializationStrategy) +internal fun > K.json(): JsonObject = toJsonWithoutNulls(requestSerializer as SerializationStrategy) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt index 74465b9d26..077255c52c 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt @@ -1,11 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class AnswerCallbackQuery( @@ -22,7 +21,7 @@ data class AnswerCallbackQuery( ) : SimpleRequest { override fun method(): String = "answerCallbackQuery" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerInlineQuery.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerInlineQuery.kt index 0fb9a4097a..039c038243 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerInlineQuery.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerInlineQuery.kt @@ -1,14 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InlineQuery import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class AnswerInlineQuery( @@ -30,7 +29,7 @@ data class AnswerInlineQuery( ): SimpleRequest { override fun method(): String = "answerInlineQuery" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } @@ -52,6 +51,6 @@ fun InlineQuery.createAnswer( switchPmParameter ) -internal object InlineQueryAnswersResultsSerializer: KSerializer> by ArrayListSerializer( +internal object InlineQueryAnswersResultsSerializer: KSerializer> by ListSerializer( InlineQueryResultSerializer ) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerPreCheckoutQuery.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerPreCheckoutQuery.kt index 2fa9b4277c..ff7d297270 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerPreCheckoutQuery.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerPreCheckoutQuery.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerShippingQuery.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerShippingQuery.kt index 8a9c41d455..5e61840797 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerShippingQuery.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/AnswerShippingQuery.kt @@ -1,12 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer @Serializable data class AnswerShippingQueryOk( @@ -22,7 +21,7 @@ data class AnswerShippingQueryOk( get() = serializer() } -internal object ShippingOptionsSerializer : KSerializer> by ArrayListSerializer( +internal object ShippingOptionsSerializer : KSerializer> by ListSerializer( ShippingOption.serializer() ) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerPreCheckoutQuery.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerPreCheckoutQuery.kt index 20388ba7e2..4fcca89ae9 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerPreCheckoutQuery.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerPreCheckoutQuery.kt @@ -3,12 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abs import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId import kotlinx.serialization.KSerializer -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer interface AnswerPreCheckoutQuery : SimpleRequest { override fun method(): String = "answerPreCheckoutQuery" override val resultDeserializer: KSerializer - get() = BooleanSerializer + get() = Boolean.serializer() val preCheckoutQueryId: PreCheckoutQueryId val isOk: Boolean diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerShippingQuery.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerShippingQuery.kt index cf9b8f3e5b..49dcba9c5e 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerShippingQuery.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/payments/abstracts/AnswerShippingQuery.kt @@ -3,12 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abs import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer interface AnswerShippingQuery : SimpleRequest { override fun method(): String = "answerShippingQuery" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() val shippingQueryId: ShippingQueryIdentifier val isOk: Boolean diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/ExportChatInviteLink.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/ExportChatInviteLink.kt index a0532da8a9..67bcb3b17a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/ExportChatInviteLink.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/ExportChatInviteLink.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.StringSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class ExportChatInviteLink( @@ -16,7 +14,7 @@ data class ExportChatInviteLink( ): ChatRequest, SimpleRequest { override fun method(): String = "exportChatInviteLink" override val resultDeserializer: DeserializationStrategy - get() = StringSerializer + get() = String.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt index 956e2e4a43..5148f965ca 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class LeaveChat( @@ -16,7 +14,7 @@ data class LeaveChat( ): ChatRequest, SimpleRequest { override fun method(): String = "leaveChat" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt index cd257a99f8..fb0decdbad 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ExtendedChatSerializer -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* @@ -21,13 +19,3 @@ data class GetChat( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChat( - chatId: ChatIdentifier -) = execute(GetChat(chatId)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChat( - chat: Chat -) = getChat(chat.id) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt index 0e43498c1c..28853f1f74 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt @@ -1,17 +1,15 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMemberSerializerWithoutDeserialization -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer -private val chatMembersListSerializer = ArrayListSerializer( +private val chatMembersListSerializer = ListSerializer( AdministratorChatMemberSerializerWithoutDeserialization ) @@ -26,13 +24,3 @@ data class GetChatAdministrators( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatAdministrators( - chatId: ChatIdentifier -) = execute(GetChatAdministrators(chatId)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatAdministrators( - chat: PublicChat -) = getChatAdministrators(chat.id) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt index 2ba659c347..247f55b303 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.IntSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class GetChatMembersCount( @@ -16,17 +14,7 @@ data class GetChatMembersCount( ): ChatRequest, SimpleRequest { override fun method(): String = "getChatMembersCount" override val resultDeserializer: DeserializationStrategy - get() = IntSerializer + get() = Int.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatMembersCount( - chatId: ChatIdentifier -) = execute(GetChatMembersCount(chatId)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatMembersCount( - chat: PublicChat -) = getChatMembersCount(chat.id) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt index cb75a0da7a..7ec1b18bab 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* @Serializable @@ -21,27 +19,3 @@ data class GetChatMember( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatMember( - chatId: ChatIdentifier, - userId: UserId -) = execute(GetChatMember(chatId, userId)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatMember( - chat: PublicChat, - userId: UserId -) = getChatMember(chat.id, userId) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatMember( - chatId: ChatId, - user: User -) = getChatMember(chatId, user.id) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getChatMember( - chat: PublicChat, - user: User -) = getChatMember(chat.id, user.id) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/KickChatMember.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/KickChatMember.kt index 740a699cc7..5037ab339f 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/KickChatMember.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/KickChatMember.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class KickChatMember( @@ -19,7 +17,7 @@ data class KickChatMember( ) : ChatMemberRequest, UntilDate { override fun method(): String = "kickChatMember" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/PromoteChatMember.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/PromoteChatMember.kt index 1e8a9eeb91..1be36db1fd 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/PromoteChatMember.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/PromoteChatMember.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class PromoteChatMember( @@ -35,7 +33,7 @@ data class PromoteChatMember( ) : ChatMemberRequest, UntilDate { override fun method(): String = "promoteChatMember" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/RestrictChatMember.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/RestrictChatMember.kt index 2986af0c7c..8c6d255e76 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/RestrictChatMember.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/RestrictChatMember.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class RestrictChatMember( @@ -22,40 +20,7 @@ data class RestrictChatMember( ) : ChatMemberRequest, UntilDate { override fun method(): String = "restrictChatMember" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.restrictChatMember( - chatId: ChatIdentifier, - userId: UserId, - untilDate: TelegramDate? = null, - permissions: ChatPermissions = ChatPermissions() -) = execute(RestrictChatMember(chatId, userId, untilDate, permissions)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.restrictChatMember( - chat: PublicChat, - userId: UserId, - untilDate: TelegramDate? = null, - permissions: ChatPermissions = ChatPermissions() -) = restrictChatMember(chat.id, userId, untilDate, permissions) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.restrictChatMember( - chatId: ChatId, - user: User, - untilDate: TelegramDate? = null, - permissions: ChatPermissions = ChatPermissions() -) = restrictChatMember(chatId, user.id, untilDate, permissions) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.restrictChatMember( - chat: PublicChat, - user: User, - untilDate: TelegramDate? = null, - permissions: ChatPermissions = ChatPermissions() -) = restrictChatMember(chat.id, user.id, untilDate, permissions) - diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/SetChatAdministratorCustomTitle.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/SetChatAdministratorCustomTitle.kt index 91785b0299..f91dcfc41b 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/SetChatAdministratorCustomTitle.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/SetChatAdministratorCustomTitle.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer /** * Representation of https://core.telegram.org/bots/api#setchatadministratorcustomtitle @@ -23,7 +21,7 @@ data class SetChatAdministratorCustomTitle( ) : ChatMemberRequest { override fun method(): String = "setChatAdministratorCustomTitle" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = RestrictChatMember.serializer() @@ -33,31 +31,3 @@ data class SetChatAdministratorCustomTitle( } } } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatAdministratorCustomTitle( - chatId: ChatId, - userId: UserId, - customTitle: String -) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatAdministratorCustomTitle( - chat: PublicChat, - userId: UserId, - customTitle: String -) = setChatAdministratorCustomTitle(chat.id, userId, customTitle) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatAdministratorCustomTitle( - chatId: ChatId, - user: User, - customTitle: String -) = setChatAdministratorCustomTitle(chatId, user.id, customTitle) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatAdministratorCustomTitle( - chat: PublicChat, - user: User, - customTitle: String -) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle) \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/UnbanChatMember.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/UnbanChatMember.kt index 005efe98e6..3c82edcb31 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/UnbanChatMember.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/UnbanChatMember.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class UnbanChatMember( @@ -16,7 +14,7 @@ data class UnbanChatMember( ) : ChatMemberRequest { override fun method(): String = "unbanChatMember" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt index c88c03cfc7..e3370a1efd 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class DeleteChatPhoto( @@ -16,7 +14,7 @@ data class DeleteChatPhoto( ): ChatRequest, SimpleRequest { override fun method(): String = "deleteChatPhoto" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt index a1d32f2209..41af62b0c3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt @@ -1,13 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.* -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class PinChatMessage ( @@ -20,7 +17,7 @@ data class PinChatMessage ( ): ChatRequest, SimpleRequest, MessageAction, DisableNotification { override fun method(): String = "pinChatMessage" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt index f62656f2cc..011d4680e0 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class SetChatDescription ( @@ -23,19 +21,7 @@ data class SetChatDescription ( override fun method(): String = "setChatDescription" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatDescription( - chatId: ChatIdentifier, - description: String -) = execute(SetChatDescription(chatId, description)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatDescription( - chat: PublicChat, - description: String -) = setChatDescription(chat.id, description) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPermissions.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPermissions.kt index 6909f1426f..e0e075c75a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPermissions.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPermissions.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class SetChatPermissions ( @@ -18,19 +16,7 @@ data class SetChatPermissions ( ): ChatRequest, SimpleRequest { override fun method(): String = "setChatPermissions" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setDefaultChatMembersPermissions( - chatId: ChatIdentifier, - permissions: ChatPermissions -) = execute(SetChatPermissions(chatId, permissions)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setDefaultChatMembersPermissions( - chat: PublicChat, - permissions: ChatPermissions -) = setDefaultChatMembersPermissions(chat.id, permissions) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt index 7d4ef9b408..6af5b3cfbb 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt @@ -1,14 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import com.github.insanusmokrassar.TelegramBotAPI.utils.toJson import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer import kotlinx.serialization.json.JsonObject @Serializable @@ -19,19 +17,7 @@ data class SetChatPhoto ( ): ChatRequest, MultipartRequest { override fun method(): String = "setChatPhoto" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val mediaMap: Map = mapOf(photoField to photo) override val paramsJson: JsonObject = toJson(serializer()) } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatPhoto( - chatId: ChatIdentifier, - photo: MultipartFile -) = execute(SetChatPhoto(chatId, photo)) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.setChatPhoto( - chat: PublicChat, - photo: MultipartFile -) = setChatPhoto(chat.id, photo) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt index ba86c5954b..ac88f69f25 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class SetChatTitle ( @@ -23,7 +21,7 @@ data class SetChatTitle ( override fun method(): String = "setChatTitle" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt index 8fee87557c..8e9c2772c4 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class UnpinChatMessage( @@ -16,7 +14,7 @@ data class UnpinChatMessage( ): ChatRequest, SimpleRequest { override fun method(): String = "unpinChatMessage" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt index bd27af1f3e..e44237b1fa 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class DeleteChatStickerSet( @@ -16,7 +14,7 @@ data class DeleteChatStickerSet( ): ChatRequest, SimpleRequest { override fun method(): String = "deleteChatStickerSet" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/SetChatStickerSet.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/SetChatStickerSet.kt index 4529f7c83e..17f4b485a3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/SetChatStickerSet.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/SetChatStickerSet.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class SetChatStickerSet( @@ -17,7 +15,7 @@ data class SetChatStickerSet( ): ChatRequest, SimpleRequest { override fun method(): String = "setChatStickerSet" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt index 7bdc3ace54..dcdc143392 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt @@ -1,10 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt index 1317b175c2..26b974cb3c 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt index 66d0b8cc47..a0f1c3d9fe 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt index 4da75d7df7..dbe0667ab1 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt index 044482316f..702e233ea7 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt @@ -1,12 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent import kotlinx.serialization.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt index d8c982e8a1..15a51074af 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt index c2cf5fed0a..ae90e47c59 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt @@ -3,10 +3,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer interface EditInlineMessage : SimpleRequest { val inlineMessageId: InlineMessageIdentifier override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() } \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt index e818a68484..855366a788 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt @@ -1,14 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent import kotlinx.serialization.* @@ -35,33 +32,3 @@ data class EditChatMessageCaption( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageCaption( - chatId: ChatIdentifier, - messageId: MessageIdentifier, - text: String, - parseMode: ParseMode? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = execute( - EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageCaption( - chat: Chat, - messageId: MessageIdentifier, - text: String, - parseMode: ParseMode? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageCaption( - message: ContentMessage, - text: String, - parseMode: ParseMode? = null, - replyMarkup: InlineKeyboardMarkup? = null -): ContentMessage where T : CaptionedInput, T : MediaContent { - return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) -} diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt index 59688e9763..b918ae79fd 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode @@ -23,11 +22,3 @@ data class EditInlineMessageCaption( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageCaption( - inlineMessageId: InlineMessageIdentifier, - text: String, - parseMode: ParseMode? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup)) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt index ef7b97dede..af97409eda 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent @@ -40,28 +38,3 @@ data class EditChatMessageMedia( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageMedia( - chatId: ChatIdentifier, - messageId: MessageIdentifier, - media: InputMedia, - replyMarkup: InlineKeyboardMarkup? = null -) = execute( - EditChatMessageMedia(chatId, messageId, media, replyMarkup) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageMedia( - chat: Chat, - messageId: MessageIdentifier, - media: InputMedia, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageMedia(chat.id, messageId, media, replyMarkup) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageMedia( - message: ContentMessage, - media: InputMedia, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt index 5d90e71ecb..fed5b7c66c 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* @@ -28,10 +27,3 @@ data class EditInlineMessageMedia( override fun method(): String = editMessageMediaMethod } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageCaption( - inlineMessageId: InlineMessageIdentifier, - media: InputMedia, - replyMarkup: InlineKeyboardMarkup? = null -) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup)) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt index 416e75742b..1596f45cfc 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.TextContentMessageResultDeserializer import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent import kotlinx.serialization.* @@ -36,34 +34,3 @@ data class EditChatMessageText( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageText( - chatId: ChatIdentifier, - messageId: MessageIdentifier, - text: String, - parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = execute( - EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageText( - chat: Chat, - messageId: MessageIdentifier, - text: String, - parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.editMessageText( - message: ContentMessage, - text: String, - parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup) \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt index e749155472..9219cd0949 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod import com.github.insanusmokrassar.TelegramBotAPI.types.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt index f76a637066..d1cd6effd5 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt @@ -1,12 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage -import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent import kotlinx.serialization.* @Serializable diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt index f6077d4b96..7e35cbce06 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt @@ -1,7 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByChatId.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByChatId.kt index 487875e51e..7cb00e4dc8 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByChatId.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByChatId.kt @@ -1,12 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage -import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent import kotlinx.serialization.* @Serializable diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt index 36ae744186..23deee5967 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt @@ -1,7 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/GetGameHighScores.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/GetGameHighScores.kt index 0915454e86..a4017a85fa 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/GetGameHighScores.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/GetGameHighScores.kt @@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.UserId import com.github.insanusmokrassar.TelegramBotAPI.types.games.GameHighScore import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.KSerializer -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer interface GetGameHighScores : SimpleRequest> { val userId: UserId @@ -15,4 +15,4 @@ interface GetGameHighScores : SimpleRequest> { get() = GameHighScoresSerializer } -internal object GameHighScoresSerializer : KSerializer> by ArrayListSerializer(GameHighScore.serializer()) +internal object GameHighScoresSerializer : KSerializer> by ListSerializer(GameHighScore.serializer()) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/SetGameScore.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/SetGameScore.kt index b0498392f1..3b0d258af9 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/SetGameScore.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/abstracts/SetGameScore.kt @@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.UserId import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.serializer +import kotlinx.serialization.builtins.serializer interface SetGameScore : SimpleRequest { val userId: UserId diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt index 74c689a05c..54e5e00a1f 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt @@ -1,10 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.get -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.TelegramMediaFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.fileIdField import kotlinx.serialization.* @@ -19,15 +17,3 @@ data class GetFile( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getFileAdditionalInfo( - fileId: FileId -) = execute( - GetFile(fileId) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getFileAdditionalInfo( - file: TelegramMediaFile -) = getFileAdditionalInfo(file.fileId) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt index ccc410e957..41fc2f031a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt @@ -1,8 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.get -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest -import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker import com.github.insanusmokrassar.TelegramBotAPI.types.stickerSetNameField import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet import kotlinx.serialization.* @@ -18,17 +16,3 @@ data class GetStickerSet( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getStickerSet( - name: String -) = execute( - GetStickerSet(name) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getStickerSet( - sticker: Sticker -) = getStickerSet( - sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method") -) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt index 84b12ec02c..f9270a7571 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.get -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* @@ -29,21 +28,3 @@ data class GetUserProfilePhotos( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getUserProfilePhotos( - userId: UserId, - offset: Int? = null, - limit: Int? = null -) = execute( - GetUserProfilePhotos( - userId, offset, limit - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getUserProfilePhotos( - user: CommonUser, - offset: Int? = null, - limit: Int? = null -) = getUserProfilePhotos(user.id, offset, limit) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt index 65fc2f4d36..01be3ad029 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendChatMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.actions.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.actions.BotAction import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer /** * Send notification to user which will be shown for 5 seconds or while user have no messages from bot @@ -20,7 +18,7 @@ data class SendAction( ): SendChatMessageRequest { override fun method(): String = "sendChatAction" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt index 2829f03893..51dff056f3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.ContactContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt index 363dee4d01..2c4f72c1b6 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt @@ -1,22 +1,17 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent -import com.soywiz.klock.DateTime -import com.soywiz.klock.TimeSpan import kotlinx.serialization.* private val commonResultDeserializer: DeserializationStrategy> = TelegramBotAPIMessageDeserializationStrategyClass() -// TODO:: Add location tracker for tracking location @Serializable data class SendLocation( @SerialName(chatIdField) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt index d1cb8dd4f4..8d91a0eb40 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt index 0bb20b9c4d..18e3931cfe 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt @@ -1,10 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent @@ -75,59 +73,3 @@ fun Venue.toRequest( replyToMessageId, replyMarkup ) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVenue( - chatId: ChatIdentifier, - latitude: Double, - longitude: Double, - title: String, - address: String, - foursquareId: String? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendVenue( - chatId, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVenue( - chat: Chat, - latitude: Double, - longitude: Double, - title: String, - address: String, - foursquareId: String? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVenue( - chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVenue( - chatId: ChatIdentifier, - venue: Venue, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendVenue( - chatId, venue, disableNotification, replyToMessageId, replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVenue( - chat: Chat, - venue: Venue, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVenue( - chat.id, venue, disableNotification, replyToMessageId, replyMarkup -) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt index 099df2f01c..8b95236ad9 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt @@ -1,12 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt index 08140cec76..0de73f8fdc 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -8,8 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AnimationContent @@ -115,144 +112,3 @@ data class SendAnimationFiles internal constructor( animationField to animation, thumbField to thumb ) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendAnimation( - chatId: ChatIdentifier, - animation: FileId, - thumb: FileId? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendAnimationData( - chatId, - animation.fileId, - thumb ?.fileId, - text, - parseMode, - duration, - width, - height, - disableNotification, - replyToMessageId, - replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendAnimation( - chatId: ChatIdentifier, - animation: AnimationFile, - thumb: PhotoSize? = animation.thumb, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendAnimation( - chatId, animation.fileId, thumb ?.fileId, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendAnimation( - chatId: ChatIdentifier, - animation: MultipartFile, - thumb: FileId? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendAnimationData( - chatId, null, thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup - ), - SendAnimationFiles(animation) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendAnimation( - chatId: ChatIdentifier, - animation: MultipartFile, - thumb: MultipartFile? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendAnimationData( - chatId, null, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup - ), - SendAnimationFiles(animation, thumb) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendAnimation( - chatId: ChatIdentifier, - animation: FileId, - thumb: MultipartFile, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendAnimationData( - chatId, animation.fileId, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup - ), - SendAnimationFiles(null, thumb) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendAnimation( - chatId: ChatIdentifier, - animation: MultipartFile, - thumb: PhotoSize? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendAnimation( - chatId, animation, thumb ?.fileId , text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendAnimation( - chatId: ChatIdentifier, - animation: AnimationFile, - thumb: MultipartFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendAnimation( - chatId, animation.fileId, thumb, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup -) - diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt index 08bfc93bc1..5facb438f5 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt @@ -1,7 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -9,8 +8,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AudioContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt index 144ba864f5..44ff036ec2 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -8,8 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.DocumentContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt index 63bae97836..4f7054bb29 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt @@ -1,18 +1,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.json.jsonArray val membersCountInMediaGroup: IntRange = 2 .. 10 @@ -55,8 +53,8 @@ fun SendMediaGroup( } } -private val messagesListSerializer: ArrayListSerializer - = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass()) +private val messagesListSerializer: KSerializer> + = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass()) @Serializable data class SendMediaGroupData internal constructor( @@ -87,25 +85,3 @@ data class SendMediaGroupData internal constructor( data class SendMediaGroupFiles internal constructor( val files: List ) : Files by (files.map { it.fileId to it }.toMap()) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendMediaGroup( - chatId: ChatIdentifier, - media: List, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null -) = execute( - SendMediaGroup( - chatId, media, disableNotification, replyToMessageId - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendMediaGroup( - chat: Chat, - media: List, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null -) = sendMediaGroup( - chat.id, media, disableNotification, replyToMessageId -) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt index 289985641c..b9b005d8b4 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -8,8 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.files.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent @@ -85,95 +82,3 @@ data class SendPhotoFiles internal constructor( ) : Files by mapOf( photoField to photo ) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendPhoto( - chatId: ChatIdentifier, - fileId: FileId, - caption: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendPhotoData( - chatId, - fileId.fileId, - caption, - parseMode, - disableNotification, - replyToMessageId, - replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendPhoto( - chatId: ChatIdentifier, - file: PhotoSize, - caption: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendPhoto( - chatId, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendPhoto( - chatId: ChatIdentifier, - photo: Photo, - caption: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendPhoto( - chatId, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendPhoto( - chat: Chat, - fileId: FileId, - caption: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendPhoto( - chat.id, - fileId, - caption, - parseMode, - disableNotification, - replyToMessageId, - replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendPhoto( - chat: Chat, - file: PhotoSize, - caption: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendPhoto( - chat.id, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendPhoto( - chat: Chat, - photo: Photo, - caption: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendPhoto( - chat.id, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup -) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendSticker.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendSticker.kt index 3fbfd21974..e1f23403d6 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendSticker.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendSticker.kt @@ -1,13 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.StickerContent @@ -65,68 +62,3 @@ data class SendStickerByFile internal constructor( override val mediaMap: Map = mapOf(stickerField to sticker) override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer()) } - - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendSticker( - chatId: ChatIdentifier, - sticker: FileId, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendStickerByFileId(chatId, sticker, disableNotification, replyToMessageId, replyMarkup) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendSticker( - chatId: ChatIdentifier, - sticker: MultipartFile, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendStickerByFile( - SendStickerByFileId(chatId, null, disableNotification, replyToMessageId, replyMarkup), - sticker - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendSticker( - chat: Chat, - sticker: FileId, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendSticker( - chat: Chat, - sticker: MultipartFile, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendSticker( - chatId: ChatIdentifier, - sticker: Sticker, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendSticker( - chatId, sticker.fileId, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendSticker( - chat: Chat, - sticker: Sticker, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat.id, sticker.fileId, disableNotification, replyToMessageId, replyMarkup) - diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt index 0ff86d9ab0..97781a1f7a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -8,8 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize -import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoContent @@ -119,148 +116,3 @@ data class SendVideoFiles internal constructor( videoField to video, thumbField to thumb ) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVideo( - chatId: ChatIdentifier, - video: FileId, - thumb: FileId? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendVideoData( - chatId, - video.fileId, - thumb ?.fileId, - text, - parseMode, - duration, - width, - height, - null, - disableNotification, - replyToMessageId, - replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVideo( - chatId: ChatIdentifier, - video: VideoFile, - thumb: PhotoSize? = video.thumb, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVideo( - chatId, video.fileId, thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVideo( - chatId: ChatIdentifier, - video: MultipartFile, - thumb: FileId? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - supportStreaming: Boolean? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendVideoData( - chatId, null, thumb ?.fileId, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup - ), - SendVideoFiles(video) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVideo( - chatId: ChatIdentifier, - video: MultipartFile, - thumb: MultipartFile? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - supportStreaming: Boolean? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendVideoData( - chatId, null, null, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup - ), - SendVideoFiles(video, thumb) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVideo( - chatId: ChatIdentifier, - video: FileId, - thumb: MultipartFile, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendVideoData( - chatId, video.fileId, null, text, parseMode, duration, width, height, null, disableNotification, replyToMessageId, replyMarkup - ), - SendVideoFiles(null, thumb) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVideo( - chatId: ChatIdentifier, - video: MultipartFile, - thumb: PhotoSize? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - supportStreaming: Boolean? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVideo( - chatId, video, thumb ?.fileId , text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVideo( - chatId: ChatIdentifier, - video: VideoFile, - thumb: MultipartFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVideo( - chatId, video.fileId, thumb, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup -) - diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt index ca57bfbfc8..e4e3d11bfd 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -8,8 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize -import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoNoteContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt index 46b6e3c499..a341372e5c 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* @@ -8,8 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VoiceContent @@ -106,132 +103,3 @@ data class SendVoiceFiles internal constructor( voiceField to voice, thumbField to thumb ) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVoice( - chatId: ChatIdentifier, - voice: FileId, - thumb: FileId? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendVoiceData( - chatId, - voice.fileId, - thumb ?.fileId, - text, - parseMode, - duration, - disableNotification, - replyToMessageId, - replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVoice( - chatId: ChatIdentifier, - voice: AudioFile, - thumb: PhotoSize? = voice.thumb, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVoice( - chatId, voice.fileId, thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVoice( - chatId: ChatIdentifier, - voice: MultipartFile, - thumb: FileId? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendVoiceData( - chatId, null, thumb ?.fileId, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup - ), - SendVoiceFiles(voice) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVoice( - chatId: ChatIdentifier, - voice: MultipartFile, - thumb: MultipartFile? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendVoiceData( - chatId, null, null, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup - ), - SendVoiceFiles(voice, thumb) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVoice( - chatId: ChatIdentifier, - voice: FileId, - thumb: MultipartFile, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - MultipartRequestImpl( - SendVoiceData( - chatId, voice.fileId, null, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup - ), - SendVoiceFiles(null, thumb) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVoice( - chatId: ChatIdentifier, - voice: MultipartFile, - thumb: PhotoSize? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVoice( - chatId, voice, thumb ?.fileId , text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendVoice( - chatId: ChatIdentifier, - voice: AudioFile, - thumb: MultipartFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendVoice( - chatId, voice.fileId, thumb, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup -) - diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt index 74579a267c..7179f0fd13 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt @@ -1,7 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.* -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup @@ -106,51 +105,3 @@ data class SendInvoice( photoHeight = null } } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendInvoice( - chatId: ChatId, - title: String, - description: String, - payload: String, - providerToken: String, - startParameter: StartParameter, - currency: Currency, - prices: List, - providerData: String? = null, - requireName: Boolean = false, - requirePhoneNumber: Boolean = false, - requireEmail: Boolean = false, - requireShippingAddress: Boolean = false, - shouldSendPhoneNumberToProvider: Boolean = false, - shouldSendEmailToProvider: Boolean = false, - priceDependOnShipAddress: Boolean = false, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = execute( - SendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendInvoice( - user: CommonUser, - title: String, - description: String, - payload: String, - providerToken: String, - startParameter: StartParameter, - currency: Currency, - prices: List, - providerData: String? = null, - requireName: Boolean = false, - requirePhoneNumber: Boolean = false, - requireEmail: Boolean = false, - requireShippingAddress: Boolean = false, - shouldSendPhoneNumberToProvider: Boolean = false, - shouldSendEmailToProvider: Boolean = false, - priceDependOnShipAddress: Boolean = false, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(user.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt index 1298576c65..9db62be4c1 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.PollContent @@ -185,136 +183,3 @@ data class SendQuizPoll( } } } - - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendRegularPoll( - chatId: ChatIdentifier, - question: String, - options: List, - isAnonymous: Boolean = true, - isClosed: Boolean = false, - allowMultipleAnswers: Boolean = false, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendRegularPoll( - chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup - ) -) -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendRegularPoll( - chatId: ChatIdentifier, - poll: RegularPoll, - isClosed: Boolean = false, - question: String = poll.question, - options: List = poll.options.map { it.text }, - isAnonymous: Boolean = poll.isAnonymous, - allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendRegularPoll( - chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendRegularPoll( - chat: Chat, - question: String, - options: List, - isAnonymous: Boolean = true, - isClosed: Boolean = false, - allowMultipleAnswers: Boolean = false, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendRegularPoll( - chat: Chat, - poll: RegularPoll, - isClosed: Boolean = false, - question: String = poll.question, - options: List = poll.options.map { it.text }, - isAnonymous: Boolean = poll.isAnonymous, - allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup -) - - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendQuizPoll( - chatId: ChatIdentifier, - question: String, - options: List, - correctOptionId: Int, - isAnonymous: Boolean = true, - isClosed: Boolean = false, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendQuizPoll( - chat: Chat, - question: String, - options: List, - correctOptionId: Int, - isAnonymous: Boolean = true, - isClosed: Boolean = false, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendQuizPoll( - chatId: ChatIdentifier, - isClosed: Boolean = false, - quizPoll: QuizPoll, - question: String = quizPoll.question, - options: List = quizPoll.options.map { it.text }, - correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), - isAnonymous: Boolean = quizPoll.isAnonymous, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.sendQuizPoll( - chat: Chat, - isClosed: Boolean = false, - quizPoll: QuizPoll, - question: String = quizPoll.question, - options: List = quizPoll.options.map { it.text }, - correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), - isAnonymous: Boolean = quizPoll.isAnonymous, - disableNotification: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup -) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt index 4069488cc5..113ad5966e 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/AddStickerToSet.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition -import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet import kotlinx.serialization.* fun AddStickerToSet( @@ -50,98 +48,3 @@ data class AddStickerToSet internal constructor( override fun method(): String = "addStickerToSet" } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = execute( - AddStickerToSet( - userId, stickerSetName, emojis, sticker, maskPosition - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - userId: UserId, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = execute( - CommonMultipartFileRequest( - AddStickerToSet( - userId, stickerSetName, emojis, null, maskPosition - ), - mapOf(pngStickerField to sticker) - ) -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - user: CommonUser, - stickerSetName: String, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addStickerToSet( - user.id, stickerSetName, sticker, emojis, maskPosition -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - userId: UserId, - stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - userId: UserId, - stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addStickerToSet( - userId, stickerSet.name, sticker, emojis, maskPosition -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - user: CommonUser, - stickerSet: StickerSet, - sticker: FileId, - emojis: String, - maskPosition: MaskPosition? = null -) = addStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition -) - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.addStickerToSet( - user: CommonUser, - stickerSet: StickerSet, - sticker: MultipartFile, - emojis: String, - maskPosition: MaskPosition? = null -) = addStickerToSet( - user.id, stickerSet.name, sticker, emojis, maskPosition -) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/CreateNewStickerSet.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/CreateNewStickerSet.kt index 2cd93d0f94..b02b967fc3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/CreateNewStickerSet.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/CreateNewStickerSet.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt index 46e52b243b..9ff0d9206f 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt @@ -1,12 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest -import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class DeleteStickerFromSet( @@ -15,7 +13,7 @@ data class DeleteStickerFromSet( ) : SimpleRequest { override fun method(): String = "deleteStickerFromSet" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt index fb71206675..39f84b61a3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt @@ -1,13 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest -import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker import com.github.insanusmokrassar.TelegramBotAPI.types.positionField import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable data class SetStickerPositionInSet( @@ -24,7 +22,7 @@ data class SetStickerPositionInSet( override fun method(): String = "setStickerPositionInSet" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/UploadStickerFile.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/UploadStickerFile.kt index 0fa1d1307c..967f3682c6 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/UploadStickerFile.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/UploadStickerFile.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/abstracts/StickerSetAction.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/abstracts/StickerSetAction.kt index d46e316e71..7563fb0752 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/abstracts/StickerSetAction.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/abstracts/StickerSetAction.kt @@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque import com.github.insanusmokrassar.TelegramBotAPI.types.UserId import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition import kotlinx.serialization.KSerializer -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer interface StickerSetAction : SimpleRequest { val userId: UserId @@ -13,5 +13,5 @@ interface StickerSetAction : SimpleRequest { val maskPosition: MaskPosition? override val resultDeserializer: KSerializer - get() = BooleanSerializer + get() = Boolean.serializer() } \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/DeleteWebhook.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/DeleteWebhook.kt index b061cfb830..27a1df4256 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/DeleteWebhook.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/DeleteWebhook.kt @@ -2,14 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer @Serializable class DeleteWebhook : SimpleRequest { override fun method(): String = "deleteWebhook" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/GetWebhookInfo.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/GetWebhookInfo.kt index 1d3332f4a6..607a5aa7fd 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/GetWebhookInfo.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/GetWebhookInfo.kt @@ -1,6 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo import kotlinx.serialization.* @@ -14,6 +13,3 @@ class GetWebhookInfo : SimpleRequest { override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Deprecated due to extracting into separated library") -suspend fun RequestsExecutor.getWebhookInfo() = execute(GetWebhookInfo()) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt index 305611f57a..43c53b89aa 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/webhook/SetWebhook.kt @@ -1,12 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer +import kotlinx.serialization.builtins.serializer fun SetWebhook( url: String, @@ -53,7 +52,7 @@ data class SetWebhook internal constructor( ) : DataRequest { override fun method(): String = "setWebhook" override val resultDeserializer: DeserializationStrategy - get() = BooleanSerializer + get() = Boolean.serializer() override val requestSerializer: SerializationStrategy<*> get() = serializer() diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt index cc6d97f46e..603eb5e838 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types import kotlinx.serialization.* +import kotlinx.serialization.json.JsonPrimitiveSerializer @Serializable(ChatIdentifierSerializer::class) sealed class ChatIdentifier @@ -39,20 +40,22 @@ fun String.toUsername(): Username = Username(this) @Serializer(ChatIdentifier::class) internal object ChatIdentifierSerializer : KSerializer { override fun deserialize(decoder: Decoder): ChatIdentifier { - val id = decoder.decodeString() - return id.toLongOrNull() ?.let { + val id = JsonPrimitiveSerializer.deserialize(decoder) + return id.longOrNull ?.let { ChatId(it) - } ?: if (!id.startsWith("@")) { - Username("@$id") - } else { - Username(id) + } ?: id.content.let { + if (!it.startsWith("@")) { + Username("@$it") + } else { + Username(it) + } } } - override fun serialize(encoder: Encoder, obj: ChatIdentifier) { - when (obj) { - is ChatId -> encoder.encodeLong(obj.chatId) - is Username -> encoder.encodeString(obj.username) + override fun serialize(encoder: Encoder, value: ChatIdentifier) { + when (value) { + is ChatId -> encoder.encodeLong(value.chatId) + is Username -> encoder.encodeString(value.username) } } } \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/abstracts/ChatMember.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/abstracts/ChatMember.kt index 4137309d63..93c60cbf9b 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/abstracts/ChatMember.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/abstracts/ChatMember.kt @@ -3,23 +3,22 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.User import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor interface ChatMember { val user: User } internal object AdministratorChatMemberSerializerWithoutDeserialization : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization") + override val descriptor: SerialDescriptor = ChatMemberDeserializationStrategy.descriptor override fun deserialize(decoder: Decoder): AdministratorChatMember = ChatMemberDeserializationStrategy.deserialize(decoder) as AdministratorChatMember - override fun serialize(encoder: Encoder, obj: AdministratorChatMember) = throw UnsupportedOperationException() + override fun serialize(encoder: Encoder, value: AdministratorChatMember) = throw UnsupportedOperationException() } internal object ChatMemberDeserializationStrategy : DeserializationStrategy { - override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberDeserializationStrategy") + override val descriptor: SerialDescriptor = RawChatMember.serializer().descriptor override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember - override fun patch(decoder: Decoder, old: ChatMember): ChatMember = throw UpdateNotSupportedException(descriptor.name) + override fun patch(decoder: Decoder, old: ChatMember): ChatMember = throw UpdateNotSupportedException("ChatMember") } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt index e114e76a84..91a03bb442 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/serializers/InlineQueryResultSerializer.kt @@ -3,33 +3,32 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQue import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor @Serializer(InlineQueryResult::class) internal object InlineQueryResultSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName(InlineQueryResult::class.toString()) - override fun serialize(encoder: Encoder, obj: InlineQueryResult) { - when(obj) { - is InlineQueryResultArticle -> InlineQueryResultArticle.serializer().serialize(encoder, obj) - is InlineQueryResultAudioCachedImpl -> InlineQueryResultAudioCachedImpl.serializer().serialize(encoder, obj) - is InlineQueryResultAudioImpl -> InlineQueryResultAudioImpl.serializer().serialize(encoder, obj) - is InlineQueryResultContact -> InlineQueryResultContact.serializer().serialize(encoder, obj) - is InlineQueryResultDocumentCachedImpl -> InlineQueryResultDocumentCachedImpl.serializer().serialize(encoder, obj) - is InlineQueryResultDocumentImpl -> InlineQueryResultDocumentImpl.serializer().serialize(encoder, obj) - is InlineQueryResultGame -> InlineQueryResultGame.serializer().serialize(encoder, obj) - is InlineQueryResultGifCachedImpl -> InlineQueryResultGifCachedImpl.serializer().serialize(encoder, obj) - is InlineQueryResultGifImpl -> InlineQueryResultGifImpl.serializer().serialize(encoder, obj) - is InlineQueryResultLocation -> InlineQueryResultLocation.serializer().serialize(encoder, obj) - is InlineQueryResultMpeg4GifCachedImpl -> InlineQueryResultMpeg4GifCachedImpl.serializer().serialize(encoder, obj) - is InlineQueryResultMpeg4GifImpl -> InlineQueryResultMpeg4GifImpl.serializer().serialize(encoder, obj) - is InlineQueryResultPhotoCachedImpl -> InlineQueryResultPhotoCachedImpl.serializer().serialize(encoder, obj) - is InlineQueryResultPhotoImpl -> InlineQueryResultPhotoImpl.serializer().serialize(encoder, obj) - is InlineQueryResultStickerCached -> InlineQueryResultStickerCached.serializer().serialize(encoder, obj) - is InlineQueryResultVenue -> InlineQueryResultVenue.serializer().serialize(encoder, obj) - is InlineQueryResultVideoCachedImpl -> InlineQueryResultVideoCachedImpl.serializer().serialize(encoder, obj) - is InlineQueryResultVideoImpl -> InlineQueryResultVideoImpl.serializer().serialize(encoder, obj) - is InlineQueryResultVoiceCachedImpl -> InlineQueryResultVoiceCachedImpl.serializer().serialize(encoder, obj) - is InlineQueryResultVoiceImpl -> InlineQueryResultVoiceImpl.serializer().serialize(encoder, obj) + override val descriptor: SerialDescriptor = SerialDescriptor(InlineQueryResult::class.toString(), PolymorphicKind.OPEN) + override fun serialize(encoder: Encoder, value: InlineQueryResult) { + when(value) { + is InlineQueryResultArticle -> InlineQueryResultArticle.serializer().serialize(encoder, value) + is InlineQueryResultAudioCachedImpl -> InlineQueryResultAudioCachedImpl.serializer().serialize(encoder, value) + is InlineQueryResultAudioImpl -> InlineQueryResultAudioImpl.serializer().serialize(encoder, value) + is InlineQueryResultContact -> InlineQueryResultContact.serializer().serialize(encoder, value) + is InlineQueryResultDocumentCachedImpl -> InlineQueryResultDocumentCachedImpl.serializer().serialize(encoder, value) + is InlineQueryResultDocumentImpl -> InlineQueryResultDocumentImpl.serializer().serialize(encoder, value) + is InlineQueryResultGame -> InlineQueryResultGame.serializer().serialize(encoder, value) + is InlineQueryResultGifCachedImpl -> InlineQueryResultGifCachedImpl.serializer().serialize(encoder, value) + is InlineQueryResultGifImpl -> InlineQueryResultGifImpl.serializer().serialize(encoder, value) + is InlineQueryResultLocation -> InlineQueryResultLocation.serializer().serialize(encoder, value) + is InlineQueryResultMpeg4GifCachedImpl -> InlineQueryResultMpeg4GifCachedImpl.serializer().serialize(encoder, value) + is InlineQueryResultMpeg4GifImpl -> InlineQueryResultMpeg4GifImpl.serializer().serialize(encoder, value) + is InlineQueryResultPhotoCachedImpl -> InlineQueryResultPhotoCachedImpl.serializer().serialize(encoder, value) + is InlineQueryResultPhotoImpl -> InlineQueryResultPhotoImpl.serializer().serialize(encoder, value) + is InlineQueryResultStickerCached -> InlineQueryResultStickerCached.serializer().serialize(encoder, value) + is InlineQueryResultVenue -> InlineQueryResultVenue.serializer().serialize(encoder, value) + is InlineQueryResultVideoCachedImpl -> InlineQueryResultVideoCachedImpl.serializer().serialize(encoder, value) + is InlineQueryResultVideoImpl -> InlineQueryResultVideoImpl.serializer().serialize(encoder, value) + is InlineQueryResultVoiceCachedImpl -> InlineQueryResultVoiceCachedImpl.serializer().serialize(encoder, value) + is InlineQueryResultVoiceImpl -> InlineQueryResultVoiceImpl.serializer().serialize(encoder, value) } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContentSerializer.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContentSerializer.kt index 4eca591bbe..eefeae7248 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContentSerializer.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InputMessageContentSerializer.kt @@ -3,17 +3,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InputMessageContent.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor @Serializer(InputMessageContent::class) internal object InputMessageContentSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMessageContent::class.toString()) - override fun serialize(encoder: Encoder, obj: InputMessageContent) { - when (obj) { - is InputContactMessageContent -> InputContactMessageContent.serializer().serialize(encoder, obj) - is InputLocationMessageContent -> InputLocationMessageContent.serializer().serialize(encoder, obj) - is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, obj) - is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, obj) + override val descriptor: SerialDescriptor = SerialDescriptor(InputMessageContent::class.toString(), PolymorphicKind.OPEN) + override fun serialize(encoder: Encoder, value: InputMessageContent) { + when (value) { + is InputContactMessageContent -> InputContactMessageContent.serializer().serialize(encoder, value) + is InputLocationMessageContent -> InputLocationMessageContent.serializer().serialize(encoder, value) + is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, value) + is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, value) else -> throw IllegalArgumentException("Unknown for serializing InputContactMessageContent") } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt index 2e5ea13d13..e98e8b38f7 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt @@ -25,7 +25,7 @@ data class InputMediaPhoto( } @Transient - override val arguments: Map = Mapper.mapNullable(serializer(), this) + override val arguments: Map = Properties.storeNullable(serializer(), this) } fun PhotoSize.toInputMediaPhoto( diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaSerializer.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaSerializer.kt index 72b2f98050..9da0db77fe 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaSerializer.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaSerializer.kt @@ -1,19 +1,18 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor @Serializer(InputMedia::class) internal object InputMediaSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMedia::class.toString()) - override fun serialize(encoder: Encoder, obj: InputMedia) { - when (obj) { - is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, obj) - is InputMediaAudio -> InputMediaAudio.serializer().serialize(encoder, obj) - is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, obj) - is InputMediaAnimation -> InputMediaAnimation.serializer().serialize(encoder, obj) - is InputMediaDocument -> InputMediaDocument.serializer().serialize(encoder, obj) - else -> throw IllegalArgumentException("Can't perform and serialize $obj") + override val descriptor: SerialDescriptor = SerialDescriptor(InputMedia::class.toString(), PolymorphicKind.OPEN) + override fun serialize(encoder: Encoder, value: InputMedia) { + when (value) { + is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, value) + is InputMediaAudio -> InputMediaAudio.serializer().serialize(encoder, value) + is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, value) + is InputMediaAnimation -> InputMediaAnimation.serializer().serialize(encoder, value) + is InputMediaDocument -> InputMediaDocument.serializer().serialize(encoder, value) + else -> throw IllegalArgumentException("Can't perform and serialize $value") } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt index faf5a15f3c..1c32f30adb 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt @@ -28,5 +28,5 @@ data class InputMediaVideo( } @Transient - override val arguments: Map = Mapper.mapNullable(serializer(), this) + override val arguments: Map = Properties.storeNullable(serializer(), this) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt index 235b67e871..2f57259689 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/MediaGroupMemberInputMediaSerializer.kt @@ -1,15 +1,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor @Serializer(MediaGroupMemberInputMedia::class) internal object MediaGroupMemberInputMediaSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName(MediaGroupMemberInputMedia::class.toString()) - override fun serialize(encoder: Encoder, obj: MediaGroupMemberInputMedia) { - when (obj) { - is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, obj) - is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, obj) + override val descriptor: SerialDescriptor = SerialDescriptor(MediaGroupMemberInputMedia::class.toString(), PolymorphicKind.OPEN) + override fun serialize(encoder: Encoder, value: MediaGroupMemberInputMedia) { + when (value) { + is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, value) + is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, value) } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt index e3558593d7..9e53d9b5d7 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt @@ -43,7 +43,7 @@ internal object ParseModeSerializerObject : KSerializer { } } - override fun serialize(encoder: Encoder, obj: ParseMode) { - encoder.encodeString(obj.parseModeName) + override fun serialize(encoder: Encoder, value: ParseMode) { + encoder.encodeString(value.parseModeName) } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDate.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDate.kt index 62e19cbbf0..f4ac135f99 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDate.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDate.kt @@ -24,9 +24,9 @@ fun DateTime.toTelegramDate(): TelegramDate = TelegramDate(this) @Serializer(TelegramDate::class) internal object TelegramDateSerializer : KSerializer { - override fun serialize(encoder: Encoder, obj: TelegramDate) { + override fun serialize(encoder: Encoder, value: TelegramDate) { encoder.encodeLong( - obj.date + value.date ) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt index d23a1ce1d0..2410f6fad0 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import kotlinx.serialization.* -import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObjectSerializer @Serializable(UserSerializer::class) @@ -22,17 +22,19 @@ data class CommonUser( ) : User() @Serializable(UserSerializer::class) -sealed class Bot : User() +sealed class Bot : User() { + abstract override val username: Username +} @Serializable data class CommonBot( override val id: ChatId, + @SerialName(usernameField) + override val username: Username, @SerialName(firstNameField) override val firstName: String, @SerialName(lastNameField) - override val lastName: String = "", - @SerialName(usernameField) - override val username: Username? = null + override val lastName: String = "" ) : Bot() { @SerialName(isBotField) private val isBot = true @@ -41,12 +43,12 @@ data class CommonBot( @Serializable data class ExtendedBot( override val id: ChatId, + @SerialName(usernameField) + override val username: Username, @SerialName(firstNameField) override val firstName: String, @SerialName(lastNameField) override val lastName: String = "", - @SerialName(usernameField) - override val username: Username? = null, @SerialName(canJoinGroupsField) val canJoinGroups: Boolean = false, @SerialName(canReadAllGroupMessagesField) @@ -65,7 +67,7 @@ internal object UserSerializer : KSerializer { val asJson = JsonObjectSerializer.deserialize(decoder) return when { - asJson.getPrimitiveOrNull(isBotField) ?.booleanOrNull != true -> Json.nonstrict.fromJson( + asJson.getPrimitiveOrNull(isBotField) ?.booleanOrNull != true -> nonstrictJsonFormat.fromJson( CommonUser.serializer(), asJson ) @@ -74,12 +76,12 @@ internal object UserSerializer : KSerializer { ?: asJson.get(canReadAllGroupMessagesField) ?: asJson.get(supportInlineQueriesField)) != null ) { - Json.nonstrict.fromJson( + nonstrictJsonFormat.fromJson( ExtendedBot.serializer(), asJson ) } else { - Json.nonstrict.fromJson( + nonstrictJsonFormat.fromJson( CommonBot.serializer(), asJson ) @@ -88,11 +90,11 @@ internal object UserSerializer : KSerializer { } } - override fun serialize(encoder: Encoder, obj: User) { - when (obj) { - is CommonUser -> CommonUser.serializer().serialize(encoder, obj) - is CommonBot -> CommonBot.serializer().serialize(encoder, obj) - is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, obj) + override fun serialize(encoder: Encoder, value: User) { + when (value) { + is CommonUser -> CommonUser.serializer().serialize(encoder, value) + is CommonBot -> CommonBot.serializer().serialize(encoder, value) + is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, value) } } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/UserProfilePhotos.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/UserProfilePhotos.kt index 133610427b..21cdc9d9d5 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/UserProfilePhotos.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/UserProfilePhotos.kt @@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSerializer import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer @Serializable data class UserProfilePhotos ( @@ -13,6 +13,6 @@ data class UserProfilePhotos ( val photos: List ) -internal object UserProfilePhotosPhotosSerializer : KSerializer> by ArrayListSerializer( +internal object UserProfilePhotosPhotosSerializer : KSerializer> by ListSerializer( PhotoSerializer ) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/actions/BotAction.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/actions/BotAction.kt index 5f0915a211..f8bd33f045 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/actions/BotAction.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/actions/BotAction.kt @@ -9,8 +9,8 @@ sealed class BotAction { @Serializer(BotAction::class) internal object BotActionSerializer: KSerializer { - override fun serialize(encoder: Encoder, obj: BotAction) { - encoder.encodeString(obj.actionName) + override fun serialize(encoder: Encoder, value: BotAction) { + encoder.encodeString(value.actionName) } override fun deserialize(decoder: Decoder): BotAction { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt index d477c11b18..0c2da03af1 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt @@ -9,7 +9,6 @@ sealed class InlineKeyboardButton { abstract val text: String } -//TODO:: add check that this button first in a row (it MUST be first in a row) @Serializable data class PayInlineKeyboardButton( override val text: String, diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt index 317cc57901..463b6608cb 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt @@ -1,12 +1,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor -import kotlinx.serialization.json.* +import kotlinx.serialization.json.JsonElementSerializer +import kotlinx.serialization.json.JsonObject internal object InlineKeyboardButtonSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName("com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton") + override val descriptor: SerialDescriptor = SerialDescriptor( + "com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton", + PolymorphicKind.SEALED + ) private fun resolveSerializer(json: JsonObject): KSerializer { return when { @@ -23,17 +27,17 @@ internal object InlineKeyboardButtonSerializer : KSerializer CallbackDataInlineKeyboardButton.serializer().serialize(encoder, obj) - is LoginURLInlineKeyboardButton -> LoginURLInlineKeyboardButton.serializer().serialize(encoder, obj) - is PayInlineKeyboardButton -> PayInlineKeyboardButton.serializer().serialize(encoder, obj) - is SwitchInlineQueryInlineKeyboardButton -> SwitchInlineQueryInlineKeyboardButton.serializer().serialize(encoder, obj) - is SwitchInlineQueryCurrentChatInlineKeyboardButton -> SwitchInlineQueryCurrentChatInlineKeyboardButton.serializer().serialize(encoder, obj) - is URLInlineKeyboardButton -> URLInlineKeyboardButton.serializer().serialize(encoder, obj) + override fun serialize(encoder: Encoder, value: InlineKeyboardButton) { + when (value) { + is CallbackDataInlineKeyboardButton -> CallbackDataInlineKeyboardButton.serializer().serialize(encoder, value) + is LoginURLInlineKeyboardButton -> LoginURLInlineKeyboardButton.serializer().serialize(encoder, value) + is PayInlineKeyboardButton -> PayInlineKeyboardButton.serializer().serialize(encoder, value) + is SwitchInlineQueryInlineKeyboardButton -> SwitchInlineQueryInlineKeyboardButton.serializer().serialize(encoder, value) + is SwitchInlineQueryCurrentChatInlineKeyboardButton -> SwitchInlineQueryCurrentChatInlineKeyboardButton.serializer().serialize(encoder, value) + is URLInlineKeyboardButton -> URLInlineKeyboardButton.serializer().serialize(encoder, value) } } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardMarkup.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardMarkup.kt index 64d3490c59..7529c49112 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardMarkup.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardMarkup.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.buttons import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton import com.github.insanusmokrassar.TelegramBotAPI.types.inlineKeyboardField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -9,4 +10,19 @@ import kotlinx.serialization.Serializable data class InlineKeyboardMarkup( @SerialName(inlineKeyboardField) val keyboard: Matrix -) : KeyboardMarkup +) : KeyboardMarkup { + init { + val isTherePayButton = keyboard.any { it -> + it.any { + it is PayInlineKeyboardButton + } + } + if (isTherePayButton) { + // first button is not PayInlineKeyboardButton + val firstIsPaymentButton = keyboard.first().firstOrNull() is PayInlineKeyboardButton + if (!firstIsPaymentButton) { + error("In case if PayInlineKeyboardButton included in keyboard - it must ") + } + } + } +} diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButton.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButton.kt index de8eee0c55..f913c0d07a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButton.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButton.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.buttons import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.json.* @@ -58,7 +59,7 @@ internal object KeyboardButtonSerializer : KSerializer { ) asJson is JsonObject && asJson.getObjectOrNull(requestPollField) != null -> RequestPollKeyboardButton( asJson.getPrimitive(textField).content, - Json.nonstrict.fromJson( + nonstrictJsonFormat.fromJson( KeyboardButtonPollType.serializer(), asJson.getObject(requestPollField) ) @@ -74,13 +75,13 @@ internal object KeyboardButtonSerializer : KSerializer { } } - override fun serialize(encoder: Encoder, obj: KeyboardButton) { - when (obj) { - is RequestContactKeyboardButton -> RequestContactKeyboardButton.serializer().serialize(encoder, obj) - is RequestLocationKeyboardButton -> RequestLocationKeyboardButton.serializer().serialize(encoder, obj) - is RequestPollKeyboardButton -> RequestPollKeyboardButton.serializer().serialize(encoder, obj) - is SimpleKeyboardButton -> encoder.encodeString(obj.text) - is UnknownKeyboardButton -> JsonElementSerializer.serialize(encoder, Json.nonstrict.parseJson(obj.raw)) + override fun serialize(encoder: Encoder, value: KeyboardButton) { + when (value) { + is RequestContactKeyboardButton -> RequestContactKeyboardButton.serializer().serialize(encoder, value) + is RequestLocationKeyboardButton -> RequestLocationKeyboardButton.serializer().serialize(encoder, value) + is RequestPollKeyboardButton -> RequestPollKeyboardButton.serializer().serialize(encoder, value) + is SimpleKeyboardButton -> encoder.encodeString(value.text) + is UnknownKeyboardButton -> JsonElementSerializer.serialize(encoder, nonstrictJsonFormat.parseJson(value.raw)) } } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButtonPollType.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButtonPollType.kt index b4140699f3..aef28823a3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButtonPollType.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/KeyboardButtonPollType.kt @@ -42,12 +42,12 @@ internal object KeyboardButtonPollTypeSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName(KeyboardMarkup::class.toString()) - override fun serialize(encoder: Encoder, obj: KeyboardMarkup) { - when(obj) { - is ForceReply -> ForceReply.serializer().serialize(encoder, obj) - is InlineKeyboardMarkup -> InlineKeyboardMarkup.serializer().serialize(encoder, obj) - is ReplyKeyboardMarkup -> ReplyKeyboardMarkup.serializer().serialize(encoder, obj) - is ReplyKeyboardRemove -> ReplyKeyboardRemove.serializer().serialize(encoder, obj) + override val descriptor: SerialDescriptor = SerialDescriptor( + KeyboardMarkup::class.toString(), + PolymorphicKind.OPEN + ) + override fun serialize(encoder: Encoder, value: KeyboardMarkup) { + when(value) { + is ForceReply -> ForceReply.serializer().serialize(encoder, value) + is InlineKeyboardMarkup -> InlineKeyboardMarkup.serializer().serialize(encoder, value) + is ReplyKeyboardMarkup -> ReplyKeyboardMarkup.serializer().serialize(encoder, value) + is ReplyKeyboardRemove -> ReplyKeyboardRemove.serializer().serialize(encoder, value) } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChatSerializers.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChatSerializers.kt index abb66ad729..927a59966a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChatSerializers.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChatSerializers.kt @@ -5,16 +5,15 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UnknownChatType import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended.* +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import kotlinx.serialization.* -import kotlinx.serialization.internal.LongSerializer -import kotlinx.serialization.internal.StringDescriptor -import kotlinx.serialization.json.Json +import kotlinx.serialization.builtins.serializer import kotlinx.serialization.json.JsonObjectSerializer -private val formatter = Json.nonstrict +private val formatter = nonstrictJsonFormat internal object PreviewChatSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer") + override val descriptor: SerialDescriptor = SerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) override fun deserialize(decoder: Decoder): Chat { val decodedJson = JsonObjectSerializer.deserialize(decoder) @@ -27,25 +26,25 @@ internal object PreviewChatSerializer : KSerializer { "supergroup" -> formatter.fromJson(SupergroupChatImpl.serializer(), decodedJson) "channel" -> formatter.fromJson(ChannelChatImpl.serializer(), decodedJson) else -> UnknownChatType( - formatter.fromJson(LongSerializer, decodedJson.getPrimitive(chatIdField)).toChatId(), + formatter.fromJson(Long.serializer(), decodedJson.getPrimitive(chatIdField)).toChatId(), decodedJson.toString() ) } } - override fun serialize(encoder: Encoder, obj: Chat) { - when (obj) { - is ExtendedChat -> ExtendedChatSerializer.serialize(encoder, obj) - is PrivateChatImpl -> PrivateChatImpl.serializer().serialize(encoder, obj) - is GroupChatImpl -> GroupChatImpl.serializer().serialize(encoder, obj) - is SupergroupChatImpl -> SupergroupChatImpl.serializer().serialize(encoder, obj) - is ChannelChatImpl -> ChannelChatImpl.serializer().serialize(encoder, obj) + override fun serialize(encoder: Encoder, value: Chat) { + when (value) { + is ExtendedChat -> ExtendedChatSerializer.serialize(encoder, value) + is PrivateChatImpl -> PrivateChatImpl.serializer().serialize(encoder, value) + is GroupChatImpl -> GroupChatImpl.serializer().serialize(encoder, value) + is SupergroupChatImpl -> SupergroupChatImpl.serializer().serialize(encoder, value) + is ChannelChatImpl -> ChannelChatImpl.serializer().serialize(encoder, value) } } } internal object ExtendedChatSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer") + override val descriptor: SerialDescriptor = SerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) override fun deserialize(decoder: Decoder): ExtendedChat { val decodedJson = JsonObjectSerializer.deserialize(decoder) @@ -61,12 +60,12 @@ internal object ExtendedChatSerializer : KSerializer { } } - override fun serialize(encoder: Encoder, obj: ExtendedChat) { - when (obj) { - is ExtendedPrivateChatImpl -> ExtendedPrivateChatImpl.serializer().serialize(encoder, obj) - is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, obj) - is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, obj) - is ExtendedChannelChatImpl -> ExtendedChannelChatImpl.serializer().serialize(encoder, obj) + override fun serialize(encoder: Encoder, value: ExtendedChat) { + when (value) { + is ExtendedPrivateChatImpl -> ExtendedPrivateChatImpl.serializer().serialize(encoder, value) + is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, value) + is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, value) + is ExtendedChannelChatImpl -> ExtendedChannelChatImpl.serializer().serialize(encoder, value) } } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt index c2a01cab85..24331c325a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt @@ -21,4 +21,4 @@ data class PathedFile( ): TelegramMediaFile fun TelegramAPIUrlsKeeper.resolveFileURL(file: PathedFile): String = "$fileBaseUrl/${file.filePath}" -inline fun PathedFile.fullUrl(keeper: TelegramAPIUrlsKeeper): String = keeper.resolveFileURL(this) +fun PathedFile.fullUrl(keeper: TelegramAPIUrlsKeeper): String = keeper.resolveFileURL(this) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt index 93f9ae1b39..a79862a075 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt @@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.FileUniqueId import com.github.insanusmokrassar.TelegramBotAPI.types.fileUniqueIdField import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer typealias Photo = List @@ -13,7 +13,7 @@ fun Photo.biggest(): PhotoSize? = maxBy { it.resolution } -internal object PhotoSerializer : KSerializer by ArrayListSerializer( +internal object PhotoSerializer : KSerializer by ListSerializer( PhotoSize.serializer() ) @@ -28,7 +28,6 @@ data class PhotoSize( override val width: Int, override val height: Int ) : SizedMediaFile { - @Transient val resolution: Long by lazy { width.toLong() * height } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardInfo.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardInfo.kt index 4ca379de2e..f6fff2681d 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardInfo.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardInfo.kt @@ -2,54 +2,21 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.ChannelChat -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -@Deprecated( - "Renamed", - ReplaceWith( - "ForwardInfo", - "com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo" - ) -) -typealias ForwardedMessage = ForwardInfo sealed class ForwardInfo { abstract val dateOfOriginal: TelegramDate } -@Deprecated( - "Renamed", - ReplaceWith( - "AnonymousForwardInfo", - "com.github.insanusmokrassar.TelegramBotAPI.types.message.AnonymousForwardInfo" - ) -) -typealias AnonymousForwardedMessage = AnonymousForwardInfo data class AnonymousForwardInfo( override val dateOfOriginal: TelegramDate, val senderName: String ) : ForwardInfo() -@Deprecated( - "Renamed", - ReplaceWith( - "UserForwardInfo", - "com.github.insanusmokrassar.TelegramBotAPI.types.message.UserForwardInfo" - ) -) -typealias UserForwardedMessage = UserForwardInfo data class UserForwardInfo( override val dateOfOriginal: TelegramDate, val from: User ) : ForwardInfo() -@Deprecated( - "Renamed", - ReplaceWith( - "ForwardFromChannelInfo", - "com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardFromChannelInfo" - ) -) -typealias ForwardedFromChannelMessage = ForwardFromChannelInfo data class ForwardFromChannelInfo( override val dateOfOriginal: TelegramDate, val messageId: MessageIdentifier, diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt index b1a0cad11f..8e4ff44663 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt @@ -134,7 +134,6 @@ internal data class RawMessage( } } - @Transient private val forwarded: ForwardInfo? by lazy { forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field when { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/Message.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/Message.kt index 7a809c8b46..cd9d2d4408 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/Message.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/Message.kt @@ -5,7 +5,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.soywiz.klock.DateTime import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor interface Message { val messageId: MessageIdentifier @@ -21,9 +20,11 @@ data class UnknownMessageType( ) : Message internal class TelegramBotAPIMessageDeserializationStrategyClass : DeserializationStrategy { - override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer") + override val descriptor: SerialDescriptor = SerialDescriptor("TelegramBotAPIMessageSerializer", PolymorphicKind.OPEN) - override fun patch(decoder: Decoder, old: T): T = throw UpdateNotSupportedException(descriptor.name) + override fun patch(decoder: Decoder, old: T): T = throw UpdateNotSupportedException("TelegramBotAPIMessageSerializer") + + @Suppress("UNCHECKED_CAST") override fun deserialize(decoder: Decoder): T { return RawMessage.serializer().deserialize(decoder).asMessage as T } @@ -40,7 +41,7 @@ internal class TelegramBotAPIMessageDeserializeOnlySerializerClass return deserializer.deserialize(decoder) } - override fun serialize(encoder: Encoder, obj: T) { + override fun serialize(encoder: Encoder, value: T) { throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer") } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyForwardedMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyForwardedMessage.kt index 01e2b58768..225de5af71 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyForwardedMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyForwardedMessage.kt @@ -4,10 +4,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo interface PossiblyForwardedMessage : Message { val forwardInfo: ForwardInfo? - @Deprecated( - "Renamed", - ReplaceWith("forwardInfo") - ) - val forwarded: ForwardInfo? - get() = forwardInfo } \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/ShippingOption.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/ShippingOption.kt index 95ab6ca48a..6fe86673e2 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/ShippingOption.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/ShippingOption.kt @@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.payments import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.Priced import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer @Serializable data class ShippingOption( @@ -16,6 +16,6 @@ data class ShippingOption( override val prices: List ) : Priced -internal object LabeledPricesSerializer : KSerializer> by ArrayListSerializer( +internal object LabeledPricesSerializer : KSerializer> by ListSerializer( LabeledPrice.serializer() ) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/Poll.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/Poll.kt index 5334927df4..2c9990e5b5 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/Poll.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/Poll.kt @@ -1,8 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.polls import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import kotlinx.serialization.* -import kotlinx.serialization.internal.ArrayListSerializer +import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.json.* @Serializable(PollSerializer::class) @@ -73,23 +74,23 @@ data class QuizPoll( @Serializer(Poll::class) internal object PollSerializer : KSerializer { - private val pollOptionsSerializer = ArrayListSerializer(PollOption.serializer()) + private val pollOptionsSerializer = ListSerializer(PollOption.serializer()) override fun deserialize(decoder: Decoder): Poll { val asJson = JsonObjectSerializer.deserialize(decoder) return when (asJson.getPrimitive(typeField).content) { - regularPollType -> Json.nonstrict.fromJson( + regularPollType -> nonstrictJsonFormat.fromJson( RegularPoll.serializer(), asJson ) - quizPollType -> Json.nonstrict.fromJson( + quizPollType -> nonstrictJsonFormat.fromJson( QuizPoll.serializer(), asJson ) else -> UnknownPollType( asJson.getPrimitive(idField).content, asJson.getPrimitive(questionField).content, - Json.nonstrict.fromJson( + nonstrictJsonFormat.fromJson( pollOptionsSerializer, asJson.getArray(optionsField) ), @@ -101,17 +102,17 @@ internal object PollSerializer : KSerializer { } } - override fun serialize(encoder: Encoder, obj: Poll) { - val asJson = when (obj) { - is RegularPoll -> Json.nonstrict.toJson(RegularPoll.serializer(), obj) - is QuizPoll -> Json.nonstrict.toJson(QuizPoll.serializer(), obj) - is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $obj") + override fun serialize(encoder: Encoder, value: Poll) { + val asJson = when (value) { + is RegularPoll -> nonstrictJsonFormat.toJson(RegularPoll.serializer(), value) + is QuizPoll -> nonstrictJsonFormat.toJson(QuizPoll.serializer(), value) + is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $value") } val resultJson = JsonObject( - asJson.jsonObject + (typeField to when (obj) { + asJson.jsonObject + (typeField to when (value) { is RegularPoll -> JsonPrimitive(regularPollType) is QuizPoll -> JsonPrimitive(quizPollType) - is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $obj") + is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $value") }) ) JsonObjectSerializer.serialize(encoder, resultJson) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/PollOption.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/PollOption.kt index 247a7567aa..c85eb47306 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/PollOption.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/polls/PollOption.kt @@ -3,7 +3,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.polls import com.github.insanusmokrassar.TelegramBotAPI.types.textField import com.github.insanusmokrassar.TelegramBotAPI.types.votesCountField import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor @Serializable(PollOptionSerializer::class) sealed class PollOption { @@ -20,17 +19,17 @@ data class SimplePollOption ( ) : PollOption() internal object PollOptionSerializer : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption") + override val descriptor: SerialDescriptor = SimplePollOption.serializer().descriptor override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize( decoder ) - override fun serialize(encoder: Encoder, obj: PollOption) { - when (obj) { + override fun serialize(encoder: Encoder, value: PollOption) { + when (value) { is SimplePollOption -> SimplePollOption.serializer().serialize( encoder, - obj + value ) } } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChannelPostUpdate.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChannelPostUpdate.kt index 97146d1278..43030af744 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChannelPostUpdate.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChannelPostUpdate.kt @@ -2,7 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseSentMessageUpdate data class ChannelPostUpdate( diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/MessageUpdate.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/MessageUpdate.kt index 8b855fff22..a6b938bc9d 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/MessageUpdate.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/MessageUpdate.kt @@ -2,7 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseSentMessageUpdate data class MessageUpdate( diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt index 6d317c4071..536fd33827 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt @@ -2,9 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import kotlinx.serialization.* -import kotlinx.serialization.internal.StringDescriptor -import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonElementSerializer interface Update { @@ -18,21 +17,21 @@ data class UnknownUpdateType( ) : Update internal object UpdateSerializerWithoutDeserialization : KSerializer { - override val descriptor: SerialDescriptor = StringDescriptor.withName("UpdateSerializerWithoutDeserialization") + override val descriptor: SerialDescriptor = JsonElementSerializer.descriptor override fun deserialize(decoder: Decoder): Update = UpdateDeserializationStrategy.deserialize(decoder) - override fun serialize(encoder: Encoder, obj: Update) = throw UnsupportedOperationException() + override fun serialize(encoder: Encoder, value: Update) = throw UnsupportedOperationException() } internal object UpdateDeserializationStrategy : DeserializationStrategy { - override val descriptor: SerialDescriptor = StringDescriptor.withName("UpdateDeserializationStrategy") + override val descriptor: SerialDescriptor = JsonElementSerializer.descriptor - override fun patch(decoder: Decoder, old: Update): Update = throw UpdateNotSupportedException(descriptor.name) + override fun patch(decoder: Decoder, old: Update): Update = throw UpdateNotSupportedException("Update") override fun deserialize(decoder: Decoder): Update { val asJson = JsonElementSerializer.deserialize(decoder) - return Json.nonstrict.fromJson( + return nonstrictJsonFormat.fromJson( RawUpdate.serializer(), asJson ).asUpdate( diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt index e57697e4fa..c0cafb4710 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt @@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers import com.github.insanusmokrassar.TelegramBotAPI.types.update.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update +import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow @@ -10,6 +11,7 @@ import kotlinx.coroutines.flow.asFlow private fun BroadcastChannel.createUpdateReceiver(): UpdateReceiver = ::send +@FlowPreview class FlowsUpdatesFilter( broadcastChannelsSize: Int = Channel.CONFLATED ): UpdatesFilter { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/KtorUpdatesPoller.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/KtorUpdatesPoller.kt deleted file mode 100644 index 81f393e2d5..0000000000 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/KtorUpdatesPoller.kt +++ /dev/null @@ -1,144 +0,0 @@ -package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers - -import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.bot.UpdatesPoller -import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates -import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.DeleteWebhook -import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST -import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update -import com.github.insanusmokrassar.TelegramBotAPI.utils.* -import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.executeUnsafe -import io.ktor.client.HttpClient -import io.ktor.client.engine.HttpClientEngine -import kotlinx.coroutines.* -import kotlinx.coroutines.channels.Channel - -@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api") -fun KtorUpdatesPoller( - telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, - engine: HttpClientEngine, - timeoutSeconds: Int? = null, - oneTimeUpdatesLimit: Int? = null, - allowedUpdates: List = ALL_UPDATES_LIST, - exceptionsHandler: (Exception) -> Boolean = { true }, - updatesReceiver: UpdateReceiver -): KtorUpdatesPoller { - val executor = KtorRequestsExecutor( - telegramAPIUrlsKeeper, - HttpClient(engine) - ) - - return KtorUpdatesPoller( - executor, - timeoutSeconds, - oneTimeUpdatesLimit, - allowedUpdates, - exceptionsHandler, - updatesReceiver - ) -} - -@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api") -class KtorUpdatesPoller( - private val executor: RequestsExecutor, - private val timeoutSeconds: Int? = null, - private val oneTimeUpdatesLimit: Int? = null, - private val allowedUpdates: List = ALL_UPDATES_LIST, - private val exceptionsHandler: (Exception) -> Boolean = { true }, - private val updatesReceiver: UpdateReceiver -) : UpdatesPoller { - private var lastHandledUpdate: UpdateIdentifier = 0L - private val mediaGroup: MutableList = mutableListOf() - - private var pollerJob: Job? = null - - private suspend fun sendToBlock(data: Update) { - updatesReceiver(data) - lastHandledUpdate = data.updateId - } - - private suspend fun pushMediaGroupUpdate(update: BaseMessageUpdate? = null) { - val inputMediaGroupId = (update ?.data as? MediaGroupMessage) ?.mediaGroupId - if (mediaGroup.isNotEmpty() && inputMediaGroupId ?.equals(mediaGroup.mediaGroupId) != true) { - mediaGroup.sortBy { it.updateId } - mediaGroup.convertWithMediaGroupUpdates().forEach { - sendToBlock(it) - } - mediaGroup.clear() - } - inputMediaGroupId ?.let { - mediaGroup.add(update) - } ?: sendToBlock(update ?: return) - } - - private suspend fun getUpdates(): List { - return executor.execute( - GetUpdates( - lastHandledUpdate + 1, // incremented because offset counted from 1 when updates id from 0 - oneTimeUpdatesLimit, - timeoutSeconds, - allowedUpdates - ) - ) - } - - private suspend fun handleUpdates(updates: List) { - for (update in updates) { - (update as? BaseMessageUpdate) ?.let { - if (it.data is MediaGroupMessage) { - pushMediaGroupUpdate(it) - } else { - null - } - } ?:let { - pushMediaGroupUpdate() - sendToBlock(update) - } - } - - pushMediaGroupUpdate() - } - - private val startStopScope = CoroutineScope(Dispatchers.Default) - private val startStopQueue = Channel(2) - private val startStopJob = startStopScope.launch { - for (scope in startStopQueue) { - scope ?.also { - pollerJob ?: scope.launch { - executor.executeUnsafe(DeleteWebhook()) - while (isActive) { - try { - val updates = getUpdates() - handleUpdates(updates) - } catch (e: Exception) { - if (exceptionsHandler(e)) { - continue - } else { - close() - break - } - } - } - }.also { - pollerJob = it - } - } ?: also { - startStopQueue.close() - pollerJob ?.cancel() - startStopScope.cancel() - return@launch - } - } - } - override fun start(scope: CoroutineScope) { - startStopQueue.offer(scope) - } - - override fun close() { - startStopQueue.offer(null) - } -} \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt index ba0daee6b7..868484ccb1 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt @@ -13,49 +13,6 @@ interface UpdatesFilter { val allowedUpdates: List } -@Deprecated( - "It is builder function for SimpleUpdatesFilter", - ReplaceWith( - "SimpleUpdatesFilter", - "com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.SimpleUpdatesFilter" - ) -) -fun UpdatesFilter( - messageCallback: UpdateReceiver? = null, - messageMediaGroupCallback: UpdateReceiver? = null, - editedMessageCallback: UpdateReceiver? = null, - editedMessageMediaGroupCallback: UpdateReceiver? = null, - channelPostCallback: UpdateReceiver? = null, - channelPostMediaGroupCallback: UpdateReceiver? = null, - editedChannelPostCallback: UpdateReceiver? = null, - editedChannelPostMediaGroupCallback: UpdateReceiver? = null, - chosenInlineResultCallback: UpdateReceiver? = null, - inlineQueryCallback: UpdateReceiver? = null, - callbackQueryCallback: UpdateReceiver? = null, - shippingQueryCallback: UpdateReceiver? = null, - preCheckoutQueryCallback: UpdateReceiver? = null, - pollUpdateCallback: UpdateReceiver? = null, - pollAnswerUpdateCallback: UpdateReceiver? = null, - unknownUpdateTypeCallback: UpdateReceiver? = null -) = SimpleUpdatesFilter( - messageCallback, - messageMediaGroupCallback, - editedMessageCallback, - editedMessageMediaGroupCallback, - channelPostCallback, - channelPostMediaGroupCallback, - editedChannelPostCallback, - editedChannelPostMediaGroupCallback, - chosenInlineResultCallback, - inlineQueryCallback, - callbackQueryCallback, - shippingQueryCallback, - preCheckoutQueryCallback, - pollUpdateCallback, - pollAnswerUpdateCallback, - unknownUpdateTypeCallback -) - data class SimpleUpdatesFilter( private val messageCallback: UpdateReceiver? = null, private val messageMediaGroupCallback: UpdateReceiver? = null, diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Annotations.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Annotations.kt index fc431a2ca1..a2a11b80ba 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Annotations.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/Annotations.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils -import kotlin.Experimental.Level - -@Experimental(Level.WARNING) +@RequiresOptIn( + "It is possible, that bevahiour of this thing will be changed later", + RequiresOptIn.Level.WARNING +) annotation class PreviewFeature diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt index 35e674808a..89aca12d12 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/JSON.kt @@ -3,9 +3,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.json.* -inline fun T.toJsonWithoutNulls(serializer: SerializationStrategy): JsonObject = toJson(serializer).withoutNulls() +internal val nonstrictJsonFormat = Json { + isLenient = true + ignoreUnknownKeys = true + serializeSpecialFloatingPointValues = true + useArrayPolymorphism = true +} -inline fun T.toJson(serializer: SerializationStrategy): JsonObject = Json.nonstrict.toJson( +fun T.toJsonWithoutNulls(serializer: SerializationStrategy): JsonObject = toJson(serializer).withoutNulls() + +fun T.toJson(serializer: SerializationStrategy): JsonObject = nonstrictJsonFormat.toJson( serializer, this ).jsonObject diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt index cc7ec0d8ea..29523ab7ea 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt @@ -7,7 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended. private const val internalLinkBeginning = "https://t.me" -@PreviewFeature fun makeLinkToMessage( username: String, messageId: MessageIdentifier @@ -16,7 +15,6 @@ fun makeLinkToMessage( private val linkIdRedundantPartRegex = Regex("^-100") private val usernameBeginSymbolRegex = Regex("^@") -@PreviewFeature fun makeLinkToMessage( chat: ExtendedChat, messageId: MessageIdentifier diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/UpdatesPolling.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/UpdatesPolling.kt deleted file mode 100644 index 56295e5b51..0000000000 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/UpdatesPolling.kt +++ /dev/null @@ -1,118 +0,0 @@ -package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions - -import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.bot.UpdatesPoller -import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST -import com.github.insanusmokrassar.TelegramBotAPI.types.update.* -import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update -import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.KtorUpdatesPoller -import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter -import kotlinx.coroutines.* - -@Deprecated( - "Replaced", - ReplaceWith( - "UpdateReceiver", - "com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver" - ) -) -typealias UpdateReceiver = com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver - -@Deprecated("Replaced into TelegramBotAPI-extensions-api") -fun RequestsExecutor.startGettingOfUpdates( - timeoutMillis: Long = 30 * 1000, - scope: CoroutineScope = CoroutineScope(Dispatchers.Default), - allowedUpdates: List? = null, - block: UpdateReceiver -): UpdatesPoller { - return KtorUpdatesPoller( - this, - timeoutMillis.toInt() / 1000, - allowedUpdates = allowedUpdates ?: ALL_UPDATES_LIST, - updatesReceiver = block - ).also { - it.start(scope) - } -} - -@Deprecated("Replaced into TelegramBotAPI-extensions-api") -fun RequestsExecutor.startGettingOfUpdates( - messageCallback: UpdateReceiver? = null, - messageMediaGroupCallback: UpdateReceiver? = null, - editedMessageCallback: UpdateReceiver? = null, - editedMessageMediaGroupCallback: UpdateReceiver? = null, - channelPostCallback: UpdateReceiver? = null, - channelPostMediaGroupCallback: UpdateReceiver? = null, - editedChannelPostCallback: UpdateReceiver? = null, - editedChannelPostMediaGroupCallback: UpdateReceiver? = null, - chosenInlineResultCallback: UpdateReceiver? = null, - inlineQueryCallback: UpdateReceiver? = null, - callbackQueryCallback: UpdateReceiver? = null, - shippingQueryCallback: UpdateReceiver? = null, - preCheckoutQueryCallback: UpdateReceiver? = null, - pollCallback: UpdateReceiver? = null, - pollAnswerCallback: UpdateReceiver? = null, - timeoutMillis: Long = 30 * 1000, - scope: CoroutineScope = GlobalScope -): UpdatesPoller { - val filter = UpdatesFilter( - messageCallback, - messageMediaGroupCallback, - editedMessageCallback, - editedMessageMediaGroupCallback, - channelPostCallback, - channelPostMediaGroupCallback, - editedChannelPostCallback, - editedChannelPostMediaGroupCallback, - chosenInlineResultCallback, - inlineQueryCallback, - callbackQueryCallback, - shippingQueryCallback, - preCheckoutQueryCallback, - pollCallback, - pollAnswerCallback - ) - return startGettingOfUpdates( - timeoutMillis, - scope, - filter.allowedUpdates, - filter.asUpdateReceiver - ) -} - -@Deprecated("Replaced into TelegramBotAPI-extensions-api") -fun RequestsExecutor.startGettingOfUpdates( - messageCallback: UpdateReceiver? = null, - mediaGroupCallback: UpdateReceiver? = null, - editedMessageCallback: UpdateReceiver? = null, - channelPostCallback: UpdateReceiver? = null, - editedChannelPostCallback: UpdateReceiver? = null, - chosenInlineResultCallback: UpdateReceiver? = null, - inlineQueryCallback: UpdateReceiver? = null, - callbackQueryCallback: UpdateReceiver? = null, - shippingQueryCallback: UpdateReceiver? = null, - preCheckoutQueryCallback: UpdateReceiver? = null, - pollCallback: UpdateReceiver? = null, - pollAnswerCallback: UpdateReceiver? = null, - timeoutMillis: Long = 30 * 1000, - scope: CoroutineScope = CoroutineScope(Dispatchers.Default) -): UpdatesPoller = startGettingOfUpdates( - messageCallback = messageCallback, - messageMediaGroupCallback = mediaGroupCallback, - editedMessageCallback = editedMessageCallback, - editedMessageMediaGroupCallback = mediaGroupCallback, - channelPostCallback = channelPostCallback, - channelPostMediaGroupCallback = mediaGroupCallback, - editedChannelPostCallback = editedChannelPostCallback, - editedChannelPostMediaGroupCallback = mediaGroupCallback, - chosenInlineResultCallback = chosenInlineResultCallback, - inlineQueryCallback = inlineQueryCallback, - callbackQueryCallback = callbackQueryCallback, - shippingQueryCallback = shippingQueryCallback, - preCheckoutQueryCallback = preCheckoutQueryCallback, - pollCallback = pollCallback, - pollAnswerCallback = pollAnswerCallback, - timeoutMillis = timeoutMillis, - scope = scope -) diff --git a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt new file mode 100644 index 0000000000..50219dd4c5 --- /dev/null +++ b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/TestsJsonFormat.kt @@ -0,0 +1,12 @@ +package com.github.insanusmokrassar.TelegramBotAPI + +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonConfiguration + +val TestsJsonFormat = Json(JsonConfiguration.Stable) +val NonstrictTestsJsonFormat = Json { + isLenient = true + ignoreUnknownKeys = true + serializeSpecialFloatingPointValues = true + useArrayPolymorphism = true +} diff --git a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/BotActionTests.kt b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/BotActionTests.kt index a00391b948..4c1cf4d8f3 100644 --- a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/BotActionTests.kt +++ b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/BotActionTests.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types +import com.github.insanusmokrassar.TelegramBotAPI.TestsJsonFormat import com.github.insanusmokrassar.TelegramBotAPI.types.actions.* import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.Serializable -import kotlinx.serialization.json.Json import kotlin.test.Test import kotlin.test.assertEquals @@ -33,10 +33,10 @@ class BotActionTests { } private fun checkBotActionSerializeDeserialize(example: Example) { - val stringified = Json.plain.stringify(Example.serializer(), example) + val stringified = TestsJsonFormat.stringify(Example.serializer(), example) assertEquals("{\"botAction\":\"${example.botAction.actionName}\"}", stringified) - val deserialized = Json.plain.parse(Example.serializer(), stringified) + val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified) assertEquals(example, deserialized) diff --git a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifierTests.kt b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifierTests.kt index bcf6f87870..02005ee51c 100644 --- a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifierTests.kt +++ b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifierTests.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types +import com.github.insanusmokrassar.TelegramBotAPI.TestsJsonFormat import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.Serializable -import kotlinx.serialization.json.Json import kotlin.test.* @ImplicitReflectionSerializer @@ -54,25 +54,25 @@ class ChatIdentifierTests { ) Example(chatIdentifierChatId.toChatId()).let { withChatId -> - val stringified = Json.plain.stringify(Example.serializer(), withChatId) + val stringified = TestsJsonFormat.stringify(Example.serializer(), withChatId) assertEquals(stringified, "{\"identifier\":$chatIdentifierChatId}") - val deserialized = Json.plain.parse(Example.serializer(), stringified) + val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified) assertEquals(withChatId, deserialized) } Example(testUsername.toUsername()).let { withUsername -> - val stringified = Json.plain.stringify(Example.serializer(), withUsername) + val stringified = TestsJsonFormat.stringify(Example.serializer(), withUsername) assertEquals(stringified, "{\"identifier\":\"$testUsername\"}") - val deserialized = Json.plain.parse(Example.serializer(), stringified) + val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified) assertEquals(withUsername, deserialized) } // Replace @ by empty string, because from time to time we can retrieve from Telegram system // username without starting @ symbol Example(testUsername.toUsername()).let { withUsername -> - val stringified = Json.plain.stringify(Example.serializer(), withUsername).replace("@", "") + val stringified = TestsJsonFormat.stringify(Example.serializer(), withUsername).replace("@", "") assertEquals("{\"identifier\":\"${testUsername.replace("@", "")}\"}", stringified) - val deserialized = Json.plain.parse(Example.serializer(), stringified) + val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified) assertEquals(withUsername, deserialized) } } diff --git a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/TextPartsCreatingTests.kt b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/TextPartsCreatingTests.kt index 7a2024523e..4ed06dd286 100644 --- a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/TextPartsCreatingTests.kt +++ b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/TextPartsCreatingTests.kt @@ -1,7 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.* -import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2 import com.github.insanusmokrassar.TelegramBotAPI.utils.* import kotlin.test.* diff --git a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseModeTests.kt b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseModeTests.kt index 42aa361716..6bacbc57e8 100644 --- a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseModeTests.kt +++ b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseModeTests.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types +import com.github.insanusmokrassar.TelegramBotAPI.TestsJsonFormat import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.* import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.Serializable -import kotlinx.serialization.json.Json import kotlin.test.Test import kotlin.test.assertEquals @@ -18,10 +18,10 @@ class ParseModeTests { fun `Markdown parse mode correctly serializing and deserializing`() { val example = Example(Markdown) - val stringified = Json.plain.stringify(Example.serializer(), example) + val stringified = TestsJsonFormat.stringify(Example.serializer(), example) assertEquals("{\"mode\":\"Markdown\"}", stringified) - val deserialized = Json.plain.parse(Example.serializer(), stringified) + val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified) assertEquals(example, deserialized) } @@ -29,10 +29,10 @@ class ParseModeTests { fun `HTML parse mode correctly serializing and deserializing`() { val example = Example(HTML) - val stringified = Json.plain.stringify(Example.serializer(), example) + val stringified = TestsJsonFormat.stringify(Example.serializer(), example) assertEquals("{\"mode\":\"HTML\"}", stringified) - val deserialized = Json.plain.parse(Example.serializer(), stringified) + val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified) assertEquals(example, deserialized) } } diff --git a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDateTests.kt b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDateTests.kt index 648965a44c..faf94bf560 100644 --- a/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDateTests.kt +++ b/TelegramBotAPI/src/commonTest/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/TelegramDateTests.kt @@ -1,16 +1,15 @@ package com.github.insanusmokrassar.TelegramBotAPI.types +import com.github.insanusmokrassar.TelegramBotAPI.TestsJsonFormat import com.soywiz.klock.DateTime import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.Serializable -import kotlinx.serialization.json.Json -import java.util.concurrent.TimeUnit import kotlin.test.Test import kotlin.test.assertEquals -private val dateTimeMillis = System.currentTimeMillis() -private val dateTimeUnix = TimeUnit.MILLISECONDS.toSeconds(dateTimeMillis) -private val dateTime = DateTime(TimeUnit.SECONDS.toMillis(dateTimeUnix)) +private val dateTimeUnix = DateTime.nowUnixLong() +private val dateTimeMillis = dateTimeUnix * 1000 +private val dateTime = DateTime(dateTimeMillis) @ImplicitReflectionSerializer class TelegramDateTests { @@ -22,10 +21,10 @@ class TelegramDateTests { fun `Serializtion of TelegramDate is working correctly`() { val example = Example(TelegramDate(dateTimeUnix)) - val stringified = Json.plain.stringify(Example.serializer(), example) + val stringified = TestsJsonFormat.stringify(Example.serializer(), example) assertEquals("{\"dateTime\":$dateTimeUnix}", stringified) - val deserialized = Json.plain.parse(Example.serializer(), stringified) + val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified) assertEquals(example, deserialized) assertEquals(dateTime, deserialized.dateTime.asDate) diff --git a/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFileFromJavaFile.kt b/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFileFromJavaFile.kt index 99b52b76e6..58193b52ac 100644 --- a/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFileFromJavaFile.kt +++ b/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/InputFileFromJavaFile.kt @@ -3,6 +3,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile import java.io.File -fun File.toInputFile() = MultipartFile( - StorageFile(this) -) +fun File.toInputFile() = if (exists()) { + MultipartFile( + StorageFile(this) + ) +} else { + error("Specified file $absolutePath does not exists") +} diff --git a/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/KtorUpdatesCIOPoller.kt b/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/KtorUpdatesCIOPoller.kt deleted file mode 100644 index ba6d7be94c..0000000000 --- a/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/KtorUpdatesCIOPoller.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers - -import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update -import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper -import io.ktor.client.HttpClient -import io.ktor.client.engine.HttpClientEngine -import io.ktor.client.engine.cio.CIO -import io.ktor.client.engine.cio.endpoint -import io.ktor.util.KtorExperimentalAPI - -@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api") -@KtorExperimentalAPI -fun KtorUpdatesPoller( - telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, - timeoutSeconds: Int? = null, - oneTimeUpdatesLimit: Int? = null, - allowedUpdates: List = ALL_UPDATES_LIST, - exceptionsHandler: (Exception) -> Boolean = { true }, - updatesReceiver: UpdateReceiver -): KtorUpdatesPoller { - val executor = KtorRequestsExecutor( - telegramAPIUrlsKeeper, - HttpClient( - CIO.create { - endpoint { - timeoutSeconds ?.times(1000) ?.also { timeOutMillis -> - keepAliveTime = timeOutMillis.toLong() - } - connectTimeout = 1000 - } - } - ) - ) - - return KtorUpdatesPoller( - executor, - timeoutSeconds, - oneTimeUpdatesLimit, - allowedUpdates, - exceptionsHandler, - updatesReceiver - ) -} - -@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api") -@KtorExperimentalAPI -fun KtorUpdatesPoller( - telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, - timeoutSeconds: Int? = null, - oneTimeUpdatesLimit: Int? = null, - allowedUpdates: List = ALL_UPDATES_LIST, - exceptionsHandler: (Exception) -> Boolean = { true }, - clientEngine: HttpClientEngine = CIO.create { - endpoint { - timeoutSeconds ?.times(1000) ?.also { timeOutMillis -> - keepAliveTime = timeOutMillis.toLong() - } - connectTimeout = 1000 - } - }, - updatesReceiver: UpdateReceiver -): KtorUpdatesPoller { - val executor = KtorRequestsExecutor( - telegramAPIUrlsKeeper, - HttpClient(clientEngine) - ) - - return KtorUpdatesPoller( - executor, - timeoutSeconds, - oneTimeUpdatesLimit, - allowedUpdates, - exceptionsHandler, - updatesReceiver - ) -} diff --git a/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt b/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt index 1a6c82ce32..fd995cde3d 100644 --- a/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt +++ b/TelegramBotAPI/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/Webhooks.kt @@ -8,9 +8,11 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update +import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.webhook.WebhookPrivateKeyConfig import com.github.insanusmokrassar.TelegramBotAPI.utils.convertWithMediaGroupUpdates +import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat import io.ktor.application.call import io.ktor.request.receiveText import io.ktor.response.respond @@ -19,7 +21,6 @@ import io.ktor.routing.routing import io.ktor.server.engine.* import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel -import kotlinx.serialization.json.Json import java.util.concurrent.Executors import java.util.concurrent.TimeUnit @@ -73,8 +74,8 @@ suspend fun RequestsExecutor.setWebhook( module { routing { post(listenRoute) { - val asJson = Json.nonstrict.parseJson(call.receiveText()) - val update = Json.nonstrict.fromJson( + val asJson = nonstrictJsonFormat.parseJson(call.receiveText()) + val update = nonstrictJsonFormat.fromJson( RawUpdate.serializer(), asJson ) diff --git a/gradle.properties b/gradle.properties index 67f196be79..a917de2714 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ kotlin.code.style=official -kotlin_version=1.3.61 -kotlin_coroutines_version=1.3.3 -kotlin_serialisation_runtime_version=0.14.0 -klock_version=1.8.7 -uuid_version=0.0.7 -ktor_version=1.3.1 +kotlin_version=1.3.70 +kotlin_coroutines_version=1.3.5 +kotlin_serialisation_runtime_version=0.20.0 +klock_version=1.10.0 +uuid_version=0.1.0 +ktor_version=1.3.2 library_group=com.github.insanusmokrassar -library_version=0.24.1 +library_version=0.25.0 gradle_bintray_plugin_version=1.8.4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0879550bd9..8ef06692c2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Nov 29 12:11:00 HKT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip