diff --git a/CHANGELOG.md b/CHANGELOG.md index a11a3fa8db..1e92639cc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ * New fields `ExtendedSupergroupChat#location` * New fields `AudioFile#fileName` and `VideoFile#fileName` * New fields `SendDocument#disableContentTypeDetection` and `InputMediaDocument#disableContentTypeDetection` +* `API`: + * Extensions `TelegramBot#pinChatMessage` now support any `Chat` and `Message`s from any `Chat` ## 0.29.4 diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt index b2c9f7e06b..ea73743556 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageIdentifier +import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat import dev.inmo.tgbotapi.types.message.abstracts.Message @@ -14,7 +15,7 @@ suspend fun TelegramBot.pinChatMessage( ) = execute(PinChatMessage(chatId, messageId, disableNotification)) suspend fun TelegramBot.pinChatMessage( - chat: PublicChat, + chat: Chat, messageId: MessageIdentifier, disableNotification: Boolean = false ) = pinChatMessage(chat.id, messageId, disableNotification) @@ -22,8 +23,4 @@ suspend fun TelegramBot.pinChatMessage( suspend fun TelegramBot.pinChatMessage( message: Message, disableNotification: Boolean = false -) = if (message.chat is PublicChat) { - pinChatMessage(message.chat.id, message.messageId, disableNotification) -} else { - error("It is possible to pin messages only in non one-to-one chats") -} +) = pinChatMessage(message.chat.id, message.messageId, disableNotification)