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

editForumtTopic optional fields

This commit is contained in:
InsanusMokrassar 2022-12-30 20:32:05 +06:00
parent 8b5da90e28
commit 463d5252bd
2 changed files with 7 additions and 11 deletions

View File

@ -11,8 +11,8 @@ import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.editForumTopic( suspend fun TelegramBot.editForumTopic(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageThreadId: MessageThreadId, messageThreadId: MessageThreadId,
name: String, name: String? = null,
iconEmojiId: CustomEmojiId iconEmojiId: CustomEmojiId? = null
) = execute( ) = execute(
EditForumTopic( EditForumTopic(
chatId, chatId,
@ -25,12 +25,12 @@ suspend fun TelegramBot.editForumTopic(
suspend fun TelegramBot.editForumTopic( suspend fun TelegramBot.editForumTopic(
chat: Chat, chat: Chat,
messageThreadId: MessageThreadId, messageThreadId: MessageThreadId,
name: String, name: String? = null,
iconEmojiId: CustomEmojiId iconEmojiId: CustomEmojiId? = null
) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId) ) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
suspend fun TelegramBot.editForumTopic( suspend fun TelegramBot.editForumTopic(
chatIdentifier: ChatIdentifier, chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic, forumTopic: ForumTopic,
iconEmojiId: CustomEmojiId = forumTopic.iconEmojiId ?: error("Icon emoji id in forum topic should be presented when edit forum topic basing on other forum topic object") iconEmojiId: CustomEmojiId? = forumTopic.iconEmojiId
) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId) ) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)

View File

@ -1,11 +1,7 @@
package dev.inmo.tgbotapi.requests.chat.forum package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable @Serializable
data class EditForumTopic ( data class EditForumTopic (
@ -14,9 +10,9 @@ data class EditForumTopic (
@SerialName(messageThreadIdField) @SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId, val messageThreadId: MessageThreadId,
@SerialName(nameField) @SerialName(nameField)
val name: String, val name: String? = null,
@SerialName(iconCustomEmojiIdField) @SerialName(iconCustomEmojiIdField)
val iconEmojiId: CustomEmojiId, val iconEmojiId: CustomEmojiId? = null,
): ModifyForumRequest { ): ModifyForumRequest {
init { init {
if (name.length !in threadNameLength) { if (name.length !in threadNameLength) {