mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
commit
17c10a2975
22
CHANGELOG.md
22
CHANGELOG.md
@ -1,6 +1,26 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
## 0.17.0
|
## 0.18.0 Raws cleaning
|
||||||
|
|
||||||
|
* Made internal and not available outside of library:
|
||||||
|
* `RawMessage`
|
||||||
|
* `RawUpdate`
|
||||||
|
* `RawChatMember`
|
||||||
|
* `RawMessageEntity`
|
||||||
|
* `RawInlineQuery`
|
||||||
|
* `RawCallbackQuery`
|
||||||
|
* `RawChosenInlineResult`
|
||||||
|
|
||||||
|
* All `RawMessage` usages was replaced with `Message` interface (with some of other raw classes was made the same things)
|
||||||
|
* `TelegramBotAPIMessageDeserializationStrategy` was created. It was used for deserialization of Telegram Bot API
|
||||||
|
incoming messages
|
||||||
|
* `TelegramBotAPIMessageDeserializeOnlySerializer` was created. It **MUST NOT** be used to serialize messages
|
||||||
|
* Update of description
|
||||||
|
* Make `Game` object a little bit more standartizated
|
||||||
|
* `Game` now is not serializable and have no additional trash, related to serialization
|
||||||
|
* `TelegramFile` was removed
|
||||||
|
|
||||||
|
## 0.17.0 July 29, 2019 API Update
|
||||||
|
|
||||||
Libraries updates:
|
Libraries updates:
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
## What is it?
|
## What is it?
|
||||||
|
|
||||||
It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin. Most part of some specific
|
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
|
||||||
solves or unuseful moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
project.version = "0.17.0"
|
project.version = "0.18.0"
|
||||||
project.group = "com.github.insanusmokrassar"
|
project.group = "com.github.insanusmokrassar"
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
@ -8,6 +8,6 @@ ktor_version=1.2.3
|
|||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
|
||||||
project_public_name=Telegram Bot API
|
project_public_name=Telegram Bot API
|
||||||
project_public_description=It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin
|
project_public_description=Library for Object-Oriented and type-safe work with Telegram Bot API
|
||||||
|
|
||||||
disableImplicitReflectionSerializerAnnotation=-Xexperimental=kotlinx.serialization.ImplicitReflectionSerializer
|
disableImplicitReflectionSerializerAnnotation=-Xexperimental=kotlinx.serialization.ImplicitReflectionSerializer
|
||||||
|
@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.newRequestExcep
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.extractResult
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||||
@ -74,11 +75,11 @@ class KtorRequestsExecutor(
|
|||||||
val content = call.response.use {
|
val content = call.response.use {
|
||||||
it.content.toByteArray().toString(Charsets.UTF_8)
|
it.content.toByteArray().toString(Charsets.UTF_8)
|
||||||
}
|
}
|
||||||
val responseObject = jsonFormatter.parse(
|
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||||
Response.serializer(request.resultSerializer()),
|
|
||||||
content
|
(responseObject.result ?.let {
|
||||||
)
|
jsonFormatter.fromJson(request.resultDeserializer(), it)
|
||||||
responseObject.result ?: responseObject.parameters ?.let {
|
} ?: responseObject.parameters ?.let {
|
||||||
val error = it.error
|
val error = it.error
|
||||||
if (error is RetryAfterError) {
|
if (error is RetryAfterError) {
|
||||||
delay(error.leftToRetry)
|
delay(error.leftToRetry)
|
||||||
@ -92,7 +93,7 @@ class KtorRequestsExecutor(
|
|||||||
content,
|
content,
|
||||||
"Can't get result object from $content"
|
"Can't get result object from $content"
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapWithCommonValues
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapWithCommonValues
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.forms.*
|
import io.ktor.client.request.forms.MultiPartFormDataContent
|
||||||
|
import io.ktor.client.request.forms.formData
|
||||||
import io.ktor.http.Headers
|
import io.ktor.http.Headers
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
|
import kotlinx.io.core.readBytes
|
||||||
|
|
||||||
class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||||
|
|
||||||
@ -21,9 +23,7 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
when (value) {
|
when (value) {
|
||||||
is MultipartFile -> append(
|
is MultipartFile -> append(
|
||||||
key,
|
key,
|
||||||
InputProvider {
|
value.file.asInput().readBytes(),
|
||||||
value.file.asInput()
|
|
||||||
},
|
|
||||||
Headers.build {
|
Headers.build {
|
||||||
append(HttpHeaders.ContentType, value.mimeType)
|
append(HttpHeaders.ContentType, value.mimeType)
|
||||||
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
||||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
fun newRequestException(
|
fun newRequestException(
|
||||||
response: Response<*>,
|
response: Response,
|
||||||
plainAnswer: String,
|
plainAnswer: String,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
@ -15,7 +15,7 @@ fun newRequestException(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sealed class RequestException constructor(
|
sealed class RequestException constructor(
|
||||||
val response: Response<*>,
|
val response: Response,
|
||||||
val plainAnswer: String,
|
val plainAnswer: String,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
@ -24,13 +24,13 @@ sealed class RequestException constructor(
|
|||||||
cause
|
cause
|
||||||
)
|
)
|
||||||
|
|
||||||
class CommonRequestException(response: Response<*>, plainAnswer: String, message: String?, cause: Throwable?) :
|
class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
RequestException(response, plainAnswer, message, cause)
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
class UnauthorizedException(response: Response<*>, plainAnswer: String, message: String?, cause: Throwable?) :
|
class UnauthorizedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
RequestException(response, plainAnswer, message, cause)
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
class ReplyMessageNotFoundException(response: Response<*>, plainAnswer: String, message: String?, cause: Throwable?) :
|
class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
RequestException(response, plainAnswer, message, cause)
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
|
@ -15,5 +15,5 @@ data class DeleteMessage(
|
|||||||
) : SimpleRequest<Boolean>, MessageAction {
|
) : SimpleRequest<Boolean>, MessageAction {
|
||||||
override fun method(): String = "deleteMessage"
|
override fun method(): String = "deleteMessage"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -16,12 +17,12 @@ data class ForwardMessage(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
val disableNotification: Boolean = false
|
val disableNotification: Boolean = false
|
||||||
): SimpleRequest<RawMessage>, MessageAction {
|
): SimpleRequest<Message>, MessageAction {
|
||||||
@Transient
|
@Transient
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
get() = fromChatId
|
get() = fromChatId
|
||||||
|
|
||||||
override fun method(): String = "forwardMessage"
|
override fun method(): String = "forwardMessage"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,5 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
class GetMe : SimpleRequest<User> {
|
class GetMe : SimpleRequest<User> {
|
||||||
override fun method(): String = "getMe"
|
override fun method(): String = "getMe"
|
||||||
override fun resultSerializer(): KSerializer<User> = User.serializer()
|
override fun resultDeserializer(): KSerializer<User> = User.serializer()
|
||||||
}
|
}
|
@ -3,40 +3,22 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_MESSAGE", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_MESSAGE"))
|
|
||||||
const val UPDATE_MESSAGE = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_MESSAGE
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_EDITED_MESSAGE", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_MESSAGE"))
|
|
||||||
const val UPDATE_EDITED_MESSAGE = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_MESSAGE
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CHANNEL_POST", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHANNEL_POST"))
|
|
||||||
const val UPDATE_CHANNEL_POST = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHANNEL_POST
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_EDITED_CHANNEL_POST", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_CHANNEL_POST"))
|
|
||||||
const val UPDATE_EDITED_CHANNEL_POST = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_CHANNEL_POST
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CHOSEN_INLINE_RESULT", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHOSEN_INLINE_RESULT"))
|
|
||||||
const val UPDATE_CHOSEN_INLINE_RESULT = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHOSEN_INLINE_RESULT
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_INLINE_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_INLINE_QUERY"))
|
|
||||||
const val UPDATE_INLINE_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_INLINE_QUERY
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CALLBACK_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CALLBACK_QUERY"))
|
|
||||||
const val UPDATE_CALLBACK_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CALLBACK_QUERY
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_SHIPPING_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_SHIPPING_QUERY"))
|
|
||||||
const val UPDATE_SHIPPING_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_SHIPPING_QUERY
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_PRE_CHECKOUT_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_PRE_CHECKOUT_QUERY"))
|
|
||||||
const val UPDATE_PRE_CHECKOUT_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_PRE_CHECKOUT_QUERY
|
|
||||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_POLL", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_POLL"))
|
|
||||||
const val UPDATE_POLL = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_POLL
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetUpdates(
|
data class GetUpdates(
|
||||||
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
||||||
val limit: Int? = null,
|
val limit: Int? = null,
|
||||||
val timeout: Int? = null,
|
val timeout: Int? = null,
|
||||||
val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
): SimpleRequest<List<RawUpdate>> {
|
): SimpleRequest<List<Update>> {
|
||||||
override fun method(): String = "getUpdates"
|
override fun method(): String = "getUpdates"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<List<RawUpdate>> = ArrayListSerializer(RawUpdate.serializer())
|
override fun resultDeserializer(): KSerializer<List<Update>> = ArrayListSerializer(
|
||||||
|
UpdateSerializerWithoutDeserialization
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,5 @@ data class StopPoll(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
||||||
override fun method(): String = "stopPoll"
|
override fun method(): String = "stopPoll"
|
||||||
override fun resultSerializer(): KSerializer<Poll> = Poll.serializer()
|
override fun resultDeserializer(): KSerializer<Poll> = Poll.serializer()
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
@ -8,14 +7,7 @@ import kotlinx.serialization.json.JsonObject
|
|||||||
@Serializable(RequestSerializer::class)
|
@Serializable(RequestSerializer::class)
|
||||||
interface Request<T: Any> {
|
interface Request<T: Any> {
|
||||||
fun method(): String
|
fun method(): String
|
||||||
fun resultSerializer(): KSerializer<T>
|
fun resultDeserializer(): DeserializationStrategy<T>
|
||||||
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
|
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
|
||||||
}
|
}
|
||||||
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)
|
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)
|
||||||
|
|
||||||
fun <T : Any> StringFormat.extractResult(
|
|
||||||
from: String,
|
|
||||||
dataSerializer: KSerializer<T>
|
|
||||||
): Response<T> {
|
|
||||||
return parse(Response.serializer(dataSerializer), from)
|
|
||||||
}
|
|
@ -20,7 +20,7 @@ data class AnswerCallbackQuery(
|
|||||||
val cachedTimeSeconds: Int? = null
|
val cachedTimeSeconds: Int? = null
|
||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerCallbackQuery"
|
override fun method(): String = "answerCallbackQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CallbackQuery.createAnswer(
|
fun CallbackQuery.createAnswer(
|
||||||
|
@ -28,7 +28,7 @@ data class AnswerInlineQuery(
|
|||||||
val switchPmParameter: String? = null
|
val switchPmParameter: String? = null
|
||||||
): SimpleRequest<Boolean> {
|
): SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerInlineQuery"
|
override fun method(): String = "answerInlineQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
fun InlineQuery.createAnswer(
|
fun InlineQuery.createAnswer(
|
||||||
|
@ -7,7 +7,7 @@ import kotlinx.serialization.serializer
|
|||||||
|
|
||||||
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerPreCheckoutQuery"
|
override fun method(): String = "answerPreCheckoutQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||||
|
|
||||||
val preCheckoutQueryId: PreCheckoutQueryId
|
val preCheckoutQueryId: PreCheckoutQueryId
|
||||||
val isOk: Boolean
|
val isOk: Boolean
|
||||||
|
@ -7,7 +7,7 @@ import kotlinx.serialization.serializer
|
|||||||
|
|
||||||
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerShippingQuery"
|
override fun method(): String = "answerShippingQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||||
|
|
||||||
val shippingQueryId: ShippingQueryIdentifier
|
val shippingQueryId: ShippingQueryIdentifier
|
||||||
val isOk: Boolean
|
val isOk: Boolean
|
||||||
|
@ -13,5 +13,5 @@ data class ExportChatInviteLink(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<String> {
|
): ChatRequest, SimpleRequest<String> {
|
||||||
override fun method(): String = "exportChatInviteLink"
|
override fun method(): String = "exportChatInviteLink"
|
||||||
override fun resultSerializer(): KSerializer<String> = StringSerializer
|
override fun resultDeserializer(): KSerializer<String> = StringSerializer
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ data class LeaveChat(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "leaveChat"
|
override fun method(): String = "leaveChat"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,5 @@ data class GetChat(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<ExtendedChat> {
|
): ChatRequest, SimpleRequest<ExtendedChat> {
|
||||||
override fun method(): String = "getChat"
|
override fun method(): String = "getChat"
|
||||||
override fun resultSerializer(): KSerializer<ExtendedChat> = ExtendedChatSerializer
|
override fun resultDeserializer(): KSerializer<ExtendedChat> = ExtendedChatSerializer
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberSerializerWithoutDeserialization
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
@ -12,7 +13,9 @@ import kotlinx.serialization.internal.ArrayListSerializer
|
|||||||
data class GetChatAdministrators(
|
data class GetChatAdministrators(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<List<RawChatMember>> {
|
): ChatRequest, SimpleRequest<List<ChatMember>> {
|
||||||
override fun method(): String = "getChatAdministrators"
|
override fun method(): String = "getChatAdministrators"
|
||||||
override fun resultSerializer(): KSerializer<List<RawChatMember>> = ArrayListSerializer(RawChatMember.serializer())
|
override fun resultDeserializer(): KSerializer<List<ChatMember>> = ArrayListSerializer(
|
||||||
|
ChatMemberSerializerWithoutDeserialization
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ data class GetChatMembersCount(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Int> {
|
): ChatRequest, SimpleRequest<Int> {
|
||||||
override fun method(): String = "getChatMembersCount"
|
override fun method(): String = "getChatMembersCount"
|
||||||
override fun resultSerializer(): KSerializer<Int> = IntSerializer
|
override fun resultDeserializer(): KSerializer<Int> = IntSerializer
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -11,7 +12,7 @@ data class GetChatMember(
|
|||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
override val userId: UserId
|
override val userId: UserId
|
||||||
) : ChatMemberRequest<RawChatMember> {
|
) : ChatMemberRequest<ChatMember> {
|
||||||
override fun method(): String = "getChatMember"
|
override fun method(): String = "getChatMember"
|
||||||
override fun resultSerializer(): KSerializer<RawChatMember> = RawChatMember.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<ChatMember> = ChatMemberDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,5 @@ data class KickChatMember(
|
|||||||
override val untilDate: TelegramDate? = null
|
override val untilDate: TelegramDate? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "kickChatMember"
|
override fun method(): String = "kickChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,5 @@ data class PromoteChatMember(
|
|||||||
private val canPromoteMembers: Boolean? = null
|
private val canPromoteMembers: Boolean? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "promoteChatMember"
|
override fun method(): String = "promoteChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@ data class RestrictChatMember(
|
|||||||
val permissions: ChatPermissions
|
val permissions: ChatPermissions
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "restrictChatMember"
|
override fun method(): String = "restrictChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ data class UnbanChatMember(
|
|||||||
override val userId: UserId
|
override val userId: UserId
|
||||||
) : ChatMemberRequest<Boolean> {
|
) : ChatMemberRequest<Boolean> {
|
||||||
override fun method(): String = "unbanChatMember"
|
override fun method(): String = "unbanChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ data class DeleteChatPhoto(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteChatPhoto"
|
override fun method(): String = "deleteChatPhoto"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,5 @@ data class PinChatMessage (
|
|||||||
override val disableNotification: Boolean = false
|
override val disableNotification: Boolean = false
|
||||||
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
||||||
override fun method(): String = "pinChatMessage"
|
override fun method(): String = "pinChatMessage"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@ data class SetChatDescription (
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "setChatDescription"
|
override fun method(): String = "setChatDescription"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,5 @@ data class SetChatPermissions (
|
|||||||
val permissions: ChatPermissions
|
val permissions: ChatPermissions
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "setChatPermissions"
|
override fun method(): String = "setChatPermissions"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ data class SetChatPhoto (
|
|||||||
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
|
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
|
||||||
): ChatRequest, MultipartRequest<Boolean> {
|
): ChatRequest, MultipartRequest<Boolean> {
|
||||||
override fun method(): String = "setChatPhoto"
|
override fun method(): String = "setChatPhoto"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
||||||
override val paramsJson: JsonObject = toJson(serializer())
|
override val paramsJson: JsonObject = toJson(serializer())
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@ data class SetChatTitle (
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "setChatTitle"
|
override fun method(): String = "setChatTitle"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ data class UnpinChatMessage(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "unpinChatMessage"
|
override fun method(): String = "unpinChatMessage"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ data class DeleteChatStickerSet(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteChatStickerSet"
|
override fun method(): String = "deleteChatStickerSet"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,5 @@ data class SetChatStickerSet(
|
|||||||
val stickerSetName: StickerSetName
|
val stickerSetName: StickerSetName
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "setChatStickerSet"
|
override fun method(): String = "setChatStickerSet"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -20,5 +21,5 @@ data class EditChatMessageLiveLocation(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
override fun method(): String = "editMessageLiveLocation"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditCh
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -17,5 +18,5 @@ data class StopChatMessageLiveLocation(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage {
|
) : EditChatMessage, EditReplyMessage {
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
override fun method(): String = "stopMessageLiveLocation"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditCh
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
||||||
@ -20,5 +21,5 @@ data class EditChatMessageReplyMarkup(
|
|||||||
) : EditChatMessage, EditReplyMessage {
|
) : EditChatMessage, EditReplyMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageReplyMarkupMethod
|
override fun method(): String = editMessageReplyMarkupMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
interface EditChatMessage : SimpleRequest<RawMessage>, MessageAction
|
interface EditChatMessage : SimpleRequest<Message>, MessageAction
|
||||||
|
@ -7,5 +7,5 @@ import kotlinx.serialization.internal.BooleanSerializer
|
|||||||
|
|
||||||
interface EditInlineMessage : SimpleRequest<Boolean> {
|
interface EditInlineMessage : SimpleRequest<Boolean> {
|
||||||
val inlineMessageId: InlineMessageIdentifier
|
val inlineMessageId: InlineMessageIdentifier
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageCaptionMethod = "editMessageCaption"
|
const val editMessageCaptionMethod = "editMessageCaption"
|
||||||
@ -25,5 +26,5 @@ data class EditChatMessageCaption(
|
|||||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageCaptionMethod
|
override fun method(): String = editMessageCaptionMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageMediaMethod = "editMessageMedia"
|
const val editMessageMediaMethod = "editMessageMedia"
|
||||||
@ -29,5 +30,5 @@ data class EditChatMessageMedia(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = editMessageMediaMethod
|
override fun method(): String = editMessageMediaMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageTextMethod = "editMessageText"
|
const val editMessageTextMethod = "editMessageText"
|
||||||
@ -27,5 +28,5 @@ data class EditChatMessageText(
|
|||||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageTextMethod
|
override fun method(): String = editMessageTextMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
|||||||
val userId: UserId
|
val userId: UserId
|
||||||
|
|
||||||
override fun method(): String = "getGameHighScores"
|
override fun method(): String = "getGameHighScores"
|
||||||
override fun resultSerializer(): KSerializer<List<GameHighScore>> = GameHighScoresSerializer
|
override fun resultDeserializer(): KSerializer<List<GameHighScore>> = GameHighScoresSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())
|
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())
|
||||||
|
@ -12,5 +12,5 @@ interface SetGameScore : SimpleRequest<Boolean> {
|
|||||||
val disableEditMessage: Boolean
|
val disableEditMessage: Boolean
|
||||||
|
|
||||||
override fun method(): String = "setGameScore"
|
override fun method(): String = "setGameScore"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||||
}
|
}
|
@ -12,5 +12,5 @@ data class GetFile(
|
|||||||
val fileId: FileId
|
val fileId: FileId
|
||||||
): SimpleRequest<PathedFile> {
|
): SimpleRequest<PathedFile> {
|
||||||
override fun method(): String = "getFile"
|
override fun method(): String = "getFile"
|
||||||
override fun resultSerializer(): KSerializer<PathedFile> = PathedFile.serializer()
|
override fun resultDeserializer(): KSerializer<PathedFile> = PathedFile.serializer()
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,5 @@ data class GetStickerSet(
|
|||||||
val name: String
|
val name: String
|
||||||
): SimpleRequest<StickerSet> {
|
): SimpleRequest<StickerSet> {
|
||||||
override fun method(): String = "getStickerSet"
|
override fun method(): String = "getStickerSet"
|
||||||
override fun resultSerializer(): KSerializer<StickerSet> = StickerSet.serializer()
|
override fun resultDeserializer(): KSerializer<StickerSet> = StickerSet.serializer()
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,5 @@ data class GetUserProfilePhotos(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "getUserProfilePhotos"
|
override fun method(): String = "getUserProfilePhotos"
|
||||||
override fun resultSerializer(): KSerializer<UserProfilePhotos> = UserProfilePhotos.serializer()
|
override fun resultDeserializer(): KSerializer<UserProfilePhotos> = UserProfilePhotos.serializer()
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,5 @@ data class SendAction(
|
|||||||
val action: BotAction
|
val action: BotAction
|
||||||
): SendChatMessageRequest<Boolean> {
|
): SendChatMessageRequest<Boolean> {
|
||||||
override fun method(): String = "sendChatAction"
|
override fun method(): String = "sendChatAction"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.Replyi
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -23,8 +24,8 @@ data class SendContact(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<RawMessage>,
|
) : SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>
|
ReplyingMarkupSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@ -43,7 +44,7 @@ data class SendContact(
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun method(): String = "sendContact"
|
override fun method(): String = "sendContact"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Contact.toRequest(
|
fun Contact.toRequest(
|
||||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
// TODO:: Add location tracker for tracking location
|
// TODO:: Add location tracker for tracking location
|
||||||
@ -23,11 +24,11 @@ data class SendLocation(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<RawMessage>,
|
) : SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
PositionedSendMessageRequest<RawMessage>
|
PositionedSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
|
|
||||||
override fun method(): String = "sendLocation"
|
override fun method(): String = "sendLocation"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -25,9 +26,9 @@ data class SendMessage(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<RawMessage>,
|
) : SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>,
|
TextableSendMessageRequest<Message>,
|
||||||
DisableWebPagePreview
|
DisableWebPagePreview
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
@ -37,5 +38,5 @@ data class SendMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendMessage"
|
override fun method(): String = "sendMessage"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.Replyi
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -21,8 +22,8 @@ data class SendPoll(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<RawMessage>,
|
) : SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage> {
|
ReplyingMarkupSendMessageRequest<Message> {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (question.length !in pollQuestionTextLength) {
|
if (question.length !in pollQuestionTextLength) {
|
||||||
@ -39,5 +40,5 @@ data class SendPoll(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendPoll"
|
override fun method(): String = "sendPoll"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -26,10 +27,10 @@ data class SendVenue(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<RawMessage>,
|
) : SendMessageRequest<Message>,
|
||||||
PositionedSendMessageRequest<RawMessage>,
|
PositionedSendMessageRequest<Message>,
|
||||||
TitledSendMessageRequest<RawMessage>,
|
TitledSendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>
|
ReplyingMarkupSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@ -50,7 +51,7 @@ data class SendVenue(
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun method(): String = "sendVenue"
|
override fun method(): String = "sendVenue"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Venue.toRequest(
|
fun Venue.toRequest(
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMar
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -19,8 +20,8 @@ data class SendGame (
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<RawMessage>,
|
) : SendMessageRequest<Message>,
|
||||||
ReplyMarkup {
|
ReplyMarkup {
|
||||||
override fun method(): String = "sendGame"
|
override fun method(): String = "sendGame"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
@ -7,7 +7,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ fun SendAnimation(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> {
|
): Request<Message> {
|
||||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
val animationAsFileId = (animation as? FileId) ?.fileId
|
||||||
val animationAsFile = animation as? MultipartFile
|
val animationAsFile = animation as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||||
@ -77,13 +78,13 @@ data class SendAnimationData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : DataRequest<RawMessage>,
|
) : DataRequest<Message>,
|
||||||
SendMessageRequest<RawMessage>,
|
SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>,
|
TextableSendMessageRequest<Message>,
|
||||||
ThumbedSendMessageRequest<RawMessage>,
|
ThumbedSendMessageRequest<Message>,
|
||||||
DuratedSendMessageRequest<RawMessage>,
|
DuratedSendMessageRequest<Message>,
|
||||||
SizedSendMessageRequest<RawMessage>
|
SizedSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -94,7 +95,7 @@ data class SendAnimationData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendAnimation"
|
override fun method(): String = "sendAnimation"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendAnimationFiles internal constructor(
|
data class SendAnimationFiles internal constructor(
|
||||||
|
@ -8,7 +8,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ fun SendAudio(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> {
|
): Request<Message> {
|
||||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
val audioAsFileId = (audio as? FileId) ?.fileId
|
||||||
val audioAsFile = audio as? MultipartFile
|
val audioAsFile = audio as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||||
@ -78,13 +79,13 @@ data class SendAudioData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : DataRequest<RawMessage>,
|
) : DataRequest<Message>,
|
||||||
SendMessageRequest<RawMessage>,
|
SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>,
|
TextableSendMessageRequest<Message>,
|
||||||
ThumbedSendMessageRequest<RawMessage>,
|
ThumbedSendMessageRequest<Message>,
|
||||||
TitledSendMessageRequest<RawMessage>,
|
TitledSendMessageRequest<Message>,
|
||||||
DuratedSendMessageRequest<RawMessage>,
|
DuratedSendMessageRequest<Message>,
|
||||||
Performerable
|
Performerable
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
@ -96,7 +97,7 @@ data class SendAudioData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendAudio"
|
override fun method(): String = "sendAudio"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendAudioFiles internal constructor(
|
data class SendAudioFiles internal constructor(
|
||||||
|
@ -7,7 +7,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ fun SendDocument(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> {
|
): Request<Message> {
|
||||||
val documentAsFileId = (document as? FileId) ?.fileId
|
val documentAsFileId = (document as? FileId) ?.fileId
|
||||||
val documentAsFile = document as? MultipartFile
|
val documentAsFile = document as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||||
@ -65,11 +66,11 @@ data class SendDocumentData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : DataRequest<RawMessage>,
|
) : DataRequest<Message>,
|
||||||
SendMessageRequest<RawMessage>,
|
SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>,
|
TextableSendMessageRequest<Message>,
|
||||||
ThumbedSendMessageRequest<RawMessage>
|
ThumbedSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -80,7 +81,7 @@ data class SendDocumentData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendDocument"
|
override fun method(): String = "sendDocument"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendDocumentFiles internal constructor(
|
data class SendDocumentFiles internal constructor(
|
||||||
|
@ -6,7 +6,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMe
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
@ -19,7 +20,7 @@ fun SendMediaGroup(
|
|||||||
media: List<MediaGroupMemberInputMedia>,
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null
|
replyToMessageId: MessageIdentifier? = null
|
||||||
): Request<List<RawMessage>> {
|
): Request<List<Message>> {
|
||||||
if (media.size !in membersCountInMediaGroup) {
|
if (media.size !in membersCountInMediaGroup) {
|
||||||
throw IllegalArgumentException("Count of members for media group must be in $membersCountInMediaGroup range")
|
throw IllegalArgumentException("Count of members for media group must be in $membersCountInMediaGroup range")
|
||||||
}
|
}
|
||||||
@ -52,7 +53,7 @@ fun SendMediaGroup(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val serializer = ArrayListSerializer(RawMessage.serializer())
|
private val serializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendMediaGroupData internal constructor(
|
data class SendMediaGroupData internal constructor(
|
||||||
@ -63,8 +64,8 @@ data class SendMediaGroupData internal constructor(
|
|||||||
override val disableNotification: Boolean = false,
|
override val disableNotification: Boolean = false,
|
||||||
@SerialName(replyToMessageIdField)
|
@SerialName(replyToMessageIdField)
|
||||||
override val replyToMessageId: MessageIdentifier? = null
|
override val replyToMessageId: MessageIdentifier? = null
|
||||||
) : DataRequest<List<RawMessage>>,
|
) : DataRequest<List<Message>>,
|
||||||
SendMessageRequest<List<RawMessage>>
|
SendMessageRequest<List<Message>>
|
||||||
{
|
{
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
private val convertedMedia: String
|
private val convertedMedia: String
|
||||||
@ -76,7 +77,7 @@ data class SendMediaGroupData internal constructor(
|
|||||||
|
|
||||||
|
|
||||||
override fun method(): String = "sendMediaGroup"
|
override fun method(): String = "sendMediaGroup"
|
||||||
override fun resultSerializer(): KSerializer<List<RawMessage>> = serializer
|
override fun resultDeserializer(): DeserializationStrategy<List<Message>> = serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendMediaGroupFiles internal constructor(
|
data class SendMediaGroupFiles internal constructor(
|
||||||
|
@ -7,7 +7,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun SendPhoto(
|
fun SendPhoto(
|
||||||
@ -18,7 +19,7 @@ fun SendPhoto(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> {
|
): Request<Message> {
|
||||||
val data = SendPhotoData(
|
val data = SendPhotoData(
|
||||||
chatId,
|
chatId,
|
||||||
(photo as? FileId) ?.fileId,
|
(photo as? FileId) ?.fileId,
|
||||||
@ -52,10 +53,10 @@ data class SendPhotoData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : DataRequest<RawMessage>,
|
) : DataRequest<Message>,
|
||||||
SendMessageRequest<RawMessage>,
|
SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>
|
TextableSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -66,7 +67,7 @@ data class SendPhotoData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendPhoto"
|
override fun method(): String = "sendPhoto"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendPhotoFiles internal constructor(
|
data class SendPhotoFiles internal constructor(
|
||||||
|
@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.Replyi
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
@ -16,7 +17,7 @@ fun SendSticker(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> = SendStickerByFileId(
|
): Request<Message> = SendStickerByFileId(
|
||||||
chatId,
|
chatId,
|
||||||
sticker as? FileId,
|
sticker as? FileId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
@ -41,16 +42,16 @@ data class SendStickerByFileId internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<RawMessage> {
|
) : SendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<Message> {
|
||||||
override fun method(): String = "sendSticker"
|
override fun method(): String = "sendSticker"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendStickerByFile internal constructor(
|
data class SendStickerByFile internal constructor(
|
||||||
@Transient
|
@Transient
|
||||||
private val sendStickerByFileId: SendStickerByFileId,
|
private val sendStickerByFileId: SendStickerByFileId,
|
||||||
val sticker: MultipartFile
|
val sticker: MultipartFile
|
||||||
) : MultipartRequest<RawMessage>, Request<RawMessage> by sendStickerByFileId {
|
) : MultipartRequest<Message>, Request<Message> by sendStickerByFileId {
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
||||||
override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ fun SendVideo(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> {
|
): Request<Message> {
|
||||||
val videoAsFileId = (video as? FileId) ?.fileId
|
val videoAsFileId = (video as? FileId) ?.fileId
|
||||||
val videoAsFile = video as? MultipartFile
|
val videoAsFile = video as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||||
@ -81,13 +82,13 @@ data class SendVideoData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : DataRequest<RawMessage>,
|
) : DataRequest<Message>,
|
||||||
SendMessageRequest<RawMessage>,
|
SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>,
|
TextableSendMessageRequest<Message>,
|
||||||
ThumbedSendMessageRequest<RawMessage>,
|
ThumbedSendMessageRequest<Message>,
|
||||||
DuratedSendMessageRequest<RawMessage>,
|
DuratedSendMessageRequest<Message>,
|
||||||
SizedSendMessageRequest<RawMessage>
|
SizedSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -98,7 +99,7 @@ data class SendVideoData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendVideo"
|
override fun method(): String = "sendVideo"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendVideoFiles internal constructor(
|
data class SendVideoFiles internal constructor(
|
||||||
|
@ -7,7 +7,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ fun SendVideoNote(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> {
|
): Request<Message> {
|
||||||
val videoNoteAsFileId = (videoNote as? FileId) ?.fileId
|
val videoNoteAsFileId = (videoNote as? FileId) ?.fileId
|
||||||
val videoNoteAsFile = videoNote as? MultipartFile
|
val videoNoteAsFile = videoNote as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||||
@ -73,13 +74,13 @@ data class SendVideoNoteData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : DataRequest<RawMessage>,
|
) : DataRequest<Message>,
|
||||||
SendMessageRequest<RawMessage>,
|
SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>,
|
TextableSendMessageRequest<Message>,
|
||||||
ThumbedSendMessageRequest<RawMessage>,
|
ThumbedSendMessageRequest<Message>,
|
||||||
DuratedSendMessageRequest<RawMessage>,
|
DuratedSendMessageRequest<Message>,
|
||||||
SizedSendMessageRequest<RawMessage>
|
SizedSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
@Transient
|
@Transient
|
||||||
override val height: Int?
|
override val height: Int?
|
||||||
@ -94,7 +95,7 @@ data class SendVideoNoteData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendVideoNote"
|
override fun method(): String = "sendVideoNote"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendVideoNoteFiles internal constructor(
|
data class SendVideoNoteFiles internal constructor(
|
||||||
|
@ -7,7 +7,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ fun SendVoice(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage> {
|
): Request<Message> {
|
||||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
val voiceAsFileId = (voice as? FileId) ?.fileId
|
||||||
val voiceAsFile = voice as? MultipartFile
|
val voiceAsFile = voice as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||||
@ -69,12 +70,12 @@ data class SendVoiceData internal constructor(
|
|||||||
override val replyToMessageId: MessageIdentifier? = null,
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : DataRequest<RawMessage>,
|
) : DataRequest<Message>,
|
||||||
SendMessageRequest<RawMessage>,
|
SendMessageRequest<Message>,
|
||||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
ReplyingMarkupSendMessageRequest<Message>,
|
||||||
TextableSendMessageRequest<RawMessage>,
|
TextableSendMessageRequest<Message>,
|
||||||
ThumbedSendMessageRequest<RawMessage>,
|
ThumbedSendMessageRequest<Message>,
|
||||||
DuratedSendMessageRequest<RawMessage>
|
DuratedSendMessageRequest<Message>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -85,7 +86,7 @@ data class SendVoiceData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendVoice"
|
override fun method(): String = "sendVoice"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendVoiceFiles internal constructor(
|
data class SendVoiceFiles internal constructor(
|
||||||
|
@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,7 +13,7 @@ class MultipartRequestImpl<D: DataRequest<R>, F: Files, R: Any>(
|
|||||||
val files: F
|
val files: F
|
||||||
) : MultipartRequest<R> {
|
) : MultipartRequest<R> {
|
||||||
override fun method(): String = data.method()
|
override fun method(): String = data.method()
|
||||||
override fun resultSerializer(): KSerializer<R> = data.resultSerializer()
|
override fun resultDeserializer(): DeserializationStrategy<R> = data.resultDeserializer()
|
||||||
override val paramsJson: JsonObject = data.json()
|
override val paramsJson: JsonObject = data.json()
|
||||||
override val mediaMap: Map<String, MultipartFile> = files
|
override val mediaMap: Map<String, MultipartFile> = files
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.*
|
||||||
@ -62,9 +63,9 @@ data class SendInvoice(
|
|||||||
DisableNotification,
|
DisableNotification,
|
||||||
ReplyMessageId,
|
ReplyMessageId,
|
||||||
ReplyMarkup,
|
ReplyMarkup,
|
||||||
SendMessageRequest<RawMessage> {
|
SendMessageRequest<Message> {
|
||||||
override fun method(): String = "sendInvoice"
|
override fun method(): String = "sendInvoice"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
|
||||||
@SerialName(photoUrlField)
|
@SerialName(photoUrlField)
|
||||||
var photoUrl: String? = null
|
var photoUrl: String? = null
|
||||||
|
@ -12,5 +12,5 @@ data class DeleteStickerFromSet(
|
|||||||
val sticker: FileId
|
val sticker: FileId
|
||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteStickerFromSet"
|
override fun method(): String = "deleteStickerFromSet"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,5 @@ data class SetStickerPositionInSet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "setStickerPositionInSet"
|
override fun method(): String = "setStickerPositionInSet"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,5 @@ data class UploadStickerFile(
|
|||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker)
|
||||||
@Transient
|
@Transient
|
||||||
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
||||||
override fun resultSerializer(): KSerializer<File> = File.serializer()
|
override fun resultDeserializer(): KSerializer<File> = File.serializer()
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@ interface StickerSetAction : SimpleRequest<Boolean> {
|
|||||||
val emojis: String // must be more than one
|
val emojis: String // must be more than one
|
||||||
val maskPosition: MaskPosition?
|
val maskPosition: MaskPosition?
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
@ -9,5 +9,5 @@ import kotlinx.serialization.internal.BooleanSerializer
|
|||||||
class DeleteWebhook : SimpleRequest<Boolean> {
|
class DeleteWebhook : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteWebhook"
|
override fun method(): String = "deleteWebhook"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,5 @@ import kotlinx.serialization.Serializable
|
|||||||
class GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
class GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
||||||
override fun method(): String = "getWebhookInfo"
|
override fun method(): String = "getWebhookInfo"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer()
|
override fun resultDeserializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer()
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ data class SetWebhook internal constructor(
|
|||||||
val allowedUpdates: List<String>? = null
|
val allowedUpdates: List<String>? = null
|
||||||
) : DataRequest<Boolean> {
|
) : DataRequest<Boolean> {
|
||||||
override fun method(): String = "setWebhook"
|
override fun method(): String = "setWebhook"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
|
|
||||||
init {
|
init {
|
||||||
maxAllowedConnections ?.let {
|
maxAllowedConnections ?.let {
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawCallbackQuery(
|
internal data class RawCallbackQuery(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
val id: CallbackQueryIdentifier,
|
val id: CallbackQueryIdentifier,
|
||||||
@SerialName(fromField)
|
@SerialName(fromField)
|
||||||
val from: User,
|
val from: User,
|
||||||
val message: RawMessage? = null,
|
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||||
|
val message: Message? = null,
|
||||||
@SerialName(inlineMessageIdField)
|
@SerialName(inlineMessageIdField)
|
||||||
val inlineMessageId: InlineMessageIdentifier? = null,
|
val inlineMessageId: InlineMessageIdentifier? = null,
|
||||||
@SerialName("chat_instance")
|
@SerialName("chat_instance")
|
||||||
@ -22,8 +24,8 @@ data class RawCallbackQuery(
|
|||||||
@Transient
|
@Transient
|
||||||
val asCallbackQuery: CallbackQuery by lazy {
|
val asCallbackQuery: CallbackQuery by lazy {
|
||||||
when {
|
when {
|
||||||
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message.asMessage, data)
|
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data)
|
||||||
message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message.asMessage, gameShortName)
|
message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName)
|
||||||
inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data)
|
inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data)
|
||||||
inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName)
|
inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName)
|
||||||
else -> throw IllegalStateException("Strange answer from server, can't create callback query")
|
else -> throw IllegalStateException("Strange answer from server, can't create callback query")
|
||||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.Cha
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawChatMember(
|
internal data class RawChatMember(
|
||||||
val user: User,
|
val user: User,
|
||||||
private val status: String,
|
private val status: String,
|
||||||
private val until_date: TelegramDate? = null,
|
private val until_date: TelegramDate? = null,
|
||||||
|
@ -1,7 +1,24 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
interface ChatMember {
|
interface ChatMember {
|
||||||
val user: User
|
val user: User
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal object ChatMemberSerializerWithoutDeserialization : KSerializer<ChatMember> {
|
||||||
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): ChatMember = ChatMemberDeserializationStrategy.deserialize(decoder)
|
||||||
|
override fun serialize(encoder: Encoder, obj: ChatMember) = throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
||||||
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberDeserializationStrategy")
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember
|
||||||
|
override fun patch(decoder: Decoder, old: ChatMember): ChatMember = throw UpdateNotSupportedException(descriptor.name)
|
||||||
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawChosenInlineResult(
|
internal data class RawChosenInlineResult(
|
||||||
@SerialName(resultIdField)
|
@SerialName(resultIdField)
|
||||||
val resultId: InlineQueryIdentifier, //chosen temporary, can be changed
|
val resultId: InlineQueryIdentifier, //chosen temporary, can be changed
|
||||||
@SerialName(fromField)
|
@SerialName(fromField)
|
||||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawInlineQuery(
|
internal data class RawInlineQuery(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
val id: InlineQueryIdentifier,
|
val id: InlineQueryIdentifier,
|
||||||
@SerialName(fromField)
|
@SerialName(fromField)
|
||||||
|
@ -6,7 +6,7 @@ import kotlinx.serialization.Serializable
|
|||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawMessageEntity(
|
internal data class RawMessageEntity(
|
||||||
val type: String,
|
val type: String,
|
||||||
val offset: Int,
|
val offset: Int,
|
||||||
val length: Int,
|
val length: Int,
|
||||||
@ -34,8 +34,8 @@ data class RawMessageEntity(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias RawMessageEntities = List<RawMessageEntity>
|
internal typealias RawMessageEntities = List<RawMessageEntity>
|
||||||
|
|
||||||
object RawMessageEntitiesSerializer : KSerializer<List<RawMessageEntity>> by ArrayListSerializer(
|
internal object RawMessageEntitiesSerializer : KSerializer<List<RawMessageEntity>> by ArrayListSerializer(
|
||||||
RawMessageEntity.serializer()
|
RawMessageEntity.serializer()
|
||||||
)
|
)
|
||||||
|
@ -2,19 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types
|
|||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.json.JsonElement
|
||||||
@Deprecated(
|
|
||||||
"Deprecated because incorrect name",
|
|
||||||
ReplaceWith("Response")
|
|
||||||
)
|
|
||||||
typealias ResponseParameters<T> = Response<T>
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Response<T : Any>(
|
data class Response(
|
||||||
val ok: Boolean = false,
|
val ok: Boolean = false,
|
||||||
val description: String? = null,
|
val description: String? = null,
|
||||||
@SerialName("error_code")
|
@SerialName("error_code")
|
||||||
val errorCode: Int? = null,
|
val errorCode: Int? = null,
|
||||||
val result: T? = null,
|
val result: JsonElement? = null,
|
||||||
val parameters: ResponseParametersRaw? = null
|
val parameters: ResponseParametersRaw? = null
|
||||||
)
|
)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
interface ExtendedPublicChat : ExtendedChat, PublicChat {
|
interface ExtendedPublicChat : ExtendedChat, PublicChat {
|
||||||
val description: String
|
val description: String
|
||||||
val inviteLink: String?
|
val inviteLink: String?
|
||||||
val pinnedMessage: RawMessage?
|
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||||
|
val pinnedMessage: Message?
|
||||||
}
|
}
|
@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChannelChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChannelChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -21,5 +22,6 @@ data class ExtendedChannelChatImpl(
|
|||||||
@SerialName(inviteLinkField)
|
@SerialName(inviteLinkField)
|
||||||
override val inviteLink: String? = null,
|
override val inviteLink: String? = null,
|
||||||
@SerialName(pinnedMessageField)
|
@SerialName(pinnedMessageField)
|
||||||
override val pinnedMessage: RawMessage? = null
|
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||||
|
override val pinnedMessage: Message? = null
|
||||||
) : ExtendedChannelChat
|
) : ExtendedChannelChat
|
||||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedGroupChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedGroupChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -22,5 +23,6 @@ data class ExtendedGroupChatImpl(
|
|||||||
@SerialName(inviteLinkField)
|
@SerialName(inviteLinkField)
|
||||||
override val inviteLink: String? = null,
|
override val inviteLink: String? = null,
|
||||||
@SerialName(pinnedMessageField)
|
@SerialName(pinnedMessageField)
|
||||||
override val pinnedMessage: RawMessage? = null
|
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||||
|
override val pinnedMessage: Message? = null
|
||||||
) : ExtendedGroupChat
|
) : ExtendedGroupChat
|
||||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedSupergroupChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedSupergroupChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -24,7 +25,8 @@ data class ExtendedSupergroupChatImpl(
|
|||||||
@SerialName(inviteLinkField)
|
@SerialName(inviteLinkField)
|
||||||
override val inviteLink: String? = null,
|
override val inviteLink: String? = null,
|
||||||
@SerialName(pinnedMessageField)
|
@SerialName(pinnedMessageField)
|
||||||
override val pinnedMessage: RawMessage? = null,
|
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||||
|
override val pinnedMessage: Message? = null,
|
||||||
@SerialName(stickerSetNameFullField)
|
@SerialName(stickerSetNameFullField)
|
||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(canSetStickerSetField)
|
@SerialName(canSetStickerSetField)
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.files
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.*
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class TelegramFile(
|
|
||||||
@SerialName(fileIdField)
|
|
||||||
override val fileId: FileId,
|
|
||||||
@SerialName(fileSizeField)
|
|
||||||
override val fileSize: Long? = null,
|
|
||||||
@SerialName("file_path")
|
|
||||||
val filePath: String? = null
|
|
||||||
) : TelegramMediaFile
|
|
@ -1,31 +1,33 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.games
|
package com.github.insanusmokrassar.TelegramBotAPI.types.games
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.*
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Titled
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import kotlinx.serialization.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo
|
||||||
|
import kotlinx.serialization.Transient
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Game(
|
data class Game(
|
||||||
@SerialName(titleField)
|
override val title: String,
|
||||||
val title: String,
|
|
||||||
@SerialName(descriptionField)
|
|
||||||
val description: String,
|
val description: String,
|
||||||
@Serializable(PhotoSerializer::class)
|
|
||||||
@SerialName(photoField)
|
|
||||||
val photo: Photo,
|
val photo: Photo,
|
||||||
@SerialName(textField)
|
override val caption: String? = null,
|
||||||
val text: String? = null,
|
override val captionEntities: List<MessageEntity> = emptyList(),
|
||||||
@Serializable(RawMessageEntitiesSerializer::class)
|
|
||||||
@SerialName(textEntitiesField)
|
|
||||||
private val textEntitiesRaw: RawMessageEntities? = null,
|
|
||||||
@SerialName(animationField)
|
|
||||||
val animation: AnimationFile? = null
|
val animation: AnimationFile? = null
|
||||||
) {
|
) : Titled, CaptionedInput {
|
||||||
|
@Deprecated(
|
||||||
|
"Missinterfaced field",
|
||||||
|
ReplaceWith("caption")
|
||||||
|
)
|
||||||
@Transient
|
@Transient
|
||||||
val textEntities: List<MessageEntity>? = text ?.let {
|
val text: String?
|
||||||
textEntitiesRaw ?.map {
|
get() = caption
|
||||||
it.asMessageEntity(text)
|
|
||||||
}
|
@Deprecated(
|
||||||
}
|
"Missinterfaced field",
|
||||||
|
ReplaceWith("captionEntities")
|
||||||
|
)
|
||||||
|
@Transient
|
||||||
|
val textEntities: List<MessageEntity>?
|
||||||
|
get() = captionEntities
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.games
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
internal data class RawGame(
|
||||||
|
@SerialName(titleField)
|
||||||
|
private val title: String,
|
||||||
|
@SerialName(descriptionField)
|
||||||
|
private val description: String,
|
||||||
|
@Serializable(PhotoSerializer::class)
|
||||||
|
@SerialName(photoField)
|
||||||
|
private val photo: Photo,
|
||||||
|
@SerialName(textField)
|
||||||
|
private val caption: String? = null,
|
||||||
|
@SerialName(textEntitiesField)
|
||||||
|
private val captionEntities: RawMessageEntities = emptyList(),
|
||||||
|
@SerialName(animationField)
|
||||||
|
private val animation: AnimationFile? = null
|
||||||
|
) {
|
||||||
|
@Transient
|
||||||
|
val asGame = Game(
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
photo,
|
||||||
|
caption,
|
||||||
|
caption ?.let { _ -> captionEntities.map { it.asMessageEntity(caption) } } ?: emptyList(),
|
||||||
|
animation
|
||||||
|
)
|
||||||
|
}
|
@ -2,11 +2,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntitiesSerializer
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
import com.github.insanusmokrassar.TelegramBotAPI.types.games.RawGame
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
@ -24,7 +23,7 @@ import kotlin.reflect.KClass
|
|||||||
|
|
||||||
// TODO:: add PassportData type
|
// TODO:: add PassportData type
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawMessage(
|
internal data class RawMessage(
|
||||||
@SerialName(messageIdField)
|
@SerialName(messageIdField)
|
||||||
val messageId: MessageIdentifier,
|
val messageId: MessageIdentifier,
|
||||||
@SerialName(dateField)
|
@SerialName(dateField)
|
||||||
@ -44,15 +43,13 @@ data class RawMessage(
|
|||||||
private val media_group_id: MediaGroupIdentifier? = null,
|
private val media_group_id: MediaGroupIdentifier? = null,
|
||||||
private val author_signature: AuthorSignature? = null,
|
private val author_signature: AuthorSignature? = null,
|
||||||
private val text: String? = null,
|
private val text: String? = null,
|
||||||
@Serializable(RawMessageEntitiesSerializer::class)
|
|
||||||
private val entities: RawMessageEntities? = null,
|
private val entities: RawMessageEntities? = null,
|
||||||
private val caption: String? = null,
|
private val caption: String? = null,
|
||||||
@Serializable(RawMessageEntitiesSerializer::class)
|
|
||||||
private val caption_entities: RawMessageEntities? = null,
|
private val caption_entities: RawMessageEntities? = null,
|
||||||
private val audio: AudioFile? = null,
|
private val audio: AudioFile? = null,
|
||||||
private val document: DocumentFile? = null,
|
private val document: DocumentFile? = null,
|
||||||
private val animation: AnimationFile? = null,
|
private val animation: AnimationFile? = null,
|
||||||
private val game: Game? = null,
|
private val game: RawGame? = null,
|
||||||
@Serializable(PhotoSerializer::class)
|
@Serializable(PhotoSerializer::class)
|
||||||
private val photo: Photo? = null,
|
private val photo: Photo? = null,
|
||||||
private val sticker: Sticker? = null,
|
private val sticker: Sticker? = null,
|
||||||
@ -128,7 +125,7 @@ data class RawMessage(
|
|||||||
adaptedCaptionEntities
|
adaptedCaptionEntities
|
||||||
)
|
)
|
||||||
sticker != null -> StickerContent(sticker)
|
sticker != null -> StickerContent(sticker)
|
||||||
game != null -> GameContent(game)
|
game != null -> GameContent(game.asGame)
|
||||||
video_note != null -> VideoNoteContent(video_note)
|
video_note != null -> VideoNoteContent(video_note)
|
||||||
contact != null -> ContactContent(contact)
|
contact != null -> ContactContent(contact)
|
||||||
location != null -> LocationContent(location)
|
location != null -> LocationContent(location)
|
||||||
|
@ -2,6 +2,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
interface Message {
|
interface Message {
|
||||||
@ -9,3 +12,25 @@ interface Message {
|
|||||||
val chat: Chat
|
val chat: Chat
|
||||||
val date: DateTime
|
val date: DateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal object TelegramBotAPIMessageDeserializationStrategy : DeserializationStrategy<Message> {
|
||||||
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer")
|
||||||
|
|
||||||
|
override fun patch(decoder: Decoder, old: Message): Message = throw UpdateNotSupportedException(descriptor.name)
|
||||||
|
override fun deserialize(decoder: Decoder): Message {
|
||||||
|
return RawMessage.serializer().deserialize(decoder).asMessage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal object TelegramBotAPIMessageDeserializeOnlySerializer : KSerializer<Message> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy.descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): Message {
|
||||||
|
return TelegramBotAPIMessageDeserializationStrategy.deserialize(decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, obj: Message) {
|
||||||
|
throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendContact
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendContact
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
|
||||||
data class ContactContent(
|
data class ContactContent(
|
||||||
@ -15,7 +15,7 @@ data class ContactContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendContact(
|
): Request<Message> = SendContact(
|
||||||
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
|
||||||
data class GameContent(
|
data class GameContent(
|
||||||
@ -17,7 +17,7 @@ data class GameContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendGame(
|
): Request<Message> = SendGame(
|
||||||
chatId,
|
chatId,
|
||||||
game.title,
|
game.title,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
|
||||||
data class LocationContent(
|
data class LocationContent(
|
||||||
@ -15,7 +15,7 @@ data class LocationContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendLocation(
|
): Request<Message> = SendLocation(
|
||||||
chatId,
|
chatId,
|
||||||
location.latitude,
|
location.latitude,
|
||||||
location.longitude,
|
location.longitude,
|
||||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendPoll
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ data class PollContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendPoll(
|
): Request<Message> = SendPoll(
|
||||||
chatId,
|
chatId,
|
||||||
poll.question,
|
poll.question,
|
||||||
poll.options.map { it.text },
|
poll.options.map { it.text },
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEnt
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
|
||||||
@ -21,7 +21,7 @@ data class TextContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendMessage(
|
): Request<Message> = SendMessage(
|
||||||
chatId,
|
chatId,
|
||||||
toHtmlTexts().first(),
|
toHtmlTexts().first(),
|
||||||
HTMLParseMode,
|
HTMLParseMode,
|
||||||
@ -36,7 +36,7 @@ data class TextContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): List<Request<RawMessage>> = createResends(
|
): List<Request<Message>> = createResends(
|
||||||
chatId,
|
chatId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
@ -50,7 +50,7 @@ data class TextContent(
|
|||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?,
|
replyMarkup: KeyboardMarkup?,
|
||||||
parseMode: ParseMode = HTMLParseMode
|
parseMode: ParseMode = HTMLParseMode
|
||||||
): List<Request<RawMessage>> = when (parseMode) {
|
): List<Request<Message>> = when (parseMode) {
|
||||||
is MarkdownParseMode -> toMarkdownTexts()
|
is MarkdownParseMode -> toMarkdownTexts()
|
||||||
is HTMLParseMode -> toHtmlTexts()
|
is HTMLParseMode -> toHtmlTexts()
|
||||||
}.map {
|
}.map {
|
||||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
|
||||||
data class VenueContent(
|
data class VenueContent(
|
||||||
@ -15,7 +15,7 @@ data class VenueContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendVenue(
|
): Request<Message> = SendVenue(
|
||||||
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
interface ResendableContent {
|
interface ResendableContent {
|
||||||
fun createResend(
|
fun createResend(
|
||||||
@ -12,12 +12,12 @@ interface ResendableContent {
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<RawMessage>
|
): Request<Message>
|
||||||
|
|
||||||
fun createResends(
|
fun createResends(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): List<Request<RawMessage>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
): List<Request<Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
||||||
}
|
}
|
@ -7,11 +7,10 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
|
|
||||||
@ -26,22 +25,12 @@ data class AnimationContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = createResend(chatId, toHtmlCaptions().firstOrNull(), HTMLParseMode, disableNotification, replyToMessageId, replyMarkup)
|
): Request<Message> = SendAnimation(
|
||||||
|
|
||||||
@Deprecated("Will be fully replaced by default method")
|
|
||||||
fun createResend(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
caption: String?,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): Request<RawMessage> = SendAnimation(
|
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
caption,
|
toHtmlCaptions().firstOrNull(),
|
||||||
parseMode,
|
HTMLParseMode,
|
||||||
media.duration,
|
media.duration,
|
||||||
media.width,
|
media.width,
|
||||||
media.height,
|
media.height,
|
||||||
|
@ -9,7 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ data class AudioContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendAudio(
|
): Request<Message> = SendAudio(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
|
@ -9,7 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ data class DocumentContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendDocument(
|
): Request<Message> = SendDocument(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user