From 87071ca52c9ed7ea7a3c644147ede82d9f45e2a6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Apr 2021 21:02:11 +0600 Subject: [PATCH] deprecation of an old record audio and upload audio bot actions --- .../inmo/tgbotapi/types/actions/BotAction.kt | 26 +++++++++++++++++++ .../extensions/api/send/SendAction.kt | 16 ++++++++++++ .../extensions/api/send/SendActionDSL.kt | 16 ++++++++++++ 3 files changed, 58 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt index ed9d95b567..ea15453612 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/actions/BotAction.kt @@ -26,6 +26,8 @@ internal object BotActionSerializer: KSerializer { UploadVideoAction.actionName -> UploadVideoAction RecordAudioAction.actionName -> RecordAudioAction UploadAudioAction.actionName -> UploadAudioAction + RecordVoiceAction.actionName -> RecordVoiceAction + UploadVoiceAction.actionName -> UploadVoiceAction UploadDocumentAction.actionName -> UploadDocumentAction FindLocationAction.actionName -> FindLocationAction RecordVideoNoteAction.actionName -> RecordVideoNoteAction @@ -83,22 +85,46 @@ inline fun BotAction.asUploadVideo() = this as? UploadVideoAction * Will notify user that bot is recording some audio */ @Serializable(BotActionSerializer::class) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("RecordVoiceAction", "dev.inmo.tgbotapi.types.actions.RecordVoiceAction") +) object RecordAudioAction : BotAction() { override val actionName: String = "record_audio" } +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("recordVoice", "dev.inmo.tgbotapi.types.actions.recordVoice") +) inline val recordAudio get() = RecordAudioAction +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("asRecordVoice", "dev.inmo.tgbotapi.types.actions.asRecordVoice") +) inline fun BotAction.asRecordAudio() = this as? RecordAudioAction /** * Will notify user that bot is uploading some audio */ @Serializable(BotActionSerializer::class) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("UploadVoiceAction", "dev.inmo.tgbotapi.types.actions.UploadVoiceAction") +) object UploadAudioAction : BotAction() { override val actionName: String = "upload_audio" } +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("uploadVoice", "dev.inmo.tgbotapi.types.actions.uploadVoice") +) inline val uploadAudio get() = UploadAudioAction +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("asUploadVoice", "dev.inmo.tgbotapi.types.actions.asUploadVoice") +) inline fun BotAction.asUploadAudio() = this as? UploadAudioAction /** diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt index 237f91f4fd..71e11aef1c 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt @@ -35,10 +35,18 @@ suspend fun TelegramBot.sendActionUploadVideo( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadVideoAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionRecordVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionRecordVoice") +) suspend fun TelegramBot.sendActionRecordAudio( chatId: ChatIdentifier ) = sendBotAction(chatId, RecordAudioAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionUploadVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionUploadVoice") +) suspend fun TelegramBot.sendActionUploadAudio( chatId: ChatIdentifier ) = sendBotAction(chatId, UploadAudioAction) @@ -84,10 +92,18 @@ suspend fun TelegramBot.sendActionUploadVideo( chat: Chat ) = sendBotAction(chat, UploadVideoAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionRecordVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionRecordVoice") +) suspend fun TelegramBot.sendActionRecordAudio( chat: Chat ) = sendBotAction(chat, RecordAudioAction) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("sendActionUploadVoice", "dev.inmo.tgbotapi.extensions.api.send.sendActionUploadVoice") +) suspend fun TelegramBot.sendActionUploadAudio( chat: Chat ) = sendBotAction(chat, UploadAudioAction) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 84dbede24a..0e9f1fb94e 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -56,7 +56,15 @@ suspend fun TelegramBot.withTypingAction(chatId: ChatId, block: TelegramBotA suspend fun TelegramBot.withUploadPhotoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadPhotoAction, block) suspend fun TelegramBot.withRecordVideoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVideoAction, block) suspend fun TelegramBot.withUploadVideoAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVideoAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withRecordVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withRecordVoiceAction") +) suspend fun TelegramBot.withRecordAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordAudioAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withUploadVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withUploadVoiceAction") +) suspend fun TelegramBot.withUploadAudioAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadAudioAction, block) suspend fun TelegramBot.withRecordVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, RecordVoiceAction, block) suspend fun TelegramBot.withUploadVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) = withAction(chatId, UploadVoiceAction, block) @@ -70,7 +78,15 @@ suspend fun TelegramBot.withTypingAction(chat: Chat, block: TelegramBotActio suspend fun TelegramBot.withUploadPhotoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadPhotoAction, block) suspend fun TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVideoAction, block) suspend fun TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVideoAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withRecordVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withRecordVoiceAction") +) suspend fun TelegramBot.withRecordAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordAudioAction, block) +@Deprecated( + "Deprecated according to https://core.telegram.org/bots/api-changelog#april-26-2021", + ReplaceWith("withUploadVoiceAction", "dev.inmo.tgbotapi.extensions.api.send.withUploadVoiceAction") +) suspend fun TelegramBot.withUploadAudioAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadAudioAction, block) suspend fun TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, RecordVoiceAction, block) suspend fun TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback) = withAction(chat, UploadVoiceAction, block)