From 92407c9010ad468c87745c54cb4d107bea7928fd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Aug 2022 18:09:25 +0600 Subject: [PATCH] remove deprecations from copyMessage --- .../extensions/api/send/CopyMessage.kt | 221 ++++++++++++++++++ .../extensions/api/send/OldCopyMessage.kt | 180 -------------- .../tgbotapi/extensions/api/send/Replies.kt | 13 +- .../tgbotapi/requests/send/CopyMessage.kt | 6 +- 4 files changed, 235 insertions(+), 185 deletions(-) delete mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/OldCopyMessage.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt index 3ddc68161e..5cb4239dd1 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt @@ -229,3 +229,224 @@ suspend inline fun TelegramBot.copyMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage(message.chat, message.messageId, toChat, entities, 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 inline fun TelegramBot.copyMessage( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageId: MessageIdentifier, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + CopyMessage( + fromChatId, + messageId, + toChatId, + text, + parseMode, + 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 inline fun TelegramBot.copyMessage( + toChatId: ChatIdentifier, + fromChat: Chat, + messageId: MessageIdentifier, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = copyMessage( + toChatId, + fromChat.id, + messageId, + text, + parseMode, + 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 inline fun TelegramBot.copyMessage( + toChat: Chat, + fromChatId: ChatIdentifier, + messageId: MessageIdentifier, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = copyMessage( + toChat.id, + fromChatId, + messageId, + text, + parseMode, + 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 inline fun TelegramBot.copyMessage( + toChat: Chat, + fromChat: Chat, + messageId: MessageIdentifier, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = copyMessage( + toChat.id, + fromChat.id, + messageId, + text, + parseMode, + 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 inline fun TelegramBot.copyMessage( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageId: MessageIdentifier, + entities: TextSourcesList, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + CopyMessage( + fromChatId, + messageId, + toChatId, + entities, + 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 inline fun TelegramBot.copyMessage( + toChatId: ChatIdentifier, + fromChat: Chat, + messageId: MessageIdentifier, + entities: TextSourcesList, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = copyMessage( + toChatId, + fromChat.id, + messageId, + entities, + 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 inline fun TelegramBot.copyMessage( + toChat: Chat, + fromChatId: ChatIdentifier, + messageId: MessageIdentifier, + entities: TextSourcesList, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = copyMessage( + toChat.id, + fromChatId, + messageId, + entities, + 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 inline fun TelegramBot.copyMessage( + toChat: Chat, + fromChat: Chat, + messageId: MessageIdentifier, + entities: TextSourcesList, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = copyMessage( + toChat.id, + fromChat.id, + messageId, + entities, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply, + replyMarkup +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/OldCopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/OldCopyMessage.kt deleted file mode 100644 index f546a93451..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/OldCopyMessage.kt +++ /dev/null @@ -1,180 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.send - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.send.CopyMessage -import dev.inmo.tgbotapi.requests.send.OrderChangingDeprecationWarn -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageIdentifier -import dev.inmo.tgbotapi.types.message.ParseMode -import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup -import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message - -// TODO:: Swap fromChatId and toChatId for more correct order of parameters - -/** - * @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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChatId: ChatIdentifier, - toChatId: ChatIdentifier, - messageId: MessageIdentifier, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - CopyMessage( - fromChatId, - messageId, - toChatId, - text, - parseMode, - 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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChat: Chat, - toChatId: ChatIdentifier, - messageId: MessageIdentifier, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, 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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChatId: ChatIdentifier, - toChat: Chat, - messageId: MessageIdentifier, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, 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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChat: Chat, - toChat: Chat, - messageId: MessageIdentifier, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, 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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChatId: ChatIdentifier, - toChatId: ChatIdentifier, - messageId: MessageIdentifier, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = execute( - CopyMessage( - fromChatId, - messageId, - toChatId, - entities, - 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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChat: Chat, - toChatId: ChatIdentifier, - messageId: MessageIdentifier, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, toChatId, messageId, entities, 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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChatId: ChatIdentifier, - toChat: Chat, - messageId: MessageIdentifier, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, toChat.id, messageId, entities, 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 - */ -@Deprecated(OrderChangingDeprecationWarn) -suspend inline fun TelegramBot.copyMessage( - fromChat: Chat, - toChat: Chat, - messageId: MessageIdentifier, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageIdentifier? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) 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 a857405cf6..0bd006aeec 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 @@ -950,7 +950,18 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, to.chat.id, messageId, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage( + to.chat.id, + fromChatId, + messageId, + text, + parseMode, + disableNotification, + protectContent, + to.messageId, + allowSendingWithoutReply, + replyMarkup +) suspend inline fun TelegramBot.reply( to: Message, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt index c079f297a7..a2bb4ad842 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt @@ -20,10 +20,9 @@ import kotlinx.serialization.* const val OrderChangingDeprecationWarn = "The order of parameters in this factory will be changed soon. To avoid unexpected behaviour, swap message id and target chat id parameters" -@Deprecated(OrderChangingDeprecationWarn) fun CopyMessage( - fromChatId: ChatIdentifier, toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, messageId: MessageIdentifier, text: String? = null, parseMode: ParseMode? = null, @@ -46,10 +45,9 @@ fun CopyMessage( replyMarkup ) -@Deprecated(OrderChangingDeprecationWarn) fun CopyMessage( - fromChatId: ChatIdentifier, toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, messageId: MessageIdentifier, entities: List, disableNotification: Boolean = false,