1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

UnpinAllChatMessages

This commit is contained in:
InsanusMokrassar 2020-11-04 23:44:13 +06:00
parent 0886781d61
commit 159ea6f1cc
3 changed files with 46 additions and 0 deletions

View File

@ -17,8 +17,10 @@
* New fields `ExtendedSupergroupChat#location` * New fields `ExtendedSupergroupChat#location`
* New fields `AudioFile#fileName` and `VideoFile#fileName` * New fields `AudioFile#fileName` and `VideoFile#fileName`
* New fields `SendDocument#disableContentTypeDetection` and `InputMediaDocument#disableContentTypeDetection` * New fields `SendDocument#disableContentTypeDetection` and `InputMediaDocument#disableContentTypeDetection`
* New request `UnpinAllChatMessages`
* `API`: * `API`:
* Extensions `TelegramBot#pinChatMessage` now support any `Chat` and `Message`s from any `Chat` * Extensions `TelegramBot#pinChatMessage` now support any `Chat` and `Message`s from any `Chat`
* New extensions `TelegramBot#unpinAllChatMessages`
## 0.29.4 ## 0.29.4

View File

@ -0,0 +1,28 @@
package dev.inmo.tgbotapi.requests.chat.modify
import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chatIdField
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
/**
* Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an
* administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or
* 'can_edit_messages' admin right in a channel.
*
* @see PinChatMessage
* @see UnpinChatMessage
*/
@Serializable
data class UnpinAllChatMessages(
@SerialName(chatIdField)
override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "unpinAllChatMessages"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,16 @@
package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.UnpinAllChatMessages
import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
suspend fun TelegramBot.unpinAllChatMessages(
chatId: ChatIdentifier
) = execute(UnpinAllChatMessages(chatId))
suspend fun TelegramBot.unpinAllChatMessages(
chat: Chat
) = unpinAllChatMessages(chat.id)