From d8f6429385f7d987d503d68a6c0260f4e97cc8a4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Aug 2022 11:47:39 +0600 Subject: [PATCH] solution for #636 --- CHANGELOG.md | 4 + .../extensions/api/LiveFlowLocation.kt | 151 +++++++++++++ .../tgbotapi/extensions/api/send/Replies.kt | 80 +++++++ .../extensions/api/send/SendLiveLocation.kt | 212 ++++++++++++++++++ ...{SendLocation.kt => SendStaticLocation.kt} | 9 +- .../tgbotapi/abstracts/types/ReplyMarkup.kt | 7 - .../abstracts/types/WithReplyMarkup.kt | 9 + .../dev/inmo/tgbotapi/requests/StopPoll.kt | 4 +- .../edit/abstracts/EditReplyMessage.kt | 4 +- .../ReplyingMarkupSendMessageRequest.kt | 4 +- .../tgbotapi/requests/send/games/SendGame.kt | 4 +- .../requests/send/payments/SendInvoice.kt | 2 +- 12 files changed, 470 insertions(+), 20 deletions(-) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt rename tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/{SendLocation.kt => SendStaticLocation.kt} (97%) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMarkup.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyMarkup.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index cca4e68fe3..3595948b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ## 2.2.2 +* `Core`: + * Interface `ReplyMakrup` has been renamed to `WithReplyMarkup` to correspond its purpose +* `API`: + * New API (`handleLiveLocation`) for live location streaming using `Flow` * `Utils`: * `buildEntities` now is inline * `Behaviour Builder`: diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt new file mode 100644 index 0000000000..6caa782d64 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt @@ -0,0 +1,151 @@ +package dev.inmo.tgbotapi.extensions.api + +import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob +import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions +import dev.inmo.tgbotapi.abstracts.* +import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation +import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +import dev.inmo.tgbotapi.types.location.LiveLocation +import dev.inmo.tgbotapi.types.location.Location +import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage +import dev.inmo.tgbotapi.types.message.content.LocationContent +import kotlinx.coroutines.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import kotlinx.serialization.Serializable +import kotlin.js.JsName +import kotlin.jvm.JvmName +import kotlin.math.ceil + +@Serializable +data class EditLiveLocationInfo( + override val latitude: Double, + override val longitude: Double, + override val horizontalAccuracy: Meters? = null, + override val heading: Degrees? = null, + override val proximityAlertRadius: Meters? = null, + override val replyMarkup: InlineKeyboardMarkup? = null +) : Locationed, HorizontallyAccured, ProximityAlertable, Headed, WithReplyMarkup + +/** + * Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing, + * the message will be sent again and new edits will be applied to the new message + */ +suspend fun TelegramBot.handleLiveLocation( + chatId: ChatIdentifier, + locationsFlow: Flow, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) { + var currentLiveLocationMessage: ContentMessage? = null + val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) { + while (isActive) { + delay(liveTimeMillis) + // Remove previous location message info to resend live location message + currentLiveLocationMessage = null + } + } + locationsFlow.collect { + val capturedLiveLocationMessage = currentLiveLocationMessage + if (capturedLiveLocationMessage == null) { + updateMessageJob.start() + currentLiveLocationMessage = sendLiveLocation( + chatId, + it.latitude, + it.longitude, + ceil(liveTimeMillis.toDouble() / 1000).toInt(), + it.horizontalAccuracy, + it.heading, + it.proximityAlertRadius, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply, + it.replyMarkup + ) + } else { + editLiveLocation( + capturedLiveLocationMessage, + it.latitude, + it.longitude, + it.horizontalAccuracy, + it.heading, + it.proximityAlertRadius, + it.replyMarkup + ) + } + } +} + +/** + * Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the + * [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo] + */ +@JvmName("handleLiveLocationWithLocation") +@JsName("handleLiveLocationWithLocation") +suspend fun TelegramBot.handleLiveLocation( + chatId: ChatIdentifier, + locationsFlow: Flow, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) { + handleLiveLocation( + chatId, + locationsFlow.map { + EditLiveLocationInfo( + it.latitude, + it.longitude, + it.horizontalAccuracy, + (it as? LiveLocation) ?.heading, + (it as? LiveLocation) ?.proximityAlertRadius, + (it as? WithReplyMarkup) ?.replyMarkup as? InlineKeyboardMarkup + ) + }, + liveTimeMillis, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply + ) +} + +/** + * Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the + * [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo] + */ +@JvmName("handleLiveLocationWithLatLong") +@JsName("handleLiveLocationWithLatLong") +suspend fun TelegramBot.handleLiveLocation( + chatId: ChatIdentifier, + locationsFlow: Flow>, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null +) { + handleLiveLocation( + chatId, + locationsFlow.map { (lat, long) -> + EditLiveLocationInfo( + lat, + long + ) + }, + liveTimeMillis, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply + ) +} diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 0bd006aeec..116c1e5387 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -1,6 +1,8 @@ package dev.inmo.tgbotapi.extensions.api.send +import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.extensions.api.* import dev.inmo.tgbotapi.extensions.api.send.games.sendGame import dev.inmo.tgbotapi.extensions.api.send.media.* import dev.inmo.tgbotapi.extensions.api.send.payments.sendInvoice @@ -29,6 +31,10 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.utils.RiskFeature +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import kotlin.js.JsName +import kotlin.jvm.JvmName // Contact @@ -1006,6 +1012,80 @@ suspend fun TelegramBot.reply( ) } +/** + * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update + * + * @see handleLiveLocation + */ +suspend fun TelegramBot.reply( + message: Message, + locationsFlow: Flow, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null +) = handleLiveLocation( + message.chat.id, + locationsFlow, + liveTimeMillis, + disableNotification, + protectContent, + message.messageId, + allowSendingWithoutReply +) + +/** + * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update + * + * @see handleLiveLocation + */ +@JvmName("replyLiveLocationWithLocation") +@JsName("replyLiveLocationWithLocation") +suspend fun TelegramBot.reply( + message: Message, + locationsFlow: Flow, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null +) { + handleLiveLocation( + message.chat.id, + locationsFlow, + liveTimeMillis, + disableNotification, + protectContent, + message.messageId, + allowSendingWithoutReply + ) +} + +/** + * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update + * + * @see handleLiveLocation + */ +@JvmName("replyLiveLocationWithLatLong") +@JsName("replyLiveLocationWithLatLong") +suspend fun TelegramBot.reply( + message: Message, + locationsFlow: Flow>, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null +) { + handleLiveLocation( + message.chat.id, + locationsFlow, + liveTimeMillis, + disableNotification, + protectContent, + message.messageId, + allowSendingWithoutReply + ) +} + suspend fun TelegramBot.reply( to: Message, mediaFile: TelegramMediaFile, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt new file mode 100644 index 0000000000..c96e676325 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt @@ -0,0 +1,212 @@ +package dev.inmo.tgbotapi.extensions.api.send + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.send.SendLiveLocation +import dev.inmo.tgbotapi.requests.send.SendStaticLocation +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.location.Location +import dev.inmo.tgbotapi.types.location.StaticLocation + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLocation( + chatId: ChatIdentifier, + latitude: Double, + longitude: Double, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + SendLiveLocation( + chatId, + latitude, + longitude, + livePeriod, + horizontalAccuracy, + heading, + proximityAlertRadius, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply, + replyMarkup + ) +) + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLocation( + chatId: ChatIdentifier, + location: Location, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLocation( + chatId, + location.latitude, + location.longitude, + livePeriod, + horizontalAccuracy, + heading, + proximityAlertRadius, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply, + replyMarkup +) + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLocation( + chat: Chat, + latitude: Double, + longitude: Double, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLocation( + chat.id, + latitude, + longitude, + livePeriod, + horizontalAccuracy, + heading, + proximityAlertRadius, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply, + replyMarkup +) + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLocation( + chat: Chat, + location: Location, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLocation( + chat.id, + location.latitude, + location.longitude, + livePeriod, + horizontalAccuracy, + heading, + proximityAlertRadius, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply, + replyMarkup +) + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLiveLocation( + chatId: ChatIdentifier, + latitude: Double, + longitude: Double, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLiveLocation( + chatId: ChatIdentifier, + location: Location, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLiveLocation( + chat: Chat, + latitude: Double, + longitude: Double, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ +suspend fun TelegramBot.sendLiveLocation( + chat: Chat, + location: Location, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt similarity index 97% rename from tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt index d571377951..af941fbb0a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.location.StaticLocation /** @@ -40,7 +41,7 @@ suspend fun TelegramBot.sendLocation( */ suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, - location: StaticLocation, + location: Location, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -87,7 +88,7 @@ suspend fun TelegramBot.sendLocation( */ suspend fun TelegramBot.sendLocation( chat: Chat, - location: StaticLocation, + location: Location, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -125,7 +126,7 @@ suspend fun TelegramBot.sendStaticLocation( */ suspend fun TelegramBot.sendStaticLocation( chatId: ChatIdentifier, - location: StaticLocation, + location: Location, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -154,7 +155,7 @@ suspend fun TelegramBot.sendStaticLocation( */ suspend fun TelegramBot.sendStaticLocation( chat: Chat, - location: StaticLocation, + location: Location, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMarkup.kt deleted file mode 100644 index dce59184d8..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMarkup.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.abstracts.types - -import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup - -interface ReplyMarkup { - val replyMarkup: KeyboardMarkup? -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyMarkup.kt new file mode 100644 index 0000000000..3429d822c8 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyMarkup.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.abstracts.types + +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup + +interface WithReplyMarkup { + val replyMarkup: KeyboardMarkup? +} +@Deprecated("Renamed", ReplaceWith("WithReplyMarkup", "dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup")) +typealias ReplyMarkup = WithReplyMarkup diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt index 1078ecf512..5705ec13e9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/StopPoll.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.requests import dev.inmo.tgbotapi.abstracts.types.MessageAction -import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup +import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -17,7 +17,7 @@ data class StopPoll( override val messageId: MessageIdentifier, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null -) : MessageAction, SimpleRequest, ReplyMarkup { +) : MessageAction, SimpleRequest, WithReplyMarkup { override fun method(): String = "stopPoll" override val resultDeserializer: DeserializationStrategy get() = PollSerializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt index 94bc78a3ce..45090bc8b7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.requests.edit.abstracts -import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup +import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -interface EditReplyMessage : ReplyMarkup { +interface EditReplyMessage : WithReplyMarkup { override val replyMarkup: InlineKeyboardMarkup? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt index f152390db7..0627d8d8d3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.requests.send.abstracts -import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup +import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup -interface ReplyingMarkupSendMessageRequest: SendMessageRequest, ReplyMarkup +interface ReplyingMarkupSendMessageRequest: SendMessageRequest, WithReplyMarkup diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt index 93c75b0338..086b69edbf 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.requests.send.games -import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup +import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -29,7 +29,7 @@ data class SendGame ( @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendMessageRequest>, - ReplyMarkup { + WithReplyMarkup { override fun method(): String = "sendGame" override val resultDeserializer: DeserializationStrategy> get() = commonResultDeserializer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt index a482268ade..0a51fafe4c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt @@ -72,7 +72,7 @@ data class SendInvoice( ChatRequest, DisableNotification, ReplyMessageId, - ReplyMarkup, + WithReplyMarkup, SendMessageRequest> { override fun method(): String = "sendInvoice" override val resultDeserializer: DeserializationStrategy>