mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-29 21:48:43 +00:00
commit
50ae9ef955
68
CHANGELOG.md
68
CHANGELOG.md
@ -1,5 +1,73 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 0.22.0
|
||||||
|
|
||||||
|
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
|
||||||
|
* `SendMessage` was renamed to `SendTextMessage` and previous `SendMessage` is deprecated
|
||||||
|
* All `AbleToBe*` interfaces was renamed to `Possibly*`
|
||||||
|
* `AbleToBeEditedMessage` -> `PossiblyEditedMessage`
|
||||||
|
* `AbleToBeForwardedMessage` -> `PossiblyForwardedMessage`
|
||||||
|
* `AbleToBeMarkedUp` -> `PossiblyMarkedUp`
|
||||||
|
* `AbleToBeEditedMessage` -> `PossiblyEditedMessage`
|
||||||
|
* `ForwardedMessage` type was renamed to `ForwardInfo`
|
||||||
|
* `AnonymousForwardedMessage` -> `AnonymousForwardInfo`
|
||||||
|
* `UserForwardedMessage` -> `UserForwardInfo`
|
||||||
|
* `ForwardedFromChannelMessage` -> `ForwardFromChannelInfo`
|
||||||
|
* `PossiblyForwardedMessage#forwarded` field now renamed to `forwardInfo`
|
||||||
|
* All serializers in library now are `internal`. **If you have used some of them or I have marked as internal by a
|
||||||
|
mistake - don't hesitate to say this.**
|
||||||
|
* `EditChatMessage` now have generic type and extends `SimpleRequest<ContentMessage<GenericType>>`
|
||||||
|
* `ResendableContent` now extends `Request<out Message>` instead of `Request<Message>`
|
||||||
|
* Most part of requests have changed return type. They are listed below:
|
||||||
|
<details>
|
||||||
|
|
||||||
|
* `ForwardMessage`
|
||||||
|
* `GetChatAdministrators`
|
||||||
|
* `EditChatMessageLiveLocation`
|
||||||
|
* `StopChatMessageLiveLocation`
|
||||||
|
* `EditChatMessageText`
|
||||||
|
* `EditChatMessageCaption`
|
||||||
|
* `EditChatMessageMedia`
|
||||||
|
* `EditChatMessageReplyMarkup`
|
||||||
|
* `SendAnimation`
|
||||||
|
* `SendAudio`
|
||||||
|
* `SendContact`
|
||||||
|
* `SendLocation`
|
||||||
|
* `SendTextMessage`
|
||||||
|
* `SendPoll`
|
||||||
|
* `SendVenue`
|
||||||
|
* `SendGame`
|
||||||
|
* `SendDocument`
|
||||||
|
* `SendMediaGroup`
|
||||||
|
* `SendPhoto`
|
||||||
|
* `SendVideo`
|
||||||
|
* `SendVideoNote`
|
||||||
|
* `SendVoice`
|
||||||
|
* `SendSticker`
|
||||||
|
|
||||||
|
</details>
|
||||||
|
* Changed type of `createResend`
|
||||||
|
<details>
|
||||||
|
|
||||||
|
* `GameContent`
|
||||||
|
* `LocationContent`
|
||||||
|
* `PollContent`
|
||||||
|
* `TextContent`
|
||||||
|
* `VenueContent`
|
||||||
|
* `AnimationContent`
|
||||||
|
* `AudioContent`
|
||||||
|
* `DocumentContent`
|
||||||
|
* `ContactContent`
|
||||||
|
* `PhotoContent`
|
||||||
|
* `VideoContent`
|
||||||
|
* `VideoNoteContent`
|
||||||
|
* `VoiceContent`
|
||||||
|
* `StickerContent`
|
||||||
|
|
||||||
|
</details>
|
||||||
|
* Version updates:
|
||||||
|
* Ktor `1.2.6` -> `1.3.0`
|
||||||
|
|
||||||
## 0.21.0 TelegramBotAPI 4.5
|
## 0.21.0 TelegramBotAPI 4.5
|
||||||
|
|
||||||
* _**All `MessageEntity`'es now are replaced with `TextPart`**_
|
* _**All `MessageEntity`'es now are replaced with `TextPart`**_
|
||||||
|
@ -17,7 +17,7 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "0.21.0"
|
project.version = "0.22.0"
|
||||||
project.group = "com.github.insanusmokrassar"
|
project.group = "com.github.insanusmokrassar"
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
apply from: "publish.gradle"
|
||||||
|
@ -4,7 +4,7 @@ kotlin_coroutines_version=1.3.3
|
|||||||
kotlin_serialisation_runtime_version=0.14.0
|
kotlin_serialisation_runtime_version=0.14.0
|
||||||
klock_version=1.8.6
|
klock_version=1.8.6
|
||||||
uuid_version=0.0.7
|
uuid_version=0.0.7
|
||||||
ktor_version=1.2.6
|
ktor_version=1.3.0
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
|
||||||
|
@ -3,11 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.HttpClientCall
|
import io.ktor.client.call.HttpClientCall
|
||||||
|
import io.ktor.client.statement.HttpStatement
|
||||||
|
|
||||||
interface KtorCallFactory {
|
interface KtorCallFactory {
|
||||||
suspend fun <T: Any> prepareCall(
|
suspend fun <T: Any> prepareCall(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
request: Request<T>
|
request: Request<T>
|
||||||
) : HttpClientCall?
|
) : HttpStatement?
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ 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
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.HttpClientCall
|
|
||||||
import io.ktor.client.call.receive
|
import io.ktor.client.call.receive
|
||||||
import io.ktor.client.features.ClientRequestException
|
import io.ktor.client.features.ClientRequestException
|
||||||
import io.ktor.client.response.readText
|
import io.ktor.client.statement.HttpStatement
|
||||||
|
import io.ktor.client.statement.readText
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
@ -36,22 +36,20 @@ class KtorRequestsExecutor(
|
|||||||
|
|
||||||
override suspend fun <T : Any> execute(request: Request<T>): T {
|
override suspend fun <T : Any> execute(request: Request<T>): T {
|
||||||
return requestsLimiter.limit {
|
return requestsLimiter.limit {
|
||||||
var call: HttpClientCall? = null
|
var statement: HttpStatement? = null
|
||||||
for (factory in callsFactories) {
|
for (factory in callsFactories) {
|
||||||
call = factory.prepareCall(
|
statement = factory.prepareCall(
|
||||||
client,
|
client,
|
||||||
telegramAPIUrlsKeeper.commonAPIUrl,
|
telegramAPIUrlsKeeper.commonAPIUrl,
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
if (call != null) {
|
if (statement != null) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (call == null) {
|
|
||||||
throw IllegalArgumentException("Can't execute request: $request")
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
val content = call.response.receive<String>()
|
val response = statement ?.execute() ?: throw IllegalArgumentException("Can't execute request: $request")
|
||||||
|
val content = response.receive<String>()
|
||||||
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||||
|
|
||||||
(responseObject.result?.let {
|
(responseObject.result?.let {
|
||||||
@ -64,7 +62,7 @@ class KtorRequestsExecutor(
|
|||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
} ?: call.let {
|
} ?: response.let {
|
||||||
throw newRequestException(
|
throw newRequestException(
|
||||||
responseObject,
|
responseObject,
|
||||||
content,
|
content,
|
||||||
|
@ -4,9 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.HttpClientCall
|
import io.ktor.client.call.HttpClientCall
|
||||||
import io.ktor.client.call.call
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.accept
|
import io.ktor.client.statement.HttpStatement
|
||||||
import io.ktor.client.request.url
|
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.HttpMethod
|
import io.ktor.http.HttpMethod
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
@ -17,20 +16,23 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
request: Request<T>
|
request: Request<T>
|
||||||
): HttpClientCall? {
|
): HttpStatement? {
|
||||||
val preparedBody = prepareCallBody(client, baseUrl, request) ?: return null
|
val preparedBody = prepareCallBody(client, baseUrl, request) ?: return null
|
||||||
|
|
||||||
return client.call {
|
return HttpStatement(
|
||||||
url(
|
HttpRequestBuilder().apply {
|
||||||
methodsCache[request.method()] ?: "$baseUrl/${request.method()}".also {
|
url(
|
||||||
methodsCache[request.method()] = it
|
methodsCache[request.method()] ?: "$baseUrl/${request.method()}".also {
|
||||||
}
|
methodsCache[request.method()] = it
|
||||||
)
|
}
|
||||||
method = HttpMethod.Post
|
)
|
||||||
accept(ContentType.Application.Json)
|
method = HttpMethod.Post
|
||||||
|
accept(ContentType.Application.Json)
|
||||||
|
|
||||||
body = preparedBody
|
body = preparedBody
|
||||||
}
|
},
|
||||||
|
client
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun <T : Any> prepareCallBody(
|
protected abstract fun <T : Any> prepareCallBody(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import kotlinx.io.core.Closeable
|
import io.ktor.utils.io.core.Closeable
|
||||||
|
|
||||||
interface RequestsExecutor : Closeable {
|
interface RequestsExecutor : Closeable {
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||||
|
|
||||||
|
import io.ktor.utils.io.core.Closeable
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.io.core.Closeable
|
|
||||||
|
|
||||||
interface UpdatesPoller : Closeable {
|
interface UpdatesPoller : Closeable {
|
||||||
fun start(scope: CoroutineScope = CoroutineScope(Dispatchers.Default))
|
fun start(scope: CoroutineScope = CoroutineScope(Dispatchers.Default))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||||
import kotlinx.io.errors.IOException
|
import kotlinx.io.IOException
|
||||||
|
|
||||||
fun newRequestException(
|
fun newRequestException(
|
||||||
response: Response,
|
response: Response,
|
||||||
@ -22,10 +22,9 @@ 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
|
override val cause: Throwable? = null
|
||||||
) : IOException(
|
) : IOException(
|
||||||
message ?: "Something went wrong",
|
message ?: "Something went wrong"
|
||||||
cause
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
|
@ -3,10 +3,11 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val AbleToBeForwardedMessageDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<PossiblyForwardedMessage>()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ForwardMessage(
|
data class ForwardMessage(
|
||||||
@SerialName(fromChatIdField)
|
@SerialName(fromChatIdField)
|
||||||
@ -17,15 +18,14 @@ data class ForwardMessage(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
val disableNotification: Boolean = false
|
val disableNotification: Boolean = false
|
||||||
): SimpleRequest<Message>, MessageAction {
|
): SimpleRequest<PossiblyForwardedMessage>, MessageAction {
|
||||||
@Transient
|
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
get() = fromChatId
|
get() = fromChatId
|
||||||
|
|
||||||
override fun method(): String = "forwardMessage"
|
override fun method(): String = "forwardMessage"
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<PossiblyForwardedMessage>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = AbleToBeForwardedMessageDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ data class FileId(
|
|||||||
fun String.toInputFile(): InputFile = FileId(this)
|
fun String.toInputFile(): InputFile = FileId(this)
|
||||||
|
|
||||||
@Serializer(InputFile::class)
|
@Serializer(InputFile::class)
|
||||||
object InputFileSerializer : KSerializer<InputFile> {
|
internal object InputFileSerializer : KSerializer<InputFile> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(FileId::class.toString())
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(FileId::class.toString())
|
||||||
override fun serialize(encoder: Encoder, obj: InputFile) = encoder.encodeString(obj.fileId)
|
override fun serialize(encoder: Encoder, obj: InputFile) = encoder.encodeString(obj.fileId)
|
||||||
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
||||||
|
@ -51,6 +51,6 @@ fun InlineQuery.createAnswer(
|
|||||||
switchPmParameter
|
switchPmParameter
|
||||||
)
|
)
|
||||||
|
|
||||||
object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
|
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
|
||||||
InlineQueryResultSerializer
|
InlineQueryResultSerializer
|
||||||
)
|
)
|
||||||
|
@ -21,7 +21,7 @@ data class AnswerShippingQueryOk(
|
|||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
|
internal object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
|
||||||
ShippingOption.serializer()
|
ShippingOption.serializer()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,23 +3,22 @@ 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.abstracts.ChatMember
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.*
|
||||||
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
|
||||||
|
|
||||||
private val chatMembersListSerializer = ArrayListSerializer(
|
private val chatMembersListSerializer = ArrayListSerializer(
|
||||||
ChatMemberSerializerWithoutDeserialization
|
AdministratorChatMemberSerializerWithoutDeserialization
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetChatAdministrators(
|
data class GetChatAdministrators(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<List<ChatMember>> {
|
): ChatRequest, SimpleRequest<List<AdministratorChatMember>> {
|
||||||
override fun method(): String = "getChatAdministrators"
|
override fun method(): String = "getChatAdministrators"
|
||||||
override val resultDeserializer: DeserializationStrategy<List<ChatMember>>
|
override val resultDeserializer: DeserializationStrategy<List<AdministratorChatMember>>
|
||||||
get() = chatMembersListSerializer
|
get() = chatMembersListSerializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
@ -3,10 +3,15 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditChatMessageLiveLocation(
|
data class EditChatMessageLiveLocation(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -19,10 +24,10 @@ data class EditChatMessageLiveLocation(
|
|||||||
override val longitude: Double,
|
override val longitude: Double,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
) : EditChatMessage<LocationContent>, EditReplyMessage, EditLocationMessage {
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
override fun method(): String = "editMessageLiveLocation"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,14 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class StopChatMessageLiveLocation(
|
data class StopChatMessageLiveLocation(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -16,10 +20,10 @@ data class StopChatMessageLiveLocation(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage {
|
) : EditChatMessage<LocationContent>, EditReplyMessage {
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
override fun method(): String = "stopMessageLiveLocation"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,16 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
||||||
|
|
||||||
|
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<MessageContent>>()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditChatMessageReplyMarkup(
|
data class EditChatMessageReplyMarkup(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -18,11 +22,11 @@ data class EditChatMessageReplyMarkup(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage {
|
) : EditChatMessage<MessageContent>, EditReplyMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageReplyMarkupMethod
|
override fun method(): String = editMessageReplyMarkupMethod
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<MessageContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
|
||||||
interface EditChatMessage : SimpleRequest<Message>, MessageAction
|
interface EditChatMessage<MT: MessageContent> : SimpleRequest<ContentMessage<MT>>, MessageAction
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageCaptionMethod = "editMessageCaption"
|
const val editMessageCaptionMethod = "editMessageCaption"
|
||||||
@ -23,11 +26,11 @@ data class EditChatMessageCaption(
|
|||||||
override val parseMode: ParseMode? = null,
|
override val parseMode: ParseMode? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageCaptionMethod
|
override fun method(): String = editMessageCaptionMethod
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = MediaContentMessageResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,15 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageMediaMethod = "editMessageMedia"
|
const val editMessageMediaMethod = "editMessageMedia"
|
||||||
|
|
||||||
|
internal val MediaContentMessageResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<MediaContent>>()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditChatMessageMedia(
|
data class EditChatMessageMedia(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -21,7 +24,7 @@ data class EditChatMessageMedia(
|
|||||||
override val media: InputMedia,
|
override val media: InputMedia,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage, EditMediaMessage {
|
) : EditChatMessage<MediaContent>, EditReplyMessage, EditMediaMessage {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (media.file is MultipartFile) {
|
if (media.file is MultipartFile) {
|
||||||
@ -30,8 +33,8 @@ data class EditChatMessageMedia(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = editMessageMediaMethod
|
override fun method(): String = editMessageMediaMethod
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = MediaContentMessageResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.TextContentMessageResultDeserializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageTextMethod = "editMessageText"
|
const val editMessageTextMethod = "editMessageText"
|
||||||
@ -25,11 +27,11 @@ data class EditChatMessageText(
|
|||||||
override val disableWebPagePreview: Boolean? = null,
|
override val disableWebPagePreview: Boolean? = null,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageTextMethod
|
override fun method(): String = editMessageTextMethod
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = TextContentMessageResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,4 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
|||||||
get() = GameHighScoresSerializer
|
get() = GameHighScoresSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())
|
internal object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())
|
||||||
|
@ -4,10 +4,14 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.ContactContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<ContactContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendContact(
|
data class SendContact(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -24,8 +28,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<Message>,
|
) : SendMessageRequest<ContentMessage<ContactContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>
|
ReplyingMarkupSendMessageRequest<ContentMessage<ContactContent>>
|
||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@ -44,8 +48,8 @@ data class SendContact(
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun method(): String = "sendContact"
|
override fun method(): String = "sendContact"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<ContactContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,15 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
// TODO:: Add location tracker for tracking location
|
// TODO:: Add location tracker for tracking location
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendLocation(
|
data class SendLocation(
|
||||||
@ -24,14 +29,14 @@ 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<Message>,
|
) : SendMessageRequest<ContentMessage<LocationContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<LocationContent>>,
|
||||||
PositionedSendMessageRequest<Message>
|
PositionedSendMessageRequest<ContentMessage<LocationContent>>
|
||||||
{
|
{
|
||||||
|
|
||||||
override fun method(): String = "sendLocation"
|
override fun method(): String = "sendLocation"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,15 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
internal val TextContentMessageResultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendMessage(
|
data class SendTextMessage(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(textField)
|
@SerialName(textField)
|
||||||
@ -26,9 +29,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<Message>,
|
) : SendMessageRequest<ContentMessage<TextContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<TextContent>>,
|
||||||
TextableSendMessageRequest<Message>,
|
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
||||||
DisableWebPagePreview
|
DisableWebPagePreview
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
@ -38,8 +41,16 @@ data class SendMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendMessage"
|
override fun method(): String = "sendMessage"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = TextContentMessageResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"This declaration is deprecated due violation of common naming rules",
|
||||||
|
ReplaceWith(
|
||||||
|
"SendTextMessage"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typealias SendMessage = SendTextMessage
|
||||||
|
@ -4,10 +4,14 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.PollContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendPoll(
|
data class SendPoll(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -22,8 +26,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<Message>,
|
) : SendMessageRequest<ContentMessage<PollContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message> {
|
ReplyingMarkupSendMessageRequest<ContentMessage<PollContent>> {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (question.length !in pollQuestionTextLength) {
|
if (question.length !in pollQuestionTextLength) {
|
||||||
@ -40,8 +44,8 @@ data class SendPoll(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendPoll"
|
override fun method(): String = "sendPoll"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
@ -3,10 +3,13 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendVenue(
|
data class SendVenue(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -27,10 +30,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<Message>,
|
) : SendMessageRequest<ContentMessage<VenueContent>>,
|
||||||
PositionedSendMessageRequest<Message>,
|
PositionedSendMessageRequest<ContentMessage<VenueContent>>,
|
||||||
TitledSendMessageRequest<Message>,
|
TitledSendMessageRequest<ContentMessage<VenueContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>
|
ReplyingMarkupSendMessageRequest<ContentMessage<VenueContent>>
|
||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@ -51,8 +54,8 @@ data class SendVenue(
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun method(): String = "sendVenue"
|
override fun method(): String = "sendVenue"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,14 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendGame (
|
data class SendGame (
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -20,11 +24,11 @@ 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<Message>,
|
) : SendMessageRequest<ContentMessage<GameContent>>,
|
||||||
ReplyMarkup {
|
ReplyMarkup {
|
||||||
override fun method(): String = "sendGame"
|
override fun method(): String = "sendGame"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
@ -7,8 +7,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AnimationContent
|
||||||
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 SendAnimation(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> {
|
): Request<ContentMessage<AnimationContent>> {
|
||||||
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
|
||||||
@ -54,6 +55,9 @@ fun SendAnimation(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendAnimationData internal constructor(
|
data class SendAnimationData internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -78,13 +82,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<Message>,
|
) : DataRequest<ContentMessage<AnimationContent>>,
|
||||||
SendMessageRequest<Message>,
|
SendMessageRequest<ContentMessage<AnimationContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||||
TextableSendMessageRequest<Message>,
|
TextableSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||||
ThumbedSendMessageRequest<Message>,
|
ThumbedSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||||
DuratedSendMessageRequest<Message>,
|
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||||
SizedSendMessageRequest<Message>
|
SizedSendMessageRequest<ContentMessage<AnimationContent>>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -95,8 +99,8 @@ data class SendAnimationData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendAnimation"
|
override fun method(): String = "sendAnimation"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AudioContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ fun SendAudio(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> {
|
): Request<ContentMessage<AudioContent>> {
|
||||||
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
|
||||||
@ -55,6 +56,9 @@ fun SendAudio(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendAudioData internal constructor(
|
data class SendAudioData internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -79,13 +83,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<Message>,
|
) : DataRequest<ContentMessage<AudioContent>>,
|
||||||
SendMessageRequest<Message>,
|
SendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
TextableSendMessageRequest<Message>,
|
TextableSendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
ThumbedSendMessageRequest<Message>,
|
ThumbedSendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
TitledSendMessageRequest<Message>,
|
TitledSendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
DuratedSendMessageRequest<Message>,
|
DuratedSendMessageRequest<ContentMessage<AudioContent>>,
|
||||||
Performerable
|
Performerable
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
@ -97,8 +101,8 @@ data class SendAudioData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendAudio"
|
override fun method(): String = "sendAudio"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.DocumentContent
|
||||||
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 SendDocument(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> {
|
): Request<ContentMessage<DocumentContent>> {
|
||||||
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
|
||||||
@ -48,6 +49,9 @@ fun SendDocument(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendDocumentData internal constructor(
|
data class SendDocumentData internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -66,11 +70,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<Message>,
|
) : DataRequest<ContentMessage<DocumentContent>>,
|
||||||
SendMessageRequest<Message>,
|
SendMessageRequest<ContentMessage<DocumentContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<DocumentContent>>,
|
||||||
TextableSendMessageRequest<Message>,
|
TextableSendMessageRequest<ContentMessage<DocumentContent>>,
|
||||||
ThumbedSendMessageRequest<Message>
|
ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -81,8 +85,8 @@ data class SendDocumentData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendDocument"
|
override fun method(): String = "sendDocument"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -6,8 +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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||||
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
|
||||||
@ -20,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<Message>> {
|
): Request<List<MediaGroupMessage>> {
|
||||||
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")
|
||||||
}
|
}
|
||||||
@ -53,7 +53,8 @@ fun SendMediaGroup(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val messagesListSerializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer)
|
private val messagesListSerializer: ArrayListSerializer<MediaGroupMessage>
|
||||||
|
= ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendMediaGroupData internal constructor(
|
data class SendMediaGroupData internal constructor(
|
||||||
@ -64,7 +65,7 @@ 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<Message>>, SendMessageRequest<List<Message>> {
|
) : DataRequest<List<MediaGroupMessage>>, SendMessageRequest<List<MediaGroupMessage>> {
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
private val convertedMedia: String
|
private val convertedMedia: String
|
||||||
get() = jsonArray {
|
get() = jsonArray {
|
||||||
@ -77,7 +78,7 @@ data class SendMediaGroupData internal constructor(
|
|||||||
override fun method(): String = "sendMediaGroup"
|
override fun method(): String = "sendMediaGroup"
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
override val resultDeserializer: DeserializationStrategy<List<Message>>
|
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage>>
|
||||||
get() = messagesListSerializer
|
get() = messagesListSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun SendPhoto(
|
fun SendPhoto(
|
||||||
@ -19,7 +20,7 @@ fun SendPhoto(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> {
|
): Request<ContentMessage<PhotoContent>> {
|
||||||
val data = SendPhotoData(
|
val data = SendPhotoData(
|
||||||
chatId,
|
chatId,
|
||||||
(photo as? FileId) ?.fileId,
|
(photo as? FileId) ?.fileId,
|
||||||
@ -37,6 +38,9 @@ fun SendPhoto(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendPhotoData internal constructor(
|
data class SendPhotoData internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -53,10 +57,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<Message>,
|
) : DataRequest<ContentMessage<PhotoContent>>,
|
||||||
SendMessageRequest<Message>,
|
SendMessageRequest<ContentMessage<PhotoContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
|
||||||
TextableSendMessageRequest<Message>
|
TextableSendMessageRequest<ContentMessage<PhotoContent>>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -67,8 +71,8 @@ data class SendPhotoData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendPhoto"
|
override fun method(): String = "sendPhoto"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.StickerContent
|
||||||
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
|
||||||
@ -17,7 +18,7 @@ fun SendSticker(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> = SendStickerByFileId(
|
): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
|
||||||
chatId,
|
chatId,
|
||||||
sticker as? FileId,
|
sticker as? FileId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
@ -30,6 +31,9 @@ fun SendSticker(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<StickerContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendStickerByFileId internal constructor(
|
data class SendStickerByFileId internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -42,10 +46,10 @@ 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<Message>, ReplyingMarkupSendMessageRequest<Message> {
|
) : SendMessageRequest<ContentMessage<StickerContent>>, ReplyingMarkupSendMessageRequest<ContentMessage<StickerContent>> {
|
||||||
override fun method(): String = "sendSticker"
|
override fun method(): String = "sendSticker"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<StickerContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@ -54,7 +58,7 @@ data class SendStickerByFile internal constructor(
|
|||||||
@Transient
|
@Transient
|
||||||
private val sendStickerByFileId: SendStickerByFileId,
|
private val sendStickerByFileId: SendStickerByFileId,
|
||||||
val sticker: MultipartFile
|
val sticker: MultipartFile
|
||||||
) : MultipartRequest<Message>, Request<Message> by sendStickerByFileId {
|
) : MultipartRequest<ContentMessage<StickerContent>>, Request<ContentMessage<StickerContent>> 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,8 +7,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ fun SendVideo(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> {
|
): Request<ContentMessage<VideoContent>> {
|
||||||
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
|
||||||
@ -56,6 +57,9 @@ fun SendVideo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendVideoData internal constructor(
|
data class SendVideoData internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -82,13 +86,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<Message>,
|
) : DataRequest<ContentMessage<VideoContent>>,
|
||||||
SendMessageRequest<Message>,
|
SendMessageRequest<ContentMessage<VideoContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<VideoContent>>,
|
||||||
TextableSendMessageRequest<Message>,
|
TextableSendMessageRequest<ContentMessage<VideoContent>>,
|
||||||
ThumbedSendMessageRequest<Message>,
|
ThumbedSendMessageRequest<ContentMessage<VideoContent>>,
|
||||||
DuratedSendMessageRequest<Message>,
|
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
|
||||||
SizedSendMessageRequest<Message>
|
SizedSendMessageRequest<ContentMessage<VideoContent>>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -99,8 +103,8 @@ data class SendVideoData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendVideo"
|
override fun method(): String = "sendVideo"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoNoteContent
|
||||||
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 SendVideoNote(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> {
|
): Request<ContentMessage<VideoNoteContent>> {
|
||||||
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
|
||||||
@ -52,6 +53,9 @@ fun SendVideoNote(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoNoteContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendVideoNoteData internal constructor(
|
data class SendVideoNoteData internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -74,13 +78,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<Message>,
|
) : DataRequest<ContentMessage<VideoNoteContent>>,
|
||||||
SendMessageRequest<Message>,
|
SendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||||
TextableSendMessageRequest<Message>,
|
TextableSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||||
ThumbedSendMessageRequest<Message>,
|
ThumbedSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||||
DuratedSendMessageRequest<Message>,
|
DuratedSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||||
SizedSendMessageRequest<Message>
|
SizedSendMessageRequest<ContentMessage<VideoNoteContent>>
|
||||||
{
|
{
|
||||||
override val height: Int?
|
override val height: Int?
|
||||||
get() = width
|
get() = width
|
||||||
@ -94,8 +98,8 @@ data class SendVideoNoteData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendVideoNote"
|
override fun method(): String = "sendVideoNote"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<VideoNoteContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@ 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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VoiceContent
|
||||||
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 SendVoice(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> {
|
): Request<ContentMessage<VoiceContent>> {
|
||||||
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
|
||||||
@ -50,6 +51,9 @@ fun SendVoice(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendVoiceData internal constructor(
|
data class SendVoiceData internal constructor(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
@ -70,12 +74,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<Message>,
|
) : DataRequest<ContentMessage<VoiceContent>>,
|
||||||
SendMessageRequest<Message>,
|
SendMessageRequest<ContentMessage<VoiceContent>>,
|
||||||
ReplyingMarkupSendMessageRequest<Message>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||||
TextableSendMessageRequest<Message>,
|
TextableSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||||
ThumbedSendMessageRequest<Message>,
|
ThumbedSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||||
DuratedSendMessageRequest<Message>
|
DuratedSendMessageRequest<ContentMessage<VoiceContent>>
|
||||||
{
|
{
|
||||||
init {
|
init {
|
||||||
text ?.let {
|
text ?.let {
|
||||||
@ -86,8 +90,8 @@ data class SendVoiceData internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "sendVoice"
|
override fun method(): String = "sendVoice"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,12 @@ interface ChatMember {
|
|||||||
val user: User
|
val user: User
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object ChatMemberSerializerWithoutDeserialization : KSerializer<ChatMember> {
|
internal object AdministratorChatMemberSerializerWithoutDeserialization : KSerializer<AdministratorChatMember> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): ChatMember = ChatMemberDeserializationStrategy.deserialize(decoder)
|
override fun deserialize(decoder: Decoder): AdministratorChatMember
|
||||||
override fun serialize(encoder: Encoder, obj: ChatMember) = throw UnsupportedOperationException()
|
= ChatMemberDeserializationStrategy.deserialize(decoder) as AdministratorChatMember
|
||||||
|
override fun serialize(encoder: Encoder, obj: AdministratorChatMember) = throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
||||||
|
@ -6,7 +6,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
@Serializer(InlineQueryResult::class)
|
@Serializer(InlineQueryResult::class)
|
||||||
object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(InlineQueryResult::class.toString())
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(InlineQueryResult::class.toString())
|
||||||
override fun serialize(encoder: Encoder, obj: InlineQueryResult) {
|
override fun serialize(encoder: Encoder, obj: InlineQueryResult) {
|
||||||
when(obj) {
|
when(obj) {
|
||||||
|
@ -6,7 +6,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
@Serializer(InputMessageContent::class)
|
@Serializer(InputMessageContent::class)
|
||||||
object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
internal object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMessageContent::class.toString())
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMessageContent::class.toString())
|
||||||
override fun serialize(encoder: Encoder, obj: InputMessageContent) {
|
override fun serialize(encoder: Encoder, obj: InputMessageContent) {
|
||||||
when (obj) {
|
when (obj) {
|
||||||
|
@ -4,7 +4,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
@Serializer(InputMedia::class)
|
@Serializer(InputMedia::class)
|
||||||
object InputMediaSerializer : KSerializer<InputMedia> {
|
internal object InputMediaSerializer : KSerializer<InputMedia> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMedia::class.toString())
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMedia::class.toString())
|
||||||
override fun serialize(encoder: Encoder, obj: InputMedia) {
|
override fun serialize(encoder: Encoder, obj: InputMedia) {
|
||||||
when (obj) {
|
when (obj) {
|
||||||
|
@ -4,7 +4,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
@Serializer(MediaGroupMemberInputMedia::class)
|
@Serializer(MediaGroupMemberInputMedia::class)
|
||||||
object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
|
internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(MediaGroupMemberInputMedia::class.toString())
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(MediaGroupMemberInputMedia::class.toString())
|
||||||
override fun serialize(encoder: Encoder, obj: MediaGroupMemberInputMedia) {
|
override fun serialize(encoder: Encoder, obj: MediaGroupMemberInputMedia) {
|
||||||
when (obj) {
|
when (obj) {
|
||||||
|
@ -13,6 +13,6 @@ data class UserProfilePhotos (
|
|||||||
val photos: List<Photo>
|
val photos: List<Photo>
|
||||||
)
|
)
|
||||||
|
|
||||||
object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ArrayListSerializer(
|
internal object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ArrayListSerializer(
|
||||||
PhotoSerializer
|
PhotoSerializer
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton")
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton")
|
||||||
|
|
||||||
private fun resolveSerializer(json: JsonObject): KSerializer<out InlineKeyboardButton> {
|
private fun resolveSerializer(json: JsonObject): KSerializer<out InlineKeyboardButton> {
|
||||||
|
@ -4,7 +4,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
@Serializer(KeyboardMarkup::class)
|
@Serializer(KeyboardMarkup::class)
|
||||||
object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
|
internal object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(KeyboardMarkup::class.toString())
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(KeyboardMarkup::class.toString())
|
||||||
override fun serialize(encoder: Encoder, obj: KeyboardMarkup) {
|
override fun serialize(encoder: Encoder, obj: KeyboardMarkup) {
|
||||||
when(obj) {
|
when(obj) {
|
||||||
|
@ -11,7 +11,7 @@ import kotlinx.serialization.json.JsonObjectSerializer
|
|||||||
|
|
||||||
private val formatter = Json.nonstrict
|
private val formatter = Json.nonstrict
|
||||||
|
|
||||||
object PreviewChatSerializer : KSerializer<Chat> {
|
internal object PreviewChatSerializer : KSerializer<Chat> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): Chat {
|
override fun deserialize(decoder: Decoder): Chat {
|
||||||
@ -39,7 +39,7 @@ object PreviewChatSerializer : KSerializer<Chat> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
internal object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): ExtendedChat {
|
override fun deserialize(decoder: Decoder): ExtendedChat {
|
||||||
|
@ -13,7 +13,7 @@ fun Photo.biggest(): PhotoSize? = maxBy {
|
|||||||
it.resolution
|
it.resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
object PhotoSerializer : KSerializer<Photo> by ArrayListSerializer(
|
internal object PhotoSerializer : KSerializer<Photo> by ArrayListSerializer(
|
||||||
PhotoSize.serializer()
|
PhotoSize.serializer()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ data class ChannelMediaGroupMessage(
|
|||||||
override val mediaGroupId: MediaGroupIdentifier,
|
override val mediaGroupId: MediaGroupIdentifier,
|
||||||
override val content: MediaGroupContent,
|
override val content: MediaGroupContent,
|
||||||
override val editDate: DateTime?,
|
override val editDate: DateTime?,
|
||||||
override val forwarded: ForwardedMessage?,
|
override val forwardInfo: ForwardInfo?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
override val replyMarkup: InlineKeyboardMarkup?
|
override val replyMarkup: InlineKeyboardMarkup?
|
||||||
) : MediaGroupMessage
|
) : MediaGroupMessage
|
||||||
|
@ -15,7 +15,7 @@ data class ChannelMessage<T: MessageContent>(
|
|||||||
override val content: T,
|
override val content: T,
|
||||||
override val date: DateTime,
|
override val date: DateTime,
|
||||||
override val editDate: DateTime?,
|
override val editDate: DateTime?,
|
||||||
override val forwarded: ForwardedMessage?,
|
override val forwardInfo: ForwardInfo?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
override val replyMarkup: InlineKeyboardMarkup?,
|
override val replyMarkup: InlineKeyboardMarkup?,
|
||||||
val authorSignature: AuthorSignature?
|
val authorSignature: AuthorSignature?
|
||||||
|
@ -15,7 +15,7 @@ data class CommonMediaGroupMessage(
|
|||||||
override val mediaGroupId: MediaGroupIdentifier,
|
override val mediaGroupId: MediaGroupIdentifier,
|
||||||
override val content: MediaGroupContent,
|
override val content: MediaGroupContent,
|
||||||
override val editDate: DateTime?,
|
override val editDate: DateTime?,
|
||||||
override val forwarded: ForwardedMessage?,
|
override val forwardInfo: ForwardInfo?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
override val replyMarkup: InlineKeyboardMarkup?
|
override val replyMarkup: InlineKeyboardMarkup?
|
||||||
) : MediaGroupMessage, FromUserMessage
|
) : MediaGroupMessage, FromUserMessage
|
||||||
|
@ -16,7 +16,7 @@ data class CommonMessageImpl<T: MessageContent>(
|
|||||||
override val content: T,
|
override val content: T,
|
||||||
override val date: DateTime,
|
override val date: DateTime,
|
||||||
override val editDate: DateTime?,
|
override val editDate: DateTime?,
|
||||||
override val forwarded: ForwardedMessage?,
|
override val forwardInfo: ForwardInfo?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
override val replyMarkup: InlineKeyboardMarkup?,
|
override val replyMarkup: InlineKeyboardMarkup?,
|
||||||
val paymentInfo: PaymentInfo?
|
val paymentInfo: PaymentInfo?
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Renamed",
|
||||||
|
ReplaceWith(
|
||||||
|
"ForwardInfo",
|
||||||
|
"com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typealias ForwardedMessage = ForwardInfo
|
||||||
|
sealed class ForwardInfo {
|
||||||
|
abstract val dateOfOriginal: TelegramDate
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Renamed",
|
||||||
|
ReplaceWith(
|
||||||
|
"AnonymousForwardInfo",
|
||||||
|
"com.github.insanusmokrassar.TelegramBotAPI.types.message.AnonymousForwardInfo"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typealias AnonymousForwardedMessage = AnonymousForwardInfo
|
||||||
|
data class AnonymousForwardInfo(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val senderName: String
|
||||||
|
) : ForwardInfo()
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Renamed",
|
||||||
|
ReplaceWith(
|
||||||
|
"UserForwardInfo",
|
||||||
|
"com.github.insanusmokrassar.TelegramBotAPI.types.message.UserForwardInfo"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typealias UserForwardedMessage = UserForwardInfo
|
||||||
|
data class UserForwardInfo(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val from: User
|
||||||
|
) : ForwardInfo()
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Renamed",
|
||||||
|
ReplaceWith(
|
||||||
|
"ForwardFromChannelInfo",
|
||||||
|
"com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardFromChannelInfo"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typealias ForwardedFromChannelMessage = ForwardFromChannelInfo
|
||||||
|
data class ForwardFromChannelInfo(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val messageId: MessageIdentifier,
|
||||||
|
val channelChat: Chat,
|
||||||
|
val signature: String? = null
|
||||||
|
) : ForwardInfo()
|
@ -1,25 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
|
||||||
|
|
||||||
sealed class ForwardedMessage {
|
|
||||||
abstract val dateOfOriginal: TelegramDate
|
|
||||||
}
|
|
||||||
|
|
||||||
data class AnonymousForwardedMessage(
|
|
||||||
override val dateOfOriginal: TelegramDate,
|
|
||||||
val senderName: String
|
|
||||||
) : ForwardedMessage()
|
|
||||||
|
|
||||||
data class UserForwardedMessage(
|
|
||||||
override val dateOfOriginal: TelegramDate,
|
|
||||||
val from: User
|
|
||||||
) : ForwardedMessage()
|
|
||||||
|
|
||||||
data class ForwardedFromChannelMessage(
|
|
||||||
override val dateOfOriginal: TelegramDate,
|
|
||||||
val messageId: MessageIdentifier,
|
|
||||||
val channelChat: Chat,
|
|
||||||
val signature: String? = null
|
|
||||||
) : ForwardedMessage()
|
|
@ -134,20 +134,20 @@ internal data class RawMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private val forwarded: ForwardedMessage? by lazy {
|
private val forwarded: ForwardInfo? by lazy {
|
||||||
forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||||
when {
|
when {
|
||||||
forward_sender_name != null -> AnonymousForwardedMessage(
|
forward_sender_name != null -> AnonymousForwardInfo(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_sender_name
|
forward_sender_name
|
||||||
)
|
)
|
||||||
forward_from_chat != null -> ForwardedFromChannelMessage(
|
forward_from_chat != null -> ForwardFromChannelInfo(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"),
|
forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"),
|
||||||
forward_from_chat,
|
forward_from_chat,
|
||||||
forward_signature
|
forward_signature
|
||||||
)
|
)
|
||||||
forward_from != null -> UserForwardedMessage(
|
forward_from != null -> UserForwardInfo(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from
|
forward_from
|
||||||
)
|
)
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage
|
|
||||||
|
|
||||||
interface AbleToBeForwardedMessage : Message {
|
|
||||||
val forwarded: ForwardedMessage?
|
|
||||||
}
|
|
@ -3,8 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
|
||||||
interface CommonMessage<T: MessageContent> : Message,
|
interface CommonMessage<T: MessageContent> : Message,
|
||||||
AbleToBeForwardedMessage,
|
PossiblyForwardedMessage,
|
||||||
AbleToBeEditedMessage,
|
PossiblyEditedMessage,
|
||||||
AbleToReplyMessage,
|
PossiblyReplyMessage,
|
||||||
AbleToBeMarkedUp,
|
PossiblyMarkedUp,
|
||||||
ContentMessage<T>
|
ContentMessage<T>
|
||||||
|
@ -13,24 +13,29 @@ interface Message {
|
|||||||
val date: DateTime
|
val date: DateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object TelegramBotAPIMessageDeserializationStrategy : DeserializationStrategy<Message> {
|
internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : DeserializationStrategy<T> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer")
|
override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer")
|
||||||
|
|
||||||
override fun patch(decoder: Decoder, old: Message): Message = throw UpdateNotSupportedException(descriptor.name)
|
override fun patch(decoder: Decoder, old: T): T = throw UpdateNotSupportedException(descriptor.name)
|
||||||
override fun deserialize(decoder: Decoder): Message {
|
override fun deserialize(decoder: Decoder): T {
|
||||||
return RawMessage.serializer().deserialize(decoder).asMessage
|
return RawMessage.serializer().deserialize(decoder).asMessage as T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal object TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
: DeserializationStrategy<Message> by TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
internal object TelegramBotAPIMessageDeserializeOnlySerializer : KSerializer<Message> {
|
internal class TelegramBotAPIMessageDeserializeOnlySerializerClass<T : Message> : KSerializer<T> {
|
||||||
|
private val deserializer = TelegramBotAPIMessageDeserializationStrategyClass<T>()
|
||||||
override val descriptor: SerialDescriptor
|
override val descriptor: SerialDescriptor
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy.descriptor
|
get() = deserializer.descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): Message {
|
override fun deserialize(decoder: Decoder): T {
|
||||||
return TelegramBotAPIMessageDeserializationStrategy.deserialize(decoder)
|
return deserializer.deserialize(decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: Message) {
|
override fun serialize(encoder: Encoder, obj: T) {
|
||||||
throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer")
|
throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal object TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
|
: KSerializer<Message> by TelegramBotAPIMessageDeserializeOnlySerializerClass()
|
||||||
|
@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
|||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
|
||||||
interface AbleToBeEditedMessage : Message {
|
interface PossiblyEditedMessage : Message {
|
||||||
val editDate: DateTime?
|
val editDate: DateTime?
|
||||||
}
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo
|
||||||
|
|
||||||
|
interface PossiblyForwardedMessage : Message {
|
||||||
|
val forwardInfo: ForwardInfo?
|
||||||
|
@Deprecated(
|
||||||
|
"Renamed",
|
||||||
|
ReplaceWith("forwardInfo")
|
||||||
|
)
|
||||||
|
val forwarded: ForwardInfo?
|
||||||
|
get() = forwardInfo
|
||||||
|
}
|
@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
interface AbleToBeMarkedUp {
|
interface PossiblyMarkedUp {
|
||||||
val replyMarkup: InlineKeyboardMarkup?
|
val replyMarkup: InlineKeyboardMarkup?
|
||||||
}
|
}
|
@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
||||||
|
|
||||||
interface AbleToBePaymentedMessage : Message {
|
interface PossiblyPaymentMessage : Message {
|
||||||
val paymentInfo: PaymentInfo?
|
val paymentInfo: PaymentInfo?
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||||
|
|
||||||
interface AbleToReplyMessage {
|
interface PossiblyReplyMessage {
|
||||||
val replyTo: Message?
|
val replyTo: Message?
|
||||||
}
|
}
|
@ -4,6 +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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ data class ContactContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendContact(
|
): Request<ContentMessage<ContactContent>> = SendContact(
|
||||||
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -6,6 +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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ data class GameContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendGame(
|
): Request<ContentMessage<GameContent>> = SendGame(
|
||||||
chatId,
|
chatId,
|
||||||
game.title,
|
game.title,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
|
@ -4,6 +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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ data class LocationContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendLocation(
|
): Request<ContentMessage<LocationContent>> = SendLocation(
|
||||||
chatId,
|
chatId,
|
||||||
location.latitude,
|
location.latitude,
|
||||||
location.longitude,
|
location.longitude,
|
||||||
|
@ -5,6 +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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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 +18,7 @@ data class PollContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendPoll(
|
): Request<ContentMessage<PollContent>> = SendPoll(
|
||||||
chatId,
|
chatId,
|
||||||
poll.question,
|
poll.question,
|
||||||
poll.options.map { it.text },
|
poll.options.map { it.text },
|
||||||
|
@ -3,10 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendTextMessage
|
||||||
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.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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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.*
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
|
||||||
@ -20,7 +22,7 @@ data class TextContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendMessage(
|
): Request<ContentMessage<TextContent>> = SendTextMessage(
|
||||||
chatId,
|
chatId,
|
||||||
toHtmlTexts().first(),
|
toHtmlTexts().first(),
|
||||||
HTMLParseMode,
|
HTMLParseMode,
|
||||||
@ -35,7 +37,7 @@ data class TextContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): List<Request<Message>> = createResends(
|
): List<Request<ContentMessage<TextContent>>> = createResends(
|
||||||
chatId,
|
chatId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
@ -49,12 +51,12 @@ data class TextContent(
|
|||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?,
|
replyMarkup: KeyboardMarkup?,
|
||||||
parseMode: ParseMode = HTMLParseMode
|
parseMode: ParseMode = HTMLParseMode
|
||||||
): List<Request<Message>> = when (parseMode) {
|
): List<Request<ContentMessage<TextContent>>> = when (parseMode) {
|
||||||
is MarkdownParseMode -> toMarkdownTexts()
|
is MarkdownParseMode -> toMarkdownTexts()
|
||||||
is MarkdownV2ParseMode -> toMarkdownV2Texts()
|
is MarkdownV2ParseMode -> toMarkdownV2Texts()
|
||||||
is HTMLParseMode -> toHtmlTexts()
|
is HTMLParseMode -> toHtmlTexts()
|
||||||
}.map {
|
}.map {
|
||||||
SendMessage(
|
SendTextMessage(
|
||||||
chatId,
|
chatId,
|
||||||
it,
|
it,
|
||||||
parseMode,
|
parseMode,
|
||||||
|
@ -4,6 +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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ data class VenueContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendVenue(
|
): Request<ContentMessage<VenueContent>> = SendVenue(
|
||||||
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -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<Message>
|
): Request<out 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<Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
): List<Request<out Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ 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.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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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
|
||||||
@ -25,7 +26,7 @@ data class AnimationContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendAnimation(
|
): Request<ContentMessage<AnimationContent>> = SendAnimation(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
|
@ -9,6 +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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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 +24,7 @@ data class AudioContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendAudio(
|
): Request<ContentMessage<AudioContent>> = SendAudio(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
|
@ -9,6 +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.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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 +24,7 @@ data class DocumentContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendDocument(
|
): Request<ContentMessage<DocumentContent>> = SendDocument(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
|
@ -11,6 +11,7 @@ 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.PhotoSize
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaCollectionContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaCollectionContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||||
@ -28,7 +29,7 @@ data class PhotoContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendPhoto(
|
): Request<ContentMessage<PhotoContent>> = SendPhoto(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
toHtmlCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
|
@ -6,6 +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.files.Sticker
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ data class StickerContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendSticker(
|
): Request<ContentMessage<StickerContent>> = SendSticker(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
|
@ -10,6 +10,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.VideoFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
@ -24,7 +25,7 @@ data class VideoContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendVideo(
|
): Request<ContentMessage<VideoContent>> = SendVideo(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
|
@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
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.VideoNoteFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoNoteFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ data class VideoNoteContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup)
|
): Request<ContentMessage<VideoNoteContent>> = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|
||||||
fun createResend(
|
fun createResend(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@ -27,7 +28,7 @@ data class VideoNoteContent(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<Message> = SendVideoNote(
|
): Request<ContentMessage<VideoNoteContent>> = SendVideoNote(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
|
@ -9,6 +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.VoiceFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
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 +24,7 @@ data class VoiceContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<Message> = SendVoice(
|
): Request<ContentMessage<VoiceContent>> = SendVoice(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
null,
|
null,
|
||||||
|
@ -16,6 +16,6 @@ data class ShippingOption(
|
|||||||
override val prices: List<LabeledPrice>
|
override val prices: List<LabeledPrice>
|
||||||
) : Priced
|
) : Priced
|
||||||
|
|
||||||
object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ArrayListSerializer(
|
internal object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ArrayListSerializer(
|
||||||
LabeledPrice.serializer()
|
LabeledPrice.serializer()
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,7 @@ data class AnonymousPollOption (
|
|||||||
override val votes: Int
|
override val votes: Int
|
||||||
) : PollOption()
|
) : PollOption()
|
||||||
|
|
||||||
object PollOptionSerializer : KSerializer<PollOption> {
|
internal object PollOptionSerializer : KSerializer<PollOption> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption")
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption")
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): PollOption = AnonymousPollOption.serializer().deserialize(
|
override fun deserialize(decoder: Decoder): PollOption = AnonymousPollOption.serializer().deserialize(
|
||||||
|
@ -2,18 +2,18 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||||
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.ForwardedMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||||
|
|
||||||
val List<BaseMessageUpdate>.forwarded: ForwardedMessage?
|
val List<BaseMessageUpdate>.forwarded: ForwardInfo?
|
||||||
get() = first().let {
|
get() = first().let {
|
||||||
(it as? AbleToBeForwardedMessage) ?.forwarded
|
(it as? PossiblyForwardedMessage) ?.forwardInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
val List<BaseMessageUpdate>.replyTo: Message?
|
val List<BaseMessageUpdate>.replyTo: Message?
|
||||||
get() = first().let {
|
get() = first().let {
|
||||||
(it as? AbleToReplyMessage) ?.replyTo
|
(it as? PossiblyReplyMessage) ?.replyTo
|
||||||
}
|
}
|
||||||
|
|
||||||
val List<BaseMessageUpdate>.chat: Chat?
|
val List<BaseMessageUpdate>.chat: Chat?
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||||
|
|
||||||
import kotlinx.io.core.Input
|
import io.ktor.utils.io.core.Input
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||||
|
|
||||||
import com.benasher44.uuid.uuid4
|
import com.benasher44.uuid.uuid4
|
||||||
import kotlinx.io.core.Input
|
import io.ktor.utils.io.core.Input
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||||
|
|
||||||
import com.benasher44.uuid.uuid4
|
import com.benasher44.uuid.uuid4
|
||||||
import kotlinx.io.core.Input
|
import io.ktor.utils.io.core.Input
|
||||||
import kotlinx.io.streams.asInput
|
import io.ktor.utils.io.streams.asInput
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
Loading…
Reference in New Issue
Block a user