diff --git a/CHANGELOG.md b/CHANGELOG.md index c09fa689d7..af68a25e48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 7.1.0 +**This update contains changes according to the [Telegram Bot API 6.7](https://core.telegram.org/bots/api-changelog#april-21-2023)** + * `API`: * Rename `editMessageCaption` to `editMessageMedia` due to wrong old naming * Add `edit` extensions for `InlineMessageIdentifier`s diff --git a/README.md b/README.md index cdfc5b81c8..2d37b38940 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.6-blue)](https://core.telegram.org/bots/api-changelog#march-9-2023) +# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.7-blue)](https://core.telegram.org/bots/api-changelog#april-21-2023) | Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Bookstack&message=Tutorial&color=blue&logo=bookstack)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index b8f5a82e4f..1f91e33efc 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -12,9 +12,12 @@ package dev.inmo.tgbotapi.extensions.utils import dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData import dev.inmo.tgbotapi.abstracts.FromUser import dev.inmo.tgbotapi.abstracts.WithUser +import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink import dev.inmo.tgbotapi.requests.send.payments.SendInvoice import dev.inmo.tgbotapi.requests.stickers.InputSticker +import dev.inmo.tgbotapi.types.ChatFolderInviteLink +import dev.inmo.tgbotapi.types.ChatFolderInviteLinkUnlimited import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.ChatIdWithThreadId import dev.inmo.tgbotapi.types.ChatIdentifier @@ -108,6 +111,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineK import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.LoginURLInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryChosenChatInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryCurrentChatInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardButton @@ -559,6 +563,25 @@ public inline fun WithUser.chatInviteLinkUnlimitedOrThrow(): ChatInviteLinkUnlim public inline fun WithUser.ifChatInviteLinkUnlimited(block: (ChatInviteLinkUnlimited) -> T): T? = chatInviteLinkUnlimitedOrNull() ?.let(block) +public inline fun WithUser.chatFolderInviteLinkOrNull(): ChatFolderInviteLink? = this as? + dev.inmo.tgbotapi.types.ChatFolderInviteLink + +public inline fun WithUser.chatFolderInviteLinkOrThrow(): ChatFolderInviteLink = this as + dev.inmo.tgbotapi.types.ChatFolderInviteLink + +public inline fun WithUser.ifChatFolderInviteLink(block: (ChatFolderInviteLink) -> T): T? = + chatFolderInviteLinkOrNull() ?.let(block) + +public inline fun WithUser.chatFolderInviteLinkUnlimitedOrNull(): ChatFolderInviteLinkUnlimited? = + this as? dev.inmo.tgbotapi.types.ChatFolderInviteLinkUnlimited + +public inline fun WithUser.chatFolderInviteLinkUnlimitedOrThrow(): ChatFolderInviteLinkUnlimited = + this as dev.inmo.tgbotapi.types.ChatFolderInviteLinkUnlimited + +public inline fun + WithUser.ifChatFolderInviteLinkUnlimited(block: (ChatFolderInviteLinkUnlimited) -> T): T? = + chatFolderInviteLinkUnlimitedOrNull() ?.let(block) + public inline fun WithUser.baseChosenInlineResultOrNull(): BaseChosenInlineResult? = this as? dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.BaseChosenInlineResult @@ -1013,6 +1036,36 @@ public inline fun WithUser.ifMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T): T? = messageGameShortNameCallbackQueryOrNull() ?.let(block) +public inline fun InlineQueryResultsButton.startOrNull(): InlineQueryResultsButton.Start? = this as? + dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.Start + +public inline fun InlineQueryResultsButton.startOrThrow(): InlineQueryResultsButton.Start = this as + dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.Start + +public inline fun + InlineQueryResultsButton.ifStart(block: (InlineQueryResultsButton.Start) -> T): T? = + startOrNull() ?.let(block) + +public inline fun InlineQueryResultsButton.unknownOrNull(): InlineQueryResultsButton.Unknown? = this + as? dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.Unknown + +public inline fun InlineQueryResultsButton.unknownOrThrow(): InlineQueryResultsButton.Unknown = this + as dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.Unknown + +public inline fun + InlineQueryResultsButton.ifUnknown(block: (InlineQueryResultsButton.Unknown) -> T): T? = + unknownOrNull() ?.let(block) + +public inline fun InlineQueryResultsButton.webAppOrNull(): InlineQueryResultsButton.WebApp? = this + as? dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.WebApp + +public inline fun InlineQueryResultsButton.webAppOrThrow(): InlineQueryResultsButton.WebApp = this + as dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.WebApp + +public inline fun + InlineQueryResultsButton.ifWebApp(block: (InlineQueryResultsButton.WebApp) -> T): T? = + webAppOrNull() ?.let(block) + public inline fun InputSticker.maskOrNull(): InputSticker.Mask? = this as? dev.inmo.tgbotapi.requests.stickers.InputSticker.Mask @@ -1898,6 +1951,18 @@ public inline fun InlineKeyboardButton.ifSwitchInlineQueryCurrentChatInlineKeyboardButton(block: (SwitchInlineQueryCurrentChatInlineKeyboardButton) -> T): T? = switchInlineQueryCurrentChatInlineKeyboardButtonOrNull() ?.let(block) +public inline fun InlineKeyboardButton.switchInlineQueryChosenChatInlineKeyboardButtonOrNull(): + SwitchInlineQueryChosenChatInlineKeyboardButton? = this as? + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryChosenChatInlineKeyboardButton + +public inline fun InlineKeyboardButton.switchInlineQueryChosenChatInlineKeyboardButtonOrThrow(): + SwitchInlineQueryChosenChatInlineKeyboardButton = this as + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryChosenChatInlineKeyboardButton + +public inline fun + InlineKeyboardButton.ifSwitchInlineQueryChosenChatInlineKeyboardButton(block: (SwitchInlineQueryChosenChatInlineKeyboardButton) -> T): + T? = switchInlineQueryChosenChatInlineKeyboardButtonOrNull() ?.let(block) + public inline fun InlineKeyboardButton.switchInlineQueryInlineKeyboardButtonOrNull(): SwitchInlineQueryInlineKeyboardButton? = this as? dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton