mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
supporting of private chats in pinChatMessage
This commit is contained in:
parent
2a33216006
commit
60d5581ec6
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user